40 _animationSpeed(1.0f),
41 _animationLength(1.0f),
43 _animationLoopLength(1.0f),
44 _animationLoopTime(0.0f),
50 if (!animation || speed <= 0.0f)
76 length = (loopCount + 1) * animation->
getLength();
172 if (nextFrame == 0.0f)
197 uint8 pick = std::rand() % 100;
200 if (pick < a->probability)
203 pick -= a->probability;
222 int maxNodeNumber = -1;
224 for (std::list<AnimNode *>::const_iterator n = animNodes.begin();
225 n != animNodes.end(); ++n) {
226 int nodeNumber = (*n)->getNodeData()->getNodeNumber();
227 if (nodeNumber > maxNodeNumber)
228 maxNodeNumber = nodeNumber;
233 if (maxNodeNumber == -1)
238 for (std::list<AnimNode *>::const_iterator an = animNodes.begin();
239 an != animNodes.end(); ++an) {
240 ModelNode *animNode = (*an)->getNodeData();
258 n = state->
nodeMap.find(animNodeName);
259 if (n != state->
nodeMap.end()) {
DefaultAnimations _defaultAnimations
A node within an animation.
NodeMap nodeMap
The nodes within the state, indexed by name.
void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Play a named animation.
float _animationLoopTime
The time the current loop of the current animation has played.
float _animationSpeed
The speed the current animation should run at.
float _animationTime
The time the current animation has played.
A class holding an UTF-8 string.
void update(Model *model, float lastFrame, float nextFrame, const std::vector< ModelNode *> &modelNodeMap)
Update the model position and orientation.
An animation to be applied to a model.
std::map< Common::UString, Model * > _attachedModels
State * _currentState
The current state.
bool lock(uint32 timeout=0)
void addDefaultAnimation(const Common::UString &name, uint8 probability)
float _animationLoopLength
The length of one loop of the current animation.
float _animationLength
The time the current animation should run for.
void playDefaultAnimation()
Common::Semaphore _manageSem
void manageAnimations(float dt)
Animation * _currentAnimation
The currently playing animation.
const std::list< AnimNode * > & getNodes() const
Get all animation nodes.
void playDefaultAnimationInternal()
Animation * _nextAnimation
The animation that's scheduled next.
void createBound()
Create the model's bounding box.
AnimationChannel(Model *model)
std::vector< ModelNode * > _modelNodeMap
float getLength() const
Get the animations length.
const Common::UString & getName() const
Get the node's name.
Model * _superModel
The actual super model.
uint8 probability
The probability (in percent) this animation is selected.
uint16 getNodeNumber() const
Animation * getAnimation(const Common::UString &anim)
Get the animation from its name.
ModelNode * getNode(const Common::UString &node)
Get the specified node, from the current state.
void clearDefaultAnimations()
void playAnimationCount(const Common::UString &anim, bool restart=true, int32 loopCount=0)
Play a named animation a number of loop iterations.
Animation * selectDefaultAnimation()
void setCurrentAnimation(Animation *anim)