get a bone from a Ragdoll

epha

10-06-2008 01:56:35

Hi,

Can someone tell me how to get a specific bone from a ragdoll ?
I am using Walaber's ragdoll class with this in it:

// list of bones.

typedef std::list<RagBone*> RagBoneList;

typedef std::list<RagBone*>::iterator RagBoneListIterator;



RagBoneList mBones;


I have been trying but I am unfamiliar with std::list and fairly new to c++ .


Thanks!

epha

10-06-2008 18:04:02

hi,
I have worked it out- so if anyone else is interested:
I added a function declaration to Ragdoll.h
OgreNewt::Body* getBone(Ogre::String boneName);

and an instance of RagBoneListIterator:
RagBoneListIterator mBonesListIterator;
and this is the function in Ragdoll.cpp that returns a pointer to an OgreNewt::Body:
OgreNewt::Body* RagDoll::getBone(Ogre::String boneName)
{
for (mBonesListIterator = mBones.begin(); mBonesListIterator != mBones.end(); ++mBonesListIterator)
{
RagBone * rb = *mBonesListIterator;
Ogre::String os = rb->getOgreBone()->getName();
if(boneName == os) return rb->getBody();
}

}


this might not be the best or most elegant way( I am learning C++) but it seems to work.