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
00034 #include "SO3AnimTrack.h"
00035 #include "SO3Anim.h"
00036 #include "../SO3SceneGraph/SO3NodeScol.h"
00037
00038 namespace SO3
00039 {
00040
00041 SAnimTrack::SAnimTrack(std::string animationTrackName, SAnim* animation, AnimTrackType animationTrackType) : SData(animationTrackName)
00042 {
00043 type = animationTrackType;
00044 parentAnimation = animation;
00045
00046
00047 ogreAnimationTrack = 0;
00048 }
00049
00050 SAnimTrack::SAnimTrack() : SData(""), parentAnimation(0)
00051 {
00052
00053 }
00054
00055 SAnimTrack::~SAnimTrack()
00056 {
00057 parentAnimation = 0;
00058 ogreAnimationTrack = 0;
00059 }
00060
00061 Ogre::AnimationTrack* SAnimTrack::GetOgreAnimationTrackPointer()
00062 {
00063 return ogreAnimationTrack;
00064 }
00065
00066 SAnimTrack::AnimTrackType SAnimTrack::GetType()
00067 {
00068 return type;
00069 }
00070
00071 SAnim* SAnimTrack::GetParentAnimation()
00072 {
00073 return parentAnimation;
00074 }
00075
00076 unsigned short SAnimTrack::GetNumKeyFrames()
00077 {
00078 unsigned short size = 0;
00079 if (ogreAnimationTrack)
00080 size = ogreAnimationTrack->getNumKeyFrames();
00081 return size;
00082 }
00083
00084 void SAnimTrack::SetOptimise()
00085 {
00086 if (ogreAnimationTrack)
00087 ogreAnimationTrack->optimise();
00088 }
00089
00090 void SAnimTrack::Update(float pos)
00091 {
00092 }
00093
00094 void SAnimTrack::CreateKey(float timepos, Ogre::Vector3 pos, Ogre::Quaternion quat, Ogre::Vector3 scale)
00095 {
00096 }
00097
00098 void SAnimTrack::SetKeyTransform(unsigned int keyIndex, Ogre::Vector3 pos, Ogre::Quaternion quat, Ogre::Vector3 scale)
00099 {
00100 }
00101
00102 void SAnimTrack::GetKeyTransform(unsigned int keyIndex, Ogre::Vector3 &pos, Ogre::Quaternion &quat, Ogre::Vector3 &scale)
00103 {
00104 pos = Ogre::Vector3::ZERO;
00105 quat = Ogre::Quaternion::IDENTITY;
00106 scale = Ogre::Vector3::ZERO;
00107 }
00108
00109 float SAnimTrack::GetKeyPositionTime(unsigned int keyIndex)
00110 {
00111 float postime = 0.0f;
00112 Ogre::KeyFrame* key = 0;
00113 if(((int)GetNumKeyFrames() - 1) >= (int)keyIndex)
00114 key = GetOgreAnimationTrackPointer()->getKeyFrame(keyIndex);
00115
00116 if (key)
00117 postime = key->getTime();
00118
00119 return postime;
00120 }
00121
00122 void SAnimTrack::RemoveKey(unsigned int keyIndex)
00123 {
00124 if(((int)GetNumKeyFrames() - 1) >= (int)keyIndex)
00125 GetOgreAnimationTrackPointer()->removeKeyFrame(keyIndex);
00126 }
00127
00128 void SAnimTrack::RemoveAllKeyFrames()
00129 {
00130 }
00131
00132 Ogre::AnimationTrack* SAnimTrack::_Clone(Ogre::Animation* tanim, unsigned short tid)
00133 {
00134 Ogre::AnimationTrack* newAnimTrack = 0;
00135 try{
00136 switch(type)
00137 {
00138 case SAnimTrack::SO3_NODE_TRACK:
00139 {
00140 Ogre::NodeAnimationTrack* nodeTrack = static_cast<Ogre::NodeAnimationTrack*>(ogreAnimationTrack);
00141 newAnimTrack = tanim->createNodeTrack(tid, nodeTrack->getAssociatedNode());
00142 for (int i = 0; i < nodeTrack->getNumKeyFrames(); i++)
00143 {
00144 Ogre::TransformKeyFrame* key = nodeTrack->getNodeKeyFrame(i);
00145 Ogre::TransformKeyFrame* nkey = static_cast<Ogre::NodeAnimationTrack*>(newAnimTrack)->createNodeKeyFrame(key->getTime());
00146 nkey->setRotation(key->getRotation());
00147 nkey->setScale(key->getScale());
00148 nkey->setTranslate(key->getTranslate());
00149 }
00150 break;
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 case SAnimTrack::SO3_VERTEX_TRACK || SAnimTrack::SO3_POSE_TRACK:
00172 {
00173 Ogre::VertexAnimationTrack* vertexTrack = static_cast<Ogre::VertexAnimationTrack*>(ogreAnimationTrack);
00174 newAnimTrack = tanim->createVertexTrack(tid, vertexTrack->getAssociatedVertexData(), vertexTrack->getAnimationType());
00175 for (int i = 0; i < vertexTrack->getNumKeyFrames(); i++)
00176 {
00177 Ogre::VertexMorphKeyFrame* key = vertexTrack->getVertexMorphKeyFrame(i);
00178 Ogre::VertexMorphKeyFrame* nkey = static_cast<Ogre::VertexAnimationTrack*>(newAnimTrack)->createVertexMorphKeyFrame(key->getTime());
00179 nkey->setVertexBuffer(key->getVertexBuffer());
00180 }
00181 break;
00182 }
00183
00184 default:
00185 newAnimTrack = 0;
00186 }
00187 }
00188 catch (Ogre::Exception)
00189 {
00190 }
00191
00192 return newAnimTrack;
00193 }
00194
00195 }