Using static mesh as terrain

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jaja1
Posts: 43
Joined: Sat Nov 15, 2014 3:27 am

Using static mesh as terrain

Post by jaja1 »

What is the procedure to use a static mesh to generate terrain in BEPUphysics? I want to have the option of concave features.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Using static mesh as terrain

Post by Norbo »

I think I might be missing a nuance of the question- there isn't much to using a StaticMesh other than tossing some vertices and indices into it and adding it to the space. Check out the StaticMeshDemo in the demos for an example.
jaja1
Posts: 43
Joined: Sat Nov 15, 2014 3:27 am

Re: Using static mesh as terrain

Post by jaja1 »

Thanks, the demo is very simple and makes sense to me. I thought the terrain class in BEPUPhysics was a more appropriate choice for the ground in my world because it may have special "properties" I am not aware of that affect performance and so on.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Using static mesh as terrain

Post by Norbo »

The Terrain can indeed be a bit faster than the StaticMesh when the mesh in question is just a heightmap. The regular grid structure provides an implicit acceleration structure for collision queries. The difference won't be that noticeable, though.

Many games use a compromise where the bulk of their environment is represented by a strict heightmap (like the Terrain), and then they place arbitrary meshes where the heightmap isn't sufficient. Often, for things like caves, they'll poke holes in the heightmap so you can go underground.
jaja1
Posts: 43
Joined: Sat Nov 15, 2014 3:27 am

Re: Using static mesh as terrain

Post by jaja1 »

That makes sense. I was originally planning on using heightmaps but it presented an addition level of complexity that could have just been bypassed by using the static meshes. I will take note though.

Also, are there any demos on generating the collider from the static mesh? (forgot to mention...I am not using BEPU or XNA to draw. BEPU is just being used as a physics engine)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Using static mesh as terrain

Post by Norbo »

Also, are there any demos on generating the collider from the static mesh?
If you mean generating a BEPUphysics StaticMesh from different kinds of imported meshes, no- only the basic XNA vertex/index extraction in the demos. The details of extracting the necessary positions/indices varies depending on the specifics of the involved content pipeline. In the end, any method of getting a bunch of positions and indices will work.

Sidenote: be careful about generating physical meshes from graphical meshes. Graphical meshes are often many times more detailed than the physics mesh should be. Many games use physics-specific meshes to improve performance and behavior.
jaja1
Posts: 43
Joined: Sat Nov 15, 2014 3:27 am

Re: Using static mesh as terrain

Post by jaja1 »

Extracting the vertices from the graphical mesh is not an issue. But I need to create a physics mesh for my "ground" so my entities won't fall. Does BEPUphysics have a method for generating physics meshes from the graphical mesh? If not are there any alternatives?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Using static mesh as terrain

Post by Norbo »

If you mean something like an automated mesh simplification process, then no, the engine doesn't have anything like that. That sort of thing is usually offered by the content creation program, like Blender, Maya, 3ds Max, etc. Often the results of such automated tools will need some tweaking for gameplay purposes, though.
jaja1
Posts: 43
Joined: Sat Nov 15, 2014 3:27 am

Re: Using static mesh as terrain

Post by jaja1 »

Thanks again for the replies Norbo. I ended up going with the heightmap instead :oops:
I will have to use the "poke holes" method to get caves and such into my map.
XNA has a really nice Terrain demo that helped me out alot. The calculations are very simple and you don't need to use the XNA content pipeline to get your pixel data.
Here it is if anyone is interested: http://xbox.create.msdn.com/en-US/educa ... _heightmap
Post Reply