00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #include "../SO3Animation/SO3PoseAnimation.h"
00036 #include "../SO3Animation/SO3PoseAnimationTrack.h"
00037 #include "../SO3SceneGraph/SO3Entity.h"
00038
00039 namespace SO3
00040 {
00041
00042 SPoseAnimation::SPoseAnimation(SScene* scene, std::string animationName, SEntity* entity, unsigned short id, unsigned short poseHandle) : SAnim(scene, animationName, entity, id, SAnim::SO3_POSE_ANIM)
00043 {
00044 mOgreEntity = entity->getOgreEntityPointer();
00045 ogreAnimation = mOgreEntity->getMesh()->getAnimation(id);
00046 ogrePoseHandle = poseHandle;
00047 poseWeight = 0.0f;
00048
00049
00050 Ogre::VertexAnimationTrack* ogreVertexTrack = ogreAnimation->getVertexTrackIterator().getNext();
00051 std::string animationTrackName = animationName+".poseTrack_"+boost::lexical_cast<std::string>(ogreVertexTrack->getHandle());
00052 SAnimTrack* animationTrack = new SPoseAnimationTrack(animationTrackName, this, ogreVertexTrack->getHandle());
00053 AddAnimationTrack(animationTrack);
00054
00055
00056 ogreKeyFrame = ogreVertexTrack->getVertexPoseKeyFrame(0);
00057 }
00058
00059 SPoseAnimation::SPoseAnimation() : SAnim(0, "", 0, 0, SO3_UNKNOWN_ANIM)
00060 {
00061
00062 }
00063
00064 SPoseAnimation::~SPoseAnimation()
00065 {
00066 }
00067
00068 Ogre::AnimationState* SPoseAnimation::_GetOgreAnimationState()
00069 {
00070 return mOgreEntity->getAnimationState(name);
00071 }
00072
00073 void SPoseAnimation::SetWeight(float weight)
00074 {
00075 ogreKeyFrame->updatePoseReference(ogrePoseHandle, weight);
00076 poseWeight = weight;
00077 _GetOgreAnimationState()->getParent()->_notifyDirty();
00078 }
00079
00080 float SPoseAnimation::GetWeight()
00081 {
00082 return poseWeight;
00083 }
00084
00085 }