Thanks for the code update! I tried it out, and it didn't help. I think I may know why.
I've been working on it a bit more, and have noticed a few things:
1) When you call mSoftBody->getWorldTransform(), it always returns an identity transformation -- position at the origin, no rotation. That's because the whole notion of world transforms doesn't apply to soft bodies; there's no such thing as global transformation. Instead, the position and orientation of the individual triangles are all represented explicitly.
That means that this code:
Code:
btTransform transform = mSoftBody->getWorldTransform();
btQuaternion rot = transform.getRotation();
ogreNode->setOrientation(rot.w(), rot.x(), rot.y(), rot.z());
btVector3 pos = transform.getOrigin();
ogreNode->setPosition(pos.x() + btPosOffset.x(), pos.y() + btPosOffset.y(), pos.z() + btPosOffset.z());
is equivalent to this:
Code:
ogreNode->setPosition(btPosOffset.x(), btPosOffset.y(), btPosOffset.z());
(ie, there's no useful information coming out of getWorldTransform())
2) You're using the zero vertex as a reference point for the node, and updating the node position based on that. I hadn't thought about this general approach, and it seems useful: update the node statistics based on aggregate statistics computed over all of the individual triangles in the soft mesh. A more general version of using the zero vertex would be to compute the mean of all of the triangles in the mesh.
However, this doesn't solve my problem, which is rotation. Somehow, we'd need to compute an aggregate node rotation as a function of all of the positions/orientations of the individual nodes, relative to their original positions. Blech.
An alternative is still to try and inform Ogre that the underlying mesh has changed, and that it needs to update its internal statistics. That might be easier.
Thanks for your help. I'll keep working on it.
-- David
P.S. I see in the bullet code some global transform stuff for collision clusters. Maybe it would be useful here (my rough idea was to wrap each softbody in a collision cluster, so we could reference its transform)...