Set center of mass for individual bones

I need some help. I’m not even sure if I can make this work correctly but I was looking for some suggestions. What I’m trying to do is dismember a model and have it basically turn into a bunch of dynamic physics object. The model seems to break apart correctly but the point at which each part pivots/rotates is off. Is there a way to set the center of mass of each bone? Or is there a way to copy each bonerigidbody and create a regular physics rigid body from it? I don’t know jme well enough to come up with any other ideas, but any suggestions are welcome.



Right now I use a kinematicragdollcontrol to dismember the character. I do this for each bone but actually remove the root bone completely from the model so that it does not pull it through the map.

[java]

PhysicsRigidBody prb = ragdoll.getBoneRigidBody(“Head”);

for(Object obj : prb.getJoints().toArray()){

if(obj instanceof PhysicsJoint){

prb.removeJoint((PhysicsJoint)obj);

bullet.getPhysicsSpace().remove(obj);



}

}

[/java]

Just incase I didn’t make it clear what the problem was, I created a short video for example.



Thanks!

The center of the object is always its center of mass, move the collision shape and geometry accordingly to move the center of mass relatively.

I’m drawing a blank on how I could do that. Can you give me a little more of how to go about this?



Thanks.

Bascially like this: https://code.google.com/p/jbullet-jme/wiki/CenterOfMass

Awesome, I got the physics part working by adding:

[java]

CompoundCollisionShape compoundCollisionShape=new CompoundCollisionShape();

HullCollisionShape HullCollisionShape = (HullCollisionShape)ragdoll.getBoneRigidBody(“Head”).getCollisionShape();

compoundCollisionShape.addChildShape(HullCollisionShape, new Vector3f(0,-1,0));

prb.setCollisionShape(compoundCollisionShape);

[/java]



I know i’m pretty much having you spoon feed this to me, but how can I grab that portion of the mesh from the ragdoll to move it accordingly?



Thanks again.

You have to change the ragdoll for this so it creates the center of the physics objects elsewhere.

The ragdoll class or the model i’m using?

the class

Darn, this sounds like its a little more work than I thought it would be.

I ended up just using the ragdoll to figure out the position of each limb then copying it to a rigid body. I didn’t get to keep the texture of each limb but instead just painted it red which still seems fun enough.

Thanks for all you help normen, much appreciated!