Sun, Dec 22, 5:45 PM CST

Renderosity Forums / Poser - OFFICIAL



Welcome to the Poser - OFFICIAL Forum

Forum Coordinators: RedPhantom

Poser - OFFICIAL F.A.Q (Last Updated: 2024 Dec 20 7:20 am)



Subject: BulletPhysics internals


colorcurvature ( ) posted Sat, 13 September 2014 at 5:59 AM · edited Sun, 22 December 2024 at 5:43 PM

Hi, I am trying to make a bridge poser<->bulletphysics, mainly to make a posing assistant. I know that Poser already learned some physics tricks but I want to have something under my control ;) For the moment I am trying to translate a Poser figure to a set of chained rigidbodies, have them processed by bullet and translate this back into a pose of the figure. This is to enable gravity and having collisions with other body parts and props in the scene. I wonder if there is someone here who knows bullet internals a bit and might want to jump in.


colorcurvature ( ) posted Sat, 13 September 2014 at 6:12 AM

file_507214.jpg

fall on floor example


colorcurvature ( ) posted Sat, 13 September 2014 at 6:12 AM

file_507215.jpg

other


colorcurvature ( ) posted Sat, 13 September 2014 at 6:13 AM

file_507216.jpg

start position


colorcurvature ( ) posted Sat, 13 September 2014 at 6:14 AM

file_507217.jpg

pose computed by bullet


colorcurvature ( ) posted Sat, 13 September 2014 at 6:16 AM

the fingers do not really work yet, i think they do not have good collision shapes. i am using the convex hull for collision


colorcurvature ( ) posted Sat, 13 September 2014 at 6:22 AM

file_507218.jpg

this example also does not work so well, the collar rotations do not translate back  correctly, in bullet the arms are touching the ground. maybe someone can explain to me what i need to do


shvrdavid ( ) posted Sat, 13 September 2014 at 7:25 PM · edited Sat, 13 September 2014 at 7:25 PM

Do you have collision off between the hulls? Things like the fingers will have overlapping hulls and can wreck havoc in Bullet. You don't always want hull to hull collisions on.



Some things are easy to explain, other things are not........ <- Store ->   <-Freebies->


colorcurvature ( ) posted Sun, 14 September 2014 at 2:57 PM

I think adjacent actors do not collide, but the convex hull of the fingers seems to be too large. Its bigger than the finger segment, but I do not know how to get it smaller. I tried using the mesh itself as its own collision shape, but bullet does not seem to support mesh hulls for moving objects :/


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->


colorcurvature ( ) posted Thu, 18 September 2014 at 2:31 AM

No i'm using 6DOF for all the joints.

Translation from and to Poser somewhat works, its not 100% I feel, maybe the rotation order is wrong or something else. Moreover, I'm initializing the bullet doll based on the posed figure (world geometry with world orientation of joints) because I wasn't sure I'm able to use the base geometry as bullet does not support scaling and Poser's world API's all have scaling included in the transformations.

The convextrianglemeshshape, I wonder what happens if the mesh is not totally convex?

Compound Shape wise, I thought of segmenting a Poser actor along its bone axis into several smaller convex pieces, to have a bit more precision. But the clumsy finger problem is I think different.

I also do not know if bullet creates the smallest convex hull or if its just any hull that is convex.


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.