colorcurvature opened this issue on Sep 13, 2014 · 11 posts
shvrdavid posted Sun, 14 September 2014 at 6:41 PM
You can uses BoxShape() for the fingers instead of ConvexHullShape(), but the offset need to be corrected for when doing so. Hulls are created around the center, boxes start at a corner.
ConvexHullShape expects the center of mass (COM) to be (0,0,0), but the cube is offset from the center, making it tilt towards the corner.
You can find the correct COM like this.
const int indexStride = 3 * sizeof(int);
const int vertexStride = 12;
int vertexCount = points.Count;
int indexCount = vertexCount / 3;
TriangleIndexVertexArray vertexArray = new TriangleIndexVertexArray();
IndexedMesh mesh = new IndexedMesh();
mesh.Allocate(vertexCount, vertexStride, indexCount, indexStride);
Vector3Array vdata = mesh.Vertices;
IntArray idata = mesh.TriangleIndices;
for (int i = 0; i < vertexCount; i++)
{
vdata[i] = points[i];
idata[i] = i;
}
vertexArray.AddIndexedMesh(mesh);
ConvexTriangleMeshShape shape = new ConvexTriangleMeshShape(vertexArray, true);
Matrix center = Matrix.Identity;
Vector3 inertia;
float volume;
shape.CalculatePrincipalAxisTransform(ref center, out inertia, out volume);
CompoundShape compound = new CompoundShape();
compound.AddChildShape(Matrix.Invert(center), shape);
As far as the shoudlers go in your ragdoll, are you using cone twist constraints for the upper arm? There are tricks to those, but it is version dependant due to bugs in various builds.
Just so we are on the same page, what version of Bullet are you using?
Some things are easy to explain, other things are not........ <- Store -> <-Freebies->