Jump to content
  • Advertisement
Sign in to follow this  
celestis_genesis

3D Map Editor

This topic is 4511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all! Well, I've been busy with my stdies for a long time, but not its fintally time to take a break - and for me that means returning to my adventures through the world of D3D. I've decided to remake a game called NoX fully in 3D. Im sure some of you played it. Wikipedia it - theres some usefull info and a website of the leftovers of the NOXers. OK, most of this may seem like a request for somebody to code this for me -- its not. It really isnt, I just couldnt find the words to explain myself clearly. Now, back to topic. I want to remake that game. I'm doing OK with my D3D (D3D 9 that is) coding. But now I've run into a problem - every game needs maps. And adventure games definitely need a map maker. I have the original game, but I am going to remake it completly - and that means a new map format too. So, I need to make my own maps. Now, I realize this next quesion sounds stupid and not detailed, but IMO this would be the best way for me to learn the things needed - and for you to get some good rating :p hehe. So I guess my question would be this: could you guys share some techniques for editing terrain? What I basically want to learn is this: say, I have a bunch of vertices (lets say I loaded them from a heightmap). Now I want to be able to select some of them(any way to select them, Ill improve it myself later on). then, lets say I want to increase the height of all of them - make a hill of a sort. Whatever - just operate on that group of vertices. I suppose what I need is selection. Then, another thing I could not find how to do is how to...err, "extend" the terrain. Basically, you know how you have your vertex buffer and index buffer(usually) when you load a terrain from a heightmap? well, lets say I want it to not be a square, with equally spaced "square-like" vertices. I want to be able to insert a vertex - sure thats not a problem, but how would I link the terrain around it so it takes it into account. For instance, I have 4 vertices. I Click on one of them and it creates a new one there and allows me to grad it somewhere, thus changing the shape of the terrain. I realize that I wont be efficiently store the result as a BMP heightmap, but thats not a problem, I'll make my own format for the maps. Not sure if that made sense, but thanks in advance for any pointers you can throw at me(please make the VALID pointers, not non-initialized or pointing to NULL :D lol). If you know any tutorials, please post them - I'll be really gratefull. Thanks, Anton A.

Share this post


Link to post
Share on other sites
Advertisement
I've been messing around with this type of thing myself lately and here are my ideas. First of all is the displacement brush. This is simply a greyscale map which you can move and apply over the terrain with your mouse just like a paintbrush. With each sample any terrain verts which fall inside the brush map have their heights displaced up or down (depending on which mouse button is held) by an amount determined by the value of the pixel which the vert intersects multiplied by some global scalar. The user should be allowed to modify this scalar and brush size, as well as create their own custom displacement brush maps so that they can use this to quickly sculpt the terrain any way they see fit.

Secondly the user should be allowed control over each individual vertex by being able to select verticies and drag them up or down so that they can add fine detail. This can even be used as a method for quickly creating smooth hills if you add in an area of effect scale that the user can control. For example if the area of effect is 2 verticies then when the selected vertex is displaced by 'x' amount then any verts 1 away might be displaced by 'x/2' and any verts 2 away by 'x/4'. You could add in different drop-off curves the user can select from for the area effect to give more control.

Lastly the user should be allowed to control groups of verts. This will work like control over single verts above except that all verts in the selected groups will maintain their relative displacements from each other. This will allow the user to alter the relative heights of terrain features they've created without having to destroy those features in the process.

I've not gotten very far with my project yet, in fact I havn't even gotten to the terrain sculptor tool yet, but as far as I can imagine the above features should be sufficient as a start. Hope this helps.

Edit: Its just occured to be that it will also be helpfull to allow the user to lock verticies so that they're not effected by brushes or area effects. This will stop you from destroying features when sculpting others close by.

Edit 2: Just realised that your post was more asking how you go about implementing this stuff rather than what to implement. All you really need is mouse control and 'picking'. There's excellent guides with samples to both of these subjects in the DirectX SDK documentation. I recommend for the time being you keep your verts stored in a regular grid to keep things simple. Maybe after that you can think about allowing vert additions but just be aware that you'll then also have to handle some kind of connectivity data between verts.

