Jump to content

Terrain manipulation at run-time


Rick
 Share

Recommended Posts

First off is there a Terrain documentation page? Can't seem to find it.

 

Also, are we able to manipulate the terrain at run-time? I'm thinking of like an RTS when you place a building on the terrain and want to flatten the land under where the building will be placed. I want to be able to get the verts and change their height.

 

If possible at this time, does this screw up the terrain collision/navmesh at all? Would I have to recalc things? If so how and can I do it today?

Link to comment
Share on other sites

Reaction from Josh

In the future, a combination of static and dynamic data will be used, much like how the shadowmaps in Leadwerks 2 work, but for present we will rely on precalculated data generated in the editor or by a command.

 

Looks like the navmesh can be generated when you have altered the terrain at some point in your game. I have no idea terrain deformation is possible right now. at least not with the API.

Link to comment
Share on other sites

Programmatic terrain manipulation is not presently supported, officially. That said, there are lots of things you can find if you browse the header files.

 

There may even be a World::BuiltNavTile(x,z) function that may even work.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

You should be able to create a displacement map of the size of the flat area you need for a building. Then use the displacement map as a decal, then tesselate the terrain. Although nav mesh is now not dynamic. So they will not match. It would be a nice feature if we could update the nav mesh with a specified distance from a ray-cast.

Link to comment
Share on other sites

Tesselating a displacement map sounds complicated to me. :-/

 

I guess taking the x/z bounding box of the building and getting all verts inside this area and I was going to pick the average height value and make that the height value of all the verts. Was also going to do a check that if the lowest point and highest point are > a threshold then the land will be deemed to hilly to place a building on. Guess that just sounds easier to me.

Link to comment
Share on other sites

Tesselating a displacement map sounds complicated to me. :-/

 

I guess taking the x/z bounding box of the building and getting all verts inside this area and I was going to pick the average height value and make that the height value of all the verts. Was also going to do a check that if the lowest point and highest point are > a threshold then the land will be deemed to hilly to place a building on. Guess that just sounds easier to me.

 

Your terrain mesh would have to be extremly high in poly count or it is going to be blocky around where you flatten. So your game will not crawl at 3 fps you will need a normal terrain poly count and then somehow add vertice around where your buildings are. Oh yeah, I guess you could tesselate. Which will most likely be easier than your above method.

Link to comment
Share on other sites

@Tournamentdan I'll be using LE terrain so as far as I know we can't increase/decrease it's poly count. I think LE's terrain has or plans on having automatic tesselation. I remember Josh talking about that.

 

@beo6 Nice :)

 

Yes, you can not use tesselation untill josh implements the new renderer. But there is plenty to be done before then.

 

I do not know about automatic. Tesellation will be handled in a shader. You with code will have to specify level of tesselation and distance from camera.

 

The way I decribed will allow you to increase/decrease poly count in a specific local area instead of across the whole area.

 

If you plan to use the "automatic" tesellation with your method you will have to do all that picking and checking every frame or at least many times per second since every time the camera moves, more or less vertice will be created or deleted.

 

Good luck with your prodject.

Link to comment
Share on other sites

I'll play around with the undocumented way of changing verts to see how it works out. In my head at this time I just don't think it'll be a problem as the terrain is today as there seems to be plenty of verts to flatten out for the buildings I have in mind. Testing will tell me more if those undocumented commands even work. Thanks for the alternative idea.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...