17SSkeleton::SSkeleton(
SScene* parent,
const std::string& skeletonName,
SEntity* parentEntity) :
SNode(parent, skeletonName,
SNode::SKELETON_TYPE_ID)
19 assert(parentEntity != 0);
29SSkeleton::SSkeleton() :
SNode(0,
"",
SNode::SKELETON_TYPE_ID)
37 Ogre::SkeletonInstance* O3SkeletonInstance =
ogreLinkedEntity->getSkeleton();
38 if (!O3SkeletonInstance)
41 unsigned short numBones = O3SkeletonInstance->getNumBones();
42 for (
unsigned short i=0; i<numBones; i++)
44 Ogre::Bone* ogreBone = O3SkeletonInstance->getBone(i);
53 for (
unsigned short i=0; i<numBones; i++)
56 Ogre::Bone* ogreBone = O3SkeletonInstance->getBone(i);
58 Ogre::Bone* parentBone =
static_cast<Ogre::Bone*
> (ogreBone->getParent());
69 unsigned short numAnimations = O3SkeletonInstance->getNumAnimations();
70 for (
unsigned short i=0; i<numAnimations; i++)
72 Ogre::Animation* ogreAnimation = O3SkeletonInstance->getAnimation(i);
122 ogreLinkedEntity->setUpdateBoundingBoxFromSkeleton((O3SkeletonInstance->getNumBones() > 1) ?
true :
false);
135 SBoneMap::const_iterator iBone = boneListCopy.begin();
136 while(iBone != boneListCopy.end())
150 Ogre::SkeletonInstance* O3SkeletonInstance =
ogreLinkedEntity->getSkeleton();
151 O3SkeletonInstance->setBindingPose();
156 Ogre::SkeletonInstance* O3SkeletonInstance =
ogreLinkedEntity->getSkeleton();
162 Ogre::SkeletonInstance* O3SkeletonInstance =
ogreLinkedEntity->getSkeleton();
163 O3SkeletonInstance->setBlendMode(
static_cast <Ogre::SkeletonAnimationBlendMode
> (
static_cast <int> (newBlendMode)));
168 string boneName = existingBone->
GetName();
169 SBoneMap::iterator iBoneSearched =
boneList.find(boneName);
170 if (iBoneSearched ==
boneList.end())
172 boneList.insert(SBoneMap::value_type(boneName, existingBone));
178 OGRE_EXCEPT(Ogre::Exception::ERR_DUPLICATE_ITEM,
"Can not add bone named \""+ boneName +
"\", an element with the same name already exist!",
"SSkeleton::AddBone");
189 SBoneMap::iterator iBoneSearched =
boneList.find(boneName);
190 if (iBoneSearched !=
boneList.end())
192 SBone* findedBone = iBoneSearched->second;
203 SBoneMap::iterator iBoneRootSearched =
rootBonesList.find(boneName);
210 OGRE_EXCEPT(Ogre::Exception::ERR_ITEM_NOT_FOUND,
"Can not remove Bone named \""+ boneName +
"\", element not found!",
"SSkeleton::RemoveBone");
216 assert(boneInstance != 0);
231 SBoneMap::iterator iBoneSearched =
boneList.find(boneName);
232 if (iBoneSearched !=
boneList.end())
233 return iBoneSearched->second;
240 SBoneIndexMap::iterator iBoneSearched =
boneListByIndex.find(boneIndex);
242 return iBoneSearched->second;
269 return Ogre::Vector3::ZERO;
274 return Ogre::Quaternion::IDENTITY;
279 return Ogre::Vector3::UNIT_SCALE;
unsigned short GetIndex()
std::string GetName() const
void _SetSkeleton(SSkeleton *newSkeleton)
Ogre::Entity * getOgreEntityPointer()
void AddAnimation(SAnim *existingAnimation)
SScene * GetParentScene()
void AttachToParent(SNode *newParentNode)
SBone * CreateBone(const std::string &newBoneName, SSkeleton *skeleton, const unsigned short &id)
void RemoveBone(SBone *existingBone)
Ogre::SkeletonInstance * GetOgreSkeletonPointer()
SkeletonAnimationMode GetBlendMode()
void AddBone(SBone *existingBone)
SBoneMap GetBones() const
virtual void SetGlobalPosition(const Ogre::Vector3 &pos, bool updateBody=true)
Ogre::Entity * ogreLinkedEntity
SEntity * GetParentEntity()
SBone * GetBone(const std::string &boneName)
SBoneIndexMap boneListByIndex
virtual Ogre::Quaternion GetGlobalOrientation()
virtual void SetGlobalOrientation(const Ogre::Quaternion &quat, bool updateBody=true)
void SetBlendMode(const SkeletonAnimationMode &newBlendMode)
void _OnBoneDeletion(SBone *boneInstance)
virtual Ogre::Vector3 GetGlobalPosition()
virtual Ogre::Vector3 GetGlobalScale()
unsigned short GetNumBones()
std::unordered_map< std::string, SBone * > SBoneMap