[Edited by - Motorherp on July 6, 2006 7:54:07 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I've only just skimmed your post, but if what your asking for is ideas on editing heightmaps...

Well, you can simulate a 2d 'brush' and paint the heights in 3d. That is, the user sets a brush radius, hardness, power, etc, etc, and holding the mouse down on the terrain raises or lowers the vertices within the radius. This will allow the user to quickly create hills, craters, rivers, etc. I implemented this within minutes in my terrain engine, very simple.
Editing vertices one by one would be painfully slow and look horribly jagged.

Share this post


Link to post
Share on other sites
@Motorherp,

Well, thanks for the ideas! I originally didnt even think of making it as easy as just having that brush change the heightmap. That should be easier now.

I'll definitely read the SDK docs. I just didnt think they'd have that, well, esince there arent samples with such things in the DX distribution(OK, maybe there are, I havent looked in the past 3 distribs).

And as for adding verts - thats my main problem I suppose. Ive been pondering on it quite a while now, and havent really come up with an efficient method of connecting things. If someone else has done this or has ideas, please share.
-----

@Anonymous Poster,

I asked more than just editing heightmaps, but your post made me realize something...say, if I have a brush, and the user drags it to create a river-looking-thing, how would I keep it from deepening the places where it already made the verts lower? add a variable to the vertex structure(just for the editor) that is basically T/F that says "Has this vvertex been edited with the last MouseDown?". I guess that could work, but maybe(most likely) you've done it differently, so could you elaborate more on that?
-----

Rant:
Yeah, I really need to brush up on my D3D. Everything else I do I tend to remember, and D3D jsut has so much stuff that I find myself referring to tutorials/notes almost all the time :| Wish I'd written a library with all the basic functions just to keep myself one with the knowledge. Oh well, I'll remember it eventualy.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by celestis_genesis


I asked more than just editing heightmaps, but your post made me realize something...say, if I have a brush, and the user drags it to create a river-looking-thing, how would I keep it from deepening the places where it already made the verts lower? add a variable to the vertex structure(just for the editor) that is basically T/F that says "Has this vvertex been edited with the last MouseDown?". I guess that could work, but maybe(most likely) you've done it differently, so could you elaborate more on that?
-----





A river cutting tool would be a depressing pattern shaped like a cone but it wouldnt be additive/subtractive, but would cut its pattern -- setting the heighmap points to the appropriate depth (water surface down to the river bottom depth). Its a cone so you can drag it in any direction.

You would also probably have something outside the water level cone to force the adjacent terrain into a profile sloping town to the waters edge (water level).
This above water extension of the pattern could also be a cone -- excpt maybe with a different slope than the underwater pattern.

You could have either several river 'brushes' of different contours/sloped OR a couple of slider controls to adjust the river pattern contour.

Share this post


Link to post
Share on other sites
Sorry, that first AP was me.

Umm, I don't understand exactly what you just asked, but...

Normally, the user would use a _very_ low 'Power' setting (ie, the amount to raise/lower the verts), and would use the mouse to brush back and forth over the terrain to increase/decrease the hills, craters, slowly.

Think of it as the 'Opacity' setting on the paint brush in Photoshop. You'd set it to about 20%, and if you want darker areas, you just brush over areas already painted.

So to make a quick-n-dirty river, the user would use a low power setting, and simply drag the mouse in the shape they want their river. (Like painting a line in Photoshop)
(It doesn't matter if the verts of the river base, for example, aren't all lowered to the exact same point, because ofcourse, terrain is never flat)

---

There are some pretty cool river generating algorythms out there to automatically create rivers, (Taking the terrain slope, lakes, waterfalls, blah blah, into account), but for the moment, completely forget about all that :P

Share this post


Link to post
Share on other sites
OK, more or less makes sense to me.

Now, I suppose I should read up on picking(as in, raypicking or whatever its called) tutorials. Then, when I pick a brush in the editor, I guess that when the mouse is moved, it would calculate the new positions of the vertices under the affected area and display them(as a preview kinda thing). Then when I click it, it would set the values. Makes sense to me, any other suggestions/ideas?

Also, back to the adding/removing vertices question. I drew a few pictures on paper, kinds figured it out. But adding vertices one by one is a tedious and boring task, plusit isnt always worth it. So I was thiking of the concept of brushes, but in a more advanced way - when, say, I'm moving my brush to make a river, it deepens the terrain. OK, but what if its a kilometer(exaggeration, but still) deep river? Then the textures would be veeeryy stretched and reaaly bad looking. SO I was thinking of making the program automatically add vertices when changing the terrain with brushes - but of course it shouldnt add to many of them - i dont want a 9999999999-poly model of a 1 by 1 meter patch of terrain :p. I guess my question is, how could I automate the detalization of terrain when changing it with brushes.

Thanks again.

Share this post


Link to post
Share on other sites
Quote:
Original post by celestis_genesis
Also, back to the adding/removing vertices question. I drew a few pictures on paper, kinds figured it out. But adding vertices one by one is a tedious and boring task, plusit isnt always worth it. So I was thiking of the concept of brushes, but in a more advanced way - when, say, I'm moving my brush to make a river, it deepens the terrain. OK, but what if its a kilometer(exaggeration, but still) deep river? Then the textures would be veeeryy stretched and reaaly bad looking. SO I was thinking of making the program automatically add vertices when changing the terrain with brushes - but of course it shouldnt add to many of them - i dont want a 9999999999-poly model of a 1 by 1 meter patch of terrain :p. I guess my question is, how could I automate the detalization of terrain when changing it with brushes.

Thanks again.


Unless this level of detail is very important for you then I really do recommend sticking to a regular grid of verticies. This has many advantages including being simpler to handle, better to optimise for faster rendering, compatibility with CLOD algorithms, and self-transitioning texture splatting becomes easy. Unfortunately these height-map methods do suffer from low surface detail and texture stretching on steep surfaces which you describe, but unless you're modelling canyons and such then this is a fair trade-off for all the benefits you get. You could maybe lessen the problem by repeating your textures many times over the steep surface and use bump-mapping to give the impression of detail but I imagine this will only take you so far. If you want to have high detailed sheer surfaces with depressions and caves etc then a height map method isn't going to cut it no matter how many verts you add. You could maybe stitch together height-mapped regions with high detail meshes to get this effect but I dont have any experience with this unfortunately.

Share this post


Link to post
Share on other sites
Have you considered exploiting already existant editors? What did you miss from them?

I don't know how you're going to manage it but I would keep an eye from artist's perspective.
The terrain will be worked as an heightmap in the end (I'm sure you'll do this, it's just the standard - if you don't I hope you're sure about your idea). I believe having the terrain (3d) near a 2D representation may be a good idea - this allows the artist to have a look at the 3d as well at the original asset.
Added positions would be rendered normally in 3d and as as "special points" in 2d (say, the heightmap is broken and new points are drawn). Anyway, I believe you'll live much better without TINs: are you sure you really need this feature in the first place?

Share this post


Link to post
Share on other sites
Now your getting a little more advanced, and a bit too far ahead of yourself :P

There are a ton of algorythms that handle 'Level Of Detail' for terrain. They can add verts to steep cliffs and smooth out jagged parts, and/or remove verts on flat or far away areas. Some are more for creating better looking terrain, or more realistic terrain, or even just for plain speed of rendering. This is an entire topic alltogether, and tons of info and threads on the net already.


As for simply adding more verts, ie, to increase the width of the terrain later on... Simply forget about it :D. Too much hassle, and you really don't need it. Just about every Level Editor I've used, doesn't allow you change the resolution of the terrain after creation, and also most create terrains at ^2 width-height (256, 512, 1024, etc).

What is the primary role of your terrain, if I may ask? Will you ever actually see the ends of the terrain? that is, do you really ever need non square terrain? In most games, they block off the terrain ends, eg: too high cliffs, walls, water(islands), invisible barriers.....

For now, you might wanna just leave it simple, ^2 square terrain, single texture, no lighting, etc. Just get the editor up and running. You can always expand it later :P.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!