Triangle mesh stability?
Posted: Tue Apr 05, 2011 4:03 am
First off, thanks for releasing your library for free. I looked into BulletX and JigLibX, but they rely on unsafe code, which causes compilation issues against Win Phone. Your library is compatible from the get-go, so Kudos!
I'm in the process of testing some scenarios out with this library. So far basic primitives (boxes and spheres) seem fine. When I add a compound body that consists of about 100 triangles (it's the shape of a bottle), the model either swims around when it collides with the ground (a flat box) or in some cases it falls through the ground entirely. When the model settles, it appears to be floating 45 degrees off the ground.
I just wanted to drop in and ask if triangular meshes are supported with stable results and I'm just not doing something right or if the functionality is beta. The following is a outline of how I setup the physics sim.
Thanks for any assistance on this matter.
I'm in the process of testing some scenarios out with this library. So far basic primitives (boxes and spheres) seem fine. When I add a compound body that consists of about 100 triangles (it's the shape of a bottle), the model either swims around when it collides with the ground (a flat box) or in some cases it falls through the ground entirely. When the model settles, it appears to be floating 45 degrees off the ground.
I just wanted to drop in and ask if triangular meshes are supported with stable results and I'm just not doing something right or if the functionality is beta. The following is a outline of how I setup the physics sim.
Code: Select all
// Populate physical world
mSpace = new Space();
// Static ground (length of 1 or higher produces the same results, but 0 is what I'm after (flat ground))
mSpace.Add(new Box(new Vector3(0, 0, 0), 20, 20, 0));
// Dynamic sphere (bounces and slides along the ground fine)
Sphere sphere = new Sphere(new Vector3(0, 0, 5), 0.5f, 1);
sphere.Material.Bounciness = 0.5f;
mSpace.Add(sphere);
// Construct triangle mesh
List<CompoundShapeEntry> list = new List<CompoundShapeEntry>();
for (int i = 0; i < numPoints; i += 3)
{
CompoundShapeEntry entry = new CompoundShapeEntry(new TriangleShape(new Vector3(x1, y1, z1),
new Vector3(x2, y2, z2),
new Vector3(x3, y3, z3)));
listAdd(entry);
}
// Finally create a dynamic body
CompoundBody body = new CompoundBody(list, 1);
body.Position = new Vector3(4, 0, 5);
body.Material.Bounciness = 0.1f;
mSpace.Add(body);
mSpace.ForceUpdater.Gravity = new Vector3(0, 0, -9.81f);
// Game loop starts here
// ... In the update game function. Manually setting the dt doesn't make any diff.
mSpace.Update();
// Loop through entities and update the model matrices
Model[i].WorldTransform = mSpace.Entities[i].WorldTransform;
Thanks for any assistance on this matter.