Use BEPU Physics with any object
Use BEPU Physics with any object
Hello! I have a class that generates an infinite plane, and I would like to use it as terrain. Is there a way to use it with BEPUPhysics.Space? Thanks!
Re: Use BEPU Physics with any object
There is no infinite plane included in BEPUphysics (though it wouldn't be too hard to create one), but you can get something fairly similar with a single immense triangle. The triangle face collision is very robust at extreme sizes. Just be careful to make it big enough so that none of the triangle's edges can be hit during normal simulation. This is for two reasons- first, you don't want stuff falling off the map, and second, the triangle edge collision detection is not as robust as the simplistic face collision detection.
I would also be careful to ensure that the plane is axis aligned to avoid giving the plane an essentially infinite bounding box and requiring tests against every object in the Space.
I would also be careful to ensure that the plane is axis aligned to avoid giving the plane an essentially infinite bounding box and requiring tests against every object in the Space.
Re: Use BEPU Physics with any object
You could also take advantage of the Terrain class's built in support for solid depths. This could come in handy if objects ever get through the surface. You could create the 1x1 terrain such that only one of the triangles would encompass the entire simulation area.
Re: Use BEPU Physics with any object
I'm kind of new. Is there an example showing how to do that?
Re: Use BEPU Physics with any object
Here's how to create a giant triangle:
Here's how to make a massive 1x1 terrain with thickness:
The BEPUphysicsDemos in the main source download show a ton of other examples too. The TerrainDemo shows how to create a Terrain. For general entity creation, the EntityConstructionDemo is a good thing to look at.
Code: Select all
Vector3 a = new Vector3(-100000, 0, -100000);
Vector3 b = new Vector3(-100000, 0, 100000);
Vector3 c = new Vector3(100000, 0, 100000);
Triangle triangle = new Triangle(a, b, c);
triangle.Position -= (a + b + c) / 3;
Space.Add(triangle);
Code: Select all
Terrain terrain = new Terrain(new TerrainShape(new[,] { { 0f, 0f }, { 0f, 0f } }), new AffineTransform(new Vector3(100000, 1, 100000), Quaternion.Identity, new Vector3(-33333, 0, -33333)));
terrain.Thickness = 10;
Space.Add(terrain);