Kinematic Bodies

narwhals

23-02-2011 03:56:28

Looked around as much as I could, I couldn't find an explanation on how to do this.
I have a mesh that is animated using bones. Right now it just has 1 bone and the animation makes the bone rotate.
Now, when playing the animation in OGRE, the animation plays just as expected, but, as shown by the debug drawer and how it interacts with other objects, the animation does not update the position / orientation of the physics body.
I can tell, since the movement is handled by bullet, that I somehow need to also tell bullet how the animation is progressing in order for it to move the body - but how?
tl;dr: How do I make OGRE animations affect bullet bodies?

stuff so far:

OgreBulletCollisions::AnimatedMeshToShapeConverter conv(m_entity);
m_shape = (OgreBulletCollisions::CollisionShape*)conv.createConvex();

m_body->setStaticShape(m_sceneNode, m_shape, m_restitution, m_friction, m_position, m_orientation);

m_body->setKinematicObject(true);

m_entity->getAnimationState("Wobble")->setEnabled(true);

//--and later on, in an update loop:
m_entity->getAnimationState("Wobble")->addTime(tDiff);


Y U NO MOVE?

Fish

24-02-2011 13:22:21

See if this helps: viewtopic.php?f=12&t=13791

- Fish

narwhals

24-02-2011 22:28:52

Yes, I saw that, but now what I'm unsure about is how to get the transform of the bone while it's being animated.
Right now I do it after I add time to the object's animation, but I don't know how to get the new position / orientation of the bone. I try using getSkeleton()->getBone(0)->getPosition() and the same for orientation but the value never changes.

EDIT: nevermind, the orientation of the bone is changing, but when I pass it to setWorldTransform, nothing happens.

EDIT: okay, i guess I just had to set the position of the scenenode (since its a kinematic object) instead of the body. Now it animates and the physics body moves, but it screws up the animation because the whole object is being moved

jonathanblacknight

04-03-2011 13:36:06

You need to use _getDerivedPosition() and _getDerivedOrientation() to get the position and orientation relative to the world.

Try to post an image to help to solve your problem