I have made a terrain that is generated from a height map file where each pixel (black to white) represent the height of the terrain at the corresponding location.
Now, my question is how would one make a map editor for something like that? I can think of two general ways:
1) The map editor modifies the height map file and regenerates the terrain based on that.
2) The map editor directly alters the vertices of the map, and later upon saving process it generates a height map based on those vertices.
Do you have any good tutorials or resources as to how to get either one to work? I have no idea where to begin.
Check out the XNA Terrain Editor by Eric Grossinger.
I've played around with this thing a little bit and it's pretty slick and should, at the very least, give you some ideas if not an out-right solution.
This book: Building XNA games is an excellent reference and has a great overview of how to create your map editor. The only downfall is it's in XNA 2.0 so you would have to do some converting, but the idea remains the same.
Related
I shifted to unity few weeks ago. I am developing a 2D platformer. For creating the maps I am using Tiled map editor from www.mapeditor.org . I have created a basic map. Included the tileSheet png and the .tmx file (saved as XML) in the Assets of the project. I am able to read the XML , that is all the gid's. But I don't know how to access a particular portion(tile) from the tileSheet corresponding to a gid.
I think for this I need to load sprite in the memory and select a tile (by specifying Height and width and coords) from texture memory to display it on screen. As given here :http://gamedevelopment.tutsplus.com/tutorials/parsing-and-rendering-tiled-tmx-format-maps-in-your-own-game-engine--gamedev-3104
but its for flash , how I can achieve same thing in Unity using C#. Notice the copyPixel stuff in the flash code. I thought I could use ReadPixels but it is used for reading from screen only not the texture memory.
Thanks.
If you're working in Windows then the Tiled2Unity Utility sounds like it will fit your needs. It exports Object Layers and was made with Unity 4.3 features in mind.
(Full disclosure: I'm the author of Tiled2Unity)
EDIT: Tiled2Unity is available for Mac users as well now. There is a command-line version for Linux users. (all free)
If you can describe more carefully your problem and what you are trying to do, maybe myself or someone can help you better, for example what exactly do you mean by "load a sprite into memory"? Or "select a tile"? Copying pixel data is SLOWWW, and hopefully you don't mean to be doing this in real time.
Here is my real advice though:
Have you checked out UTiled? It does tiled maps in 2D in Unity so I think it already does what you want and it's free.
There is also UniTMX... free.
There is also 'Tiled Tilemaps'... which is like $2.
I also built a system that can also do what I think you are trying to do (your link is broken, so I can't be sure).
The system I built is called 'Tiled to Unity' (you can search it in youtube to see if it does what you want). It allows you to attach gameObjects to tiles and have tile variants, and can do 3D tiles.
Anyway, trying to roll your own pipeline from Tiled into Unity is a ton of work, and with these tools available, I think it is almost certainly unnecessary... That's just imo.
i recently downloaded "Tiled Map Editor" - because i heard it was a great tool for making maps. I also got a .tmx "compiler", well, something that made the .tmx usable in XNA.
I've created a map and imported it and it worked fine, but now the tricky part comes...
If i add a collision layer in "Tiled" and adds a tile that indicates block part, how would i get data and values, and how would i be able to use it in XNA? And how would i make so that the player spawns in a certain location, and also, how do i add things as events, and movable objects?
You don't have to tell me everything that, but it would be cool if you could give me an idea on how to get data and values from the .tmx and convert it into rectangles or such things^^
Thanks in advance!
I know nothing about tmx file but a little about collision.
I'm going to take a punt that your ".tmx "compiler"" is something that allows files of this type to be included in the content pipeline. Somewhere in this build process will be the vertex data that you can use to construct the collision primitives (shapes) for collision detection later.
ASIDE: it took me ages to get my head around the content pipeline - not for the faint hearted but the way to go. They are samples on the XNA website to get you going
I'm learning 3D programming and I decided to make a really simple "engine" where you can just fly around the map, etc. Only basic rendering of walls.
So, I was thinking - how can I save the level and how can I edit it. I don't want to make also an editor for it, because it is only a learning project, and not an actual game. So, I was looking towards this level format: UDMF http://zdoom.org/wiki/Universal_Doom_Map_Format although it is for a completely different type of game, still, it does what I need. Specifies vertices, floor, ceiling positions, etc. So, basic 2.5D geometry, which could be easily interpreted into a 3D space, which is more than enough for my purposes. There are also tons of editors (main reason).
BUT, I do realise that this is not really the best solution, and kind of workaround.
So, my question: Is there any "open" map format and "open" editors that I can use for my engine/game?
UPD: I'm working with C# and XNA, if that is important.
You could use XML (or something even simpler) that provides the location and other attributes of all the objects in the level. This would be the easiest solution (and have the benefit of containing whatever info you want but nothing else) but would not provide a level editor.
However, I know you want an editor (who wouldn't). Here is a very new, work-in-progress editor that looks interesting: 3D Scene Editor for XNA
I've used the .NET port of LibNoise to create a planetary map using its built-in sphere projection. However, now I want to wrap that texture around a sphere in XNA. I've got a sphere model, but I know very little about UV wrapping, etc. It's entirely possible, if not plausible, that the way I've put UV coordinates on my model absolutely will not work with the generated texture.
I've set up a small test project rather than fiddle around in my main game. It's your basic rotating model project. I'm using BasicEffect on the model and setting the Texture parameter as my map. However, all I see is the model with its default diffuse color and no texture.
For your convenience, the full code of the project:
Game1.cs
PlanetTerrainMap.cs
Required files:
sphere.fbx
EarthLookupTable.png
Also, I totally recognize that my map does not look like a map. I can handle that issue later. I just want to see all that crappy grain noise on the sphere so I can move forward.
Do I need to use a custom shader? Or do I need a different model?
Have you tried opening this in Blender? It's a great way to confirm if the UV coordinates specified in your model line up to the texture that your trying to use. If it's not going to render after it's imported in to Blender, it's highly likely you won't get it to Render in XNA without specifying the mapping yourself.
image http://prod.triplesign.com/map.jpg
How can I produce a similar output in C# window forms in the easiest way?
Is there a good library for this purpose?
I just needs to be pointed in the direction of which graphic library is best for this.
You should just roll your own in a 3d graphics library. You could use directx. If using WPF it is built-in, you can lookup viewport3d. http://msdn.microsoft.com/en-us/magazine/cc163449.aspx
In graphics programming what you are building is a very simple version of a heightmap. I think building your own would give your greater flexibility in the long run.
So a best library doesn't exist. There are plenty of them and some are just for different purposes. Here a small list of possibilities:
Tao: Make anything yourself with OpenGL
OpenTK: The successor of the Tao framework
Dundas: One of the best but quite expensive (lacks in real time performance)
Nevron: Quite good, but much cheaper (also has problems with real time data)
National Instruments: Expensive, not the best looking ones, but damn good in real time data.
... Probably someone else made some other experiences.
Checkout Microsoft Chart Controls library.
Here's how I'd implement this using OpenGL.
First up, you will need a wrapper to import the OpenGL API into C#. A bit of Googling led me to this:
CsGL - OpenGL .NET
There a few example programs available to demonstrate how the OpenGL interface works. Play around with them to get an idea of how the system works.
To implement the 3D map:
Create an array of vectors (that's not the std::vector/List type but x,y,z triplets) where x and y are along the horizontal plane and z is the up amount.
Set the Z compare to less-than-or-equal (so the overlaid line segments are visible).
Create a list of quads where the vertices of the quads are taken from the array in (1)
Calculate the colour of the quad. Use a dot-product of the quad's normal and a light source direction to get a value to shade value, i.e. normal.light of 1 is black and -1 is white.
Create a list of line segments, again from the array in (1).
Calculate the screen position of the various projected axes points.
Set up your camera and world->view transform (use the example programs to get an idea of how to do this).
Render the quads and lines, OpenGL will do the transformation from world co-ordinates (the list in (1)) to screen space. Draw the labels, you might not want to do this using OpenGL as the labels shouldn't scale with distance from camera, otherwise they could get too small to read.
Since the above is quite a lot of stuff, there isn't really the space (and time on my part) to post working code (but someone else might add something if you're lucky). You could break the task down and ask questions on the parts you don't quite understand.
Have you tried this... gigasoft data visualization tools (Its not free)
And you can checkout the online wireframe demo here