SO3Engine
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
v
w
x
Functions
Variables
Typedefs
a
b
c
d
f
m
p
s
Enumerations
Enumerator
b
c
e
f
h
l
m
n
p
r
s
t
x
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
f
g
i
l
m
n
o
p
s
t
u
v
w
Enumerations
a
c
d
e
f
g
h
l
n
p
r
s
v
w
Enumerator
a
b
c
d
e
f
h
l
m
n
o
p
r
s
t
v
Related Symbols
a
c
d
h
i
o
p
s
x
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
z
Functions
_
b
c
d
f
g
h
i
l
m
n
r
s
t
v
w
z
Variables
a
b
c
d
e
f
i
l
m
n
o
p
r
s
t
u
w
Typedefs
Enumerator
src
SO3Animation
SO3SequenceAnimation.cpp
Go to the documentation of this file.
1
/*
2
-----------------------------------------------------------------------------
3
This source file is part of OpenSpace3D
4
For the latest info, see http://www.openspace3d.com
5
6
Copyright (c) 2012 I-maginer
7
8
This program is free software; you can redistribute it and/or modify it under
9
the terms of the GNU Lesser General Public License as published by the Free Software
10
Foundation; either version 2 of the License, or (at your option) any later
11
version.
12
13
This program is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public License along with
18
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20
http://www.gnu.org/copyleft/lesser.txt
21
22
-----------------------------------------------------------------------------
23
*/
24
31
#include "
SO3Animation/SO3SequenceAnimation.h
"
32
#include "
SO3Animation/SO3SequenceAnimationTrack.h
"
33
#include "
SO3SceneGraph/SO3Skeleton.h
"
34
35
namespace
SO3
36
{
37
38
SSequenceAnimation::SSequenceAnimation(
SScene
* scene,
const
std::string& animationName,
const
unsigned
short
&
id
) :
SAnim
(scene, animationName, 0, id,
SAnim
::SO3_SEQUENCE_ANIM)
39
{
40
ogreAnimation
=
mScene
->
GetOgreScenePointer
()->createAnimation(animationName, 0.0f);
41
ogreAnimationState =
mScene
->
GetOgreScenePointer
()->createAnimationState(animationName);
42
mLastPos = 0.0f;
43
mState =
false
;
44
}
38
SSequenceAnimation::SSequenceAnimation(
SScene
* scene,
const
std::string& animationName,
const
unsigned
short
&
id
) :
SAnim
(scene, animationName, 0, id,
SAnim
::SO3_SEQUENCE_ANIM) {
…
}
45
46
SSequenceAnimation::SSequenceAnimation() :
SAnim
(0,
""
, 0, 0, SO3_UNKNOWN_ANIM)
47
{
48
// Forbiden (private)
49
}
50
51
SSequenceAnimation::~SSequenceAnimation
()
52
{
53
if
(
mScene
->
GetOgreScenePointer
()->hasAnimationState(
name
))
54
mScene
->
GetOgreScenePointer
()->destroyAnimationState(
name
);
55
ogreAnimationState = 0;
56
if
(
mScene
->
GetOgreScenePointer
()->hasAnimation(
name
))
57
mScene
->
GetOgreScenePointer
()->destroyAnimation(
name
);
58
}
51
SSequenceAnimation::~SSequenceAnimation
() {
…
}
59
60
SAnimTrack
*
SSequenceAnimation::CreateAnimationTrackImpl
(
const
std::string& newAnimationTrackName)
61
{
62
return
new
SSequenceAnimationTrack
(newAnimationTrackName,
this
, 0);
63
}
60
SAnimTrack
*
SSequenceAnimation::CreateAnimationTrackImpl
(
const
std::string& newAnimationTrackName) {
…
}
64
65
Ogre::AnimationState*
SSequenceAnimation::_GetOgreAnimationState
()
66
{
67
return
ogreAnimationState;
68
}
65
Ogre::AnimationState*
SSequenceAnimation::_GetOgreAnimationState
() {
…
}
69
70
void
SSequenceAnimation::SetTimePosition
(
const
float
& timePosition)
71
{
72
if
(
_GetOgreAnimationState
())
73
_GetOgreAnimationState
()->setTimePosition(timePosition);
74
75
//update tracks
76
if
(
GetEnable
())
77
{
78
SAnimTrackList::iterator iAnimationTrack =
animationTrackList
.begin();
79
while
(iAnimationTrack !=
animationTrackList
.end())
80
{
81
(*iAnimationTrack)->Update(timePosition);
82
iAnimationTrack++;
83
}
84
//force update current animations
85
//GetParentScene()->GetOgreScenePointer()->_applySceneAnimations();
86
}
87
88
mLastPos = timePosition;
89
}
70
void
SSequenceAnimation::SetTimePosition
(
const
float
& timePosition) {
…
}
90
91
void
SSequenceAnimation::SetEnable
(
const
bool
& enable)
92
{
93
//if (ogreAnimationState)
94
// ogreAnimationState->setEnabled(enable);
95
mState = enable;
96
97
SetPaused
(!enable);
98
99
const
SAnimTrackList
animationTrackCopy =
animationTrackList
;
100
SAnimTrackList::const_iterator iAnimationTrack = animationTrackCopy.begin();
101
while
(iAnimationTrack != animationTrackCopy.end())
102
{
103
static_cast<
SSequenceAnimationTrack
*
>
(*iAnimationTrack)->
EnableTrackKeys
(enable);
104
iAnimationTrack++;
105
}
106
}
91
void
SSequenceAnimation::SetEnable
(
const
bool
& enable) {
…
}
107
108
bool
SSequenceAnimation::GetEnable
()
109
{
110
return
mState;
111
}
108
bool
SSequenceAnimation::GetEnable
() {
…
}
112
113
void
SSequenceAnimation::UpdateAnimationLength
()
114
{
115
float
length = 0.0f;
116
const
SAnimTrackList
animationTrackCopy =
animationTrackList
;
117
SAnimTrackList::const_iterator iAnimationTrack = animationTrackCopy.begin();
118
while
(iAnimationTrack != animationTrackCopy.end())
119
{
120
if
(
static_cast<
SSequenceAnimationTrack
*
>
(*iAnimationTrack)->
GetLength
() > length)
121
length =
static_cast<
SSequenceAnimationTrack
*
>
(*iAnimationTrack)->
GetLength
();
122
123
iAnimationTrack++;
124
}
125
SetLength
(length);
126
}
113
void
SSequenceAnimation::UpdateAnimationLength
() {
…
}
127
128
float
SSequenceAnimation::GetLastPos
()
129
{
130
return
mLastPos;
131
}
128
float
SSequenceAnimation::GetLastPos
() {
…
}
132
133
void
SSequenceAnimation::_UpdateImpl
(
const
Ogre::FrameEvent &evt)
134
{
135
//$BB max time is set to 16 millisecond (one frame / 60)
136
Ogre::Real maxtime = (evt.timeSinceLastFrame <= 0.016f) ? evt.timeSinceLastFrame : (evt.timeSinceLastFrame * 0.016f / evt.timeSinceLastFrame);
137
138
if
(
SkipFrame
())
139
AddTime
((
float
)evt.timeSinceLastFrame *
GetSpeed
());
140
else
141
AddTime
(maxtime *
GetSpeed
());
142
143
float
currentPos =
GetTimePosition
();
144
145
SAnimTrackList::iterator iAnimationTrack =
animationTrackList
.begin();
146
while
(iAnimationTrack !=
animationTrackList
.end())
147
{
148
(*iAnimationTrack)->Update(
GetTimePosition
());
149
iAnimationTrack++;
150
}
151
152
mLastPos = currentPos;
153
}
133
void
SSequenceAnimation::_UpdateImpl
(
const
Ogre::FrameEvent &evt) {
…
}
154
155
}
SO3SequenceAnimation.h
SO3SequenceAnimationTrack.h
SO3Skeleton.h
SO3::SAnim
Definition
SO3Anim.h:42
SO3::SAnim::AddTime
void AddTime(const float &time)
Definition
SO3Anim.cpp:351
SO3::SAnim::SetPaused
void SetPaused(const bool &pauseState)
Definition
SO3Anim.cpp:357
SO3::SAnim::ogreAnimation
Ogre::Animation * ogreAnimation
Definition
SO3Anim.h:65
SO3::SAnim::SetLength
void SetLength(const float &length)
Definition
SO3Anim.cpp:199
SO3::SAnim::SkipFrame
bool SkipFrame()
Definition
SO3Anim.cpp:135
SO3::SAnim::mScene
SScene * mScene
Definition
SO3Anim.h:67
SO3::SAnim::GetTimePosition
float GetTimePosition()
Definition
SO3Anim.cpp:228
SO3::SAnim::animationTrackList
SAnimTrackList animationTrackList
Definition
SO3Anim.h:66
SO3::SAnim::GetSpeed
float GetSpeed()
Definition
SO3Anim.cpp:337
SO3::SAnimTrack
Definition
SO3AnimTrack.h:42
SO3::SData::name
std::string name
Definition
SO3DataScol.h:44
SO3::SScene
Definition
SO3Scene.h:125
SO3::SScene::GetOgreScenePointer
Ogre::SceneManager * GetOgreScenePointer()
Definition
SO3Scene.cpp:449
SO3::SSequenceAnimation::UpdateAnimationLength
void UpdateAnimationLength()
Definition
SO3SequenceAnimation.cpp:113
SO3::SSequenceAnimation::SetEnable
virtual void SetEnable(const bool &enable)
Definition
SO3SequenceAnimation.cpp:91
SO3::SSequenceAnimation::GetEnable
virtual bool GetEnable()
Definition
SO3SequenceAnimation.cpp:108
SO3::SSequenceAnimation::_GetOgreAnimationState
virtual Ogre::AnimationState * _GetOgreAnimationState()
Definition
SO3SequenceAnimation.cpp:65
SO3::SSequenceAnimation::~SSequenceAnimation
~SSequenceAnimation()
Definition
SO3SequenceAnimation.cpp:51
SO3::SSequenceAnimation::_UpdateImpl
virtual void _UpdateImpl(const Ogre::FrameEvent &evt)
Definition
SO3SequenceAnimation.cpp:133
SO3::SSequenceAnimation::CreateAnimationTrackImpl
virtual SAnimTrack * CreateAnimationTrackImpl(const std::string &newAnimationTrackName)
Definition
SO3SequenceAnimation.cpp:60
SO3::SSequenceAnimation::GetLastPos
float GetLastPos()
Definition
SO3SequenceAnimation.cpp:128
SO3::SSequenceAnimation::SetTimePosition
virtual void SetTimePosition(const float &timePosition)
Definition
SO3SequenceAnimation.cpp:70
SO3::SSequenceAnimationTrack
Definition
SO3SequenceAnimationTrack.h:35
SO3::SSequenceAnimationTrack::GetLength
float GetLength()
Definition
SO3SequenceAnimationTrack.cpp:182
SO3::SSequenceAnimationTrack::EnableTrackKeys
void EnableTrackKeys(const bool &enable)
Definition
SO3SequenceAnimationTrack.cpp:187
SO3
Definition
SO3DataScol.h:38
SO3::SAnimTrackList
std::vector< SAnimTrack * > SAnimTrackList
Definition
SO3Prerequisites.h:264
Generated by
1.9.8