4#include <glm/gtc/matrix_transform.hpp>
5#include <glm/gtx/quaternion.hpp>
9void Bone::calcMatrix(std::vector<Bone>& allbones, ssize_t anim,
size_t time,
bool rotate)
15 const glm::fquat q(1.0f, 0.0f, 0.0f, 0.0f);
20 m = glm::translate(m,
pivot);
34 glGetFloatv(GL_MODELVIEW_MATRIX, modelview);
36 glm::vec3 vRight = glm::vec3(modelview[0], modelview[4], modelview[8]);
37 const glm::vec3 vUp = glm::vec3(modelview[1], modelview[5], modelview[9]);
39 vRight = vRight * -1.f;
48 m = glm::translate(m,
pivot * -1.0f);
53 allbones[
parent].calcMatrix(allbones, anim, time, rotate);
67 mrot = glm::toMat4(q);
71 mrot = glm::mat4(1.0f);
T getValue(ssize_t anim, size_t time)
void init(AnimationBlock &b, GameFile *f, std::vector< uint32 > &gs)
bool uses(ssize_t anim) const
void calcMatrix(std::vector< Bone > &allbones, ssize_t anim, size_t time, bool rotate=true)
Compute the bone matrix from parent bones and animation data.
bool billboard
Whether this bone is billboarded.
Animated< glm::fquat, PACK_QUATERNION, Quat16ToQuat32 > rot
Rotation animation track (packed 16-bit).
glm::vec3 transPivot
Pivot point and translated pivot.
int16 parent
Parent bone index (-1 if root).
Animated< glm::vec3 > trans
Translation animation track.
glm::mat4 mat
Computed transformation matrix.
Animated< glm::vec3 > scale
Scale animation track.
glm::mat4 mrot
Computed rotation-only matrix.
ModelBoneDef boneDef
Raw bone definition from the M2 file.
bool calc
Whether this bone has been calculated for the current frame.
void initV3(GameFile &f, ModelBoneDef &b, const modelAnimData &data)
Initialise the bone from an M2 v3+ file.
Abstract base class representing a file within the game data archive.
Holds per-model animation metadata: index-to-id mapping, external anim files, and global sequences.
On-disk bone definition (block E) in an M2 file.
AnimationBlock translation