Project

General

Profile

SO3Engine
SO3SkeletonAnimation.cpp
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
35
36#include <boost/lexical_cast.hpp>
37
38namespace SO3
39{
40
41SSkeletonAnimation::SSkeletonAnimation(SScene* scene, const std::string& animationName, SSkeleton* skeleton, const unsigned short& id) : SAnim(scene, animationName, skeleton, id, SAnim::SO3_SKELETAL_ANIM)
42{
43 ogreAnimation = skeleton->GetOgreSkeletonPointer()->getAnimation(id);
44 mOgreEntity = skeleton->GetParentEntity()->getOgreEntityPointer();
45
46 Ogre::Animation::NodeTrackList ogreNodesTracks = ogreAnimation->_getNodeTrackList();
47 for(Ogre::Animation::NodeTrackList::iterator it = ogreNodesTracks.begin(); it != ogreNodesTracks.end(); it++)
48 {
49 Ogre::NodeAnimationTrack* ogreNodeTrack = it->second;
50 std::string animationTrackName = animationName+".skeletonTrack_"+boost::lexical_cast<std::string>(ogreNodeTrack->getHandle());
51 SAnimTrack* animationTrack = new SSkeletonAnimationTrack(animationTrackName, this, ogreNodeTrack->getHandle());
52 AddAnimationTrack(animationTrack);
53 }
54}
55
56SSkeletonAnimation::SSkeletonAnimation() : SAnim(0, "", 0, 0, SO3_UNKNOWN_ANIM)
57{
58 // Forbiden (private)
59}
60
64
66{
67 return mOgreEntity->getAnimationState(name);
68}
69
70}
void AddAnimationTrack(SAnimTrack *existingAnimationTrack)
Definition SO3Anim.cpp:187
Ogre::Animation * ogreAnimation
Definition SO3Anim.h:65
std::string name
Definition SO3DataScol.h:44
Ogre::Entity * getOgreEntityPointer()
virtual Ogre::AnimationState * _GetOgreAnimationState()
Ogre::SkeletonInstance * GetOgreSkeletonPointer()
SEntity * GetParentEntity()