1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-20 09:21:44 +02:00
openrw/rwengine/include/engine/Animator.hpp

91 lines
1.7 KiB
C++
Raw Normal View History

2013-09-11 01:26:13 +02:00
#pragma once
#ifndef _ANIMATOR_HPP_
#define _ANIMATOR_HPP_
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include <vector>
#include <map>
#include <cstdint>
class Animation;
class AnimationBone;
class Model;
2014-03-01 12:19:33 +01:00
class ModelFrame;
2013-09-11 01:26:13 +02:00
/**
* @brief The Animator class handles updating frame matricies for animations.
*/
class Animator
{
Animation* animation;
Model* model;
glm::vec3 lastRootPosition;
glm::quat lastRootRotation;
float time;
float serverTime;
float lastServerTime;
2013-09-30 20:32:14 +02:00
bool repeat;
2013-09-11 01:26:13 +02:00
void reset();
public:
Animator();
/**
* @brief setAnimation Sets the currently active animation.
* @param animation
2013-09-30 20:32:14 +02:00
* @param repeat If true animation will restart after ending.
2013-09-11 01:26:13 +02:00
* @todo Interpolate between the new and old frames.
*/
2013-09-30 20:32:14 +02:00
void setAnimation(Animation* animation, bool repeat = true);
2013-09-11 01:26:13 +02:00
void setModel(Model* model);
2014-03-01 12:19:33 +01:00
/**
* @brief getFrameMatrix returns the matrix for frame at the current time
* @param t
* @param frame
* @return
*/
glm::mat4 getFrameMatrix(ModelFrame* frame, float alpha) const;
2013-09-11 01:26:13 +02:00
/**
* @brief tick Update animation paramters for server-side data.
* @param dt
*/
void tick(float dt);
/**
* @brief render Update frame matricies for client-side animation.
* @param dt
*/
void render(float dt);
/**
* @brief getRootTranslation Returns the translation of the root bone from the last server-side frame.
* @return
*/
glm::vec3 getRootTranslation() const;
/**
* @brief getRootRotation see getRootTranslation
* @return
*/
glm::quat getRootRotation() const;
2013-10-02 02:27:48 +02:00
/**
* Returns true if the animation has finished playing.
*/
bool isCompleted() const;
2014-03-01 12:19:33 +01:00
float getAnimationTime(float alpha = 0.f) const;
2013-09-11 01:26:13 +02:00
};
#endif