Page 1 of 1

Using static mesh as terrain

Posted: Sun Sep 18, 2016 4:38 pm
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.

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 6:17 pm
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.

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 7:45 pm
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.

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 8:04 pm
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.

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 8:46 pm
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)

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 9:01 pm
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.

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 9:30 pm
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?

Re: Using static mesh as terrain

Posted: Sun Sep 18, 2016 9:57 pm
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.

Re: Using static mesh as terrain

Posted: Mon Sep 19, 2016 5:25 am
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