sajan
31-12-2007 15:06:17
I'am trying to implement a breakable glass in my Ogre app. As my experience with 3D programming and with Ogre is limited, I need your help.
I tried to apply Ragdoll class from demo_08 but Ragdoll bones don't behave as I expected. I have a mesh with an armature (4 bones) and simple xml with bones definition (without joints).
Rigid bodies seem to be created correctly and they are not connected, but the problem is that the entity does not fall apart. Orientation is updated correctly but not the position of the pieces. I checked the code and tried to update _placementCallback which is used in setCustomTransformCallback but I didn't manage to achieve what I need.
I tried to put bone->getOgreBone()->setPosition( pos ) after setOrientation but it didn't work. The bones' position was updated incorrectly.
Could you please suggest what should be added to that callback?
If you don't think that this is the correct approach to the problem, could you please suggest some other way of implementing a "breakable glass"?
BTW
Although I have just started with OgreNewt, I found it very useful and I think that this is a really good piece of software - THANKS WALABER
I tried to apply Ragdoll class from demo_08 but Ragdoll bones don't behave as I expected. I have a mesh with an armature (4 bones) and simple xml with bones definition (without joints).
Rigid bodies seem to be created correctly and they are not connected, but the problem is that the entity does not fall apart. Orientation is updated correctly but not the position of the pieces. I checked the code and tried to update _placementCallback which is used in setCustomTransformCallback but I didn't manage to achieve what I need.
void RagDoll::_placementCallback( OgreNewt::Body* me, const Ogre::Quaternion& orient, const Ogre::Vector3& pos )
{
RagDoll::RagBone* bone = RagDoll::RagBone*)me->getUserData();
RagDoll* doll = bone->getDoll();
// is this the root bone?
if (!bone->getParent())
{
Ogre::Quaternion finalorient = (orient * bone->getOffsetOrient());
Ogre::Vector3 finalpos = pos + (orient * bone->getOffsetPos());
doll->mNode->setPosition( finalpos );
doll->mNode->setOrientation( finalorient );
}
else
{
// standard bone, calculate the local orientation between it and it's parent.
Ogre::Quaternion parentorient;
Ogre::Vector3 parentpos;
bone->getParent()->getBody()->getPositionOrientation( parentpos, parentorient );
Ogre::Quaternion localorient = parentorient.Inverse() * orient;
bone->getOgreBone()->setOrientation( localorient );
}
}
I tried to put bone->getOgreBone()->setPosition( pos ) after setOrientation but it didn't work. The bones' position was updated incorrectly.
Could you please suggest what should be added to that callback?
If you don't think that this is the correct approach to the problem, could you please suggest some other way of implementing a "breakable glass"?
BTW
Although I have just started with OgreNewt, I found it very useful and I think that this is a really good piece of software - THANKS WALABER