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
00028 #include "../SO3Animation/SO3NodeAnimation.h"
00029 #include "../SO3Animation/SO3NodeAnimationTrack.h"
00030 #include "../SO3SceneGraph/SO3NodeScol.h"
00031
00032 namespace SO3
00033 {
00034
00035 SNodeAnimationTrack::SNodeAnimationTrack(std::string animationTrackName, SNodeAnimation* animation, unsigned short nodeTrackAnimationId) : SAnimTrack(animationTrackName, animation, SAnimTrack::SO3_NODE_TRACK)
00036 {
00037 ogreAnimationTrack = GetParentAnimation()->GetOgreAnimationPointer()->createNodeTrack(nodeTrackAnimationId, animation->GetParentNode()->GetOgreSceneNodePointer());
00038 }
00039
00040 SNodeAnimationTrack::~SNodeAnimationTrack()
00041 {
00042 GetParentAnimation()->GetOgreAnimationPointer()->destroyNodeTrack(ogreAnimationTrack->getHandle());
00043 }
00044
00045 SNodeAnimationTrack::SNodeAnimationTrack() : SAnimTrack("", 0, SAnimTrack::SO3_NODE_TRACK)
00046 {
00047
00048 }
00049
00050 void SNodeAnimationTrack::CreateKey(float timepos, Ogre::Vector3 pos, Ogre::Quaternion quat, Ogre::Vector3 scale)
00051 {
00052 Ogre::NodeAnimationTrack* mTrack = static_cast <Ogre::NodeAnimationTrack*>(GetOgreAnimationTrackPointer());
00053 Ogre::TransformKeyFrame* key = mTrack->createNodeKeyFrame(timepos);
00054
00055 if (key)
00056 {
00057 key->setTranslate(pos);
00058 key->setRotation(quat);
00059 key->setScale(scale);
00060 }
00061 }
00062
00063 void SNodeAnimationTrack::SetKeyTransform(unsigned int keyIndex, Ogre::Vector3 pos, Ogre::Quaternion quat, Ogre::Vector3 scale)
00064 {
00065 Ogre::NodeAnimationTrack* mTrack = static_cast <Ogre::NodeAnimationTrack*> (GetOgreAnimationTrackPointer());
00066 Ogre::TransformKeyFrame* key = 0;
00067 if(((int)GetNumKeyFrames() - 1) >= (int)keyIndex)
00068 key = mTrack->getNodeKeyFrame(keyIndex);
00069
00070 if (key)
00071 {
00072 key->setTranslate(pos);
00073 key->setScale(scale);
00074 key->setRotation(quat);
00075 }
00076 }
00077
00078 void SNodeAnimationTrack::GetKeyTransform(unsigned int keyIndex, Ogre::Vector3 &pos, Ogre::Quaternion &quat, Ogre::Vector3 &scale)
00079 {
00080 pos = Ogre::Vector3::ZERO;
00081 quat = Ogre::Quaternion::IDENTITY;
00082 scale = Ogre::Vector3::ZERO;
00083
00084 Ogre::NodeAnimationTrack* mTrack = static_cast <Ogre::NodeAnimationTrack*> (GetOgreAnimationTrackPointer());
00085 Ogre::TransformKeyFrame* key = 0;
00086 if(((int)GetNumKeyFrames() - 1) >= (int)keyIndex)
00087 key = mTrack->getNodeKeyFrame(keyIndex);
00088
00089 if (key)
00090 {
00091 pos = key->getTranslate();
00092 quat = key->getRotation();
00093 scale = key->getScale();
00094 }
00095 }
00096
00097 void SNodeAnimationTrack::RemoveAllKeyFrames()
00098 {
00099 GetOgreAnimationTrackPointer()->removeAllKeyFrames();
00100 }
00101
00102 }