Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SkeletalAnimation.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11
12class SkeletonPose;
13
15class SkeletalAnimation : public RefTarget<SkeletalAnimation>
16{
17public:
19
20
22 {
23 public:
25
26
27 void FromMatrix(Mat44Arg inMatrix);
28
30 inline Mat44 ToMatrix() const { return Mat44::sRotationTranslation(mRotation, mTranslation); }
31
32 Quat mRotation = Quat::sIdentity();
33 Vec3 mTranslation = Vec3::sZero();
34 };
35
37 class Keyframe : public JointState
38 {
39 public:
41
42 float mTime = 0.0f;
43 };
44
46
49 {
50 public:
52
53 String mJointName;
54 KeyframeVector mKeyframes;
55 };
56
58
60 float GetDuration() const;
61
63 void ScaleJoints(float inScale);
64
66 void Sample(float inTime, SkeletonPose &ioPose) const;
67
69 const AnimatedJointVector & GetAnimatedJoints() const { return mAnimatedJoints; }
70 AnimatedJointVector & GetAnimatedJoints() { return mAnimatedJoints; }
71
72private:
73 AnimatedJointVector mAnimatedJoints;
74 bool mIsLooping = true;
75};
76
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition: STLAllocator.h:82
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(class_name)
Definition: SerializableObject.h:71
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
static JPH_INLINE Mat44 sRotationTranslation(QuatArg inR, Vec3Arg inT)
Get matrix that rotates and translates.
Definition: Mat44.inl:149
Definition: Quat.h:33
static JPH_INLINE Quat sIdentity()
Definition: Quat.h:93
Definition: Reference.h:35
Contains the animation for a single joint.
Definition: SkeletalAnimation.h:49
Constains the current state of a joint, a local space transformation relative to its parent joint.
Definition: SkeletalAnimation.h:22
Mat44 ToMatrix() const
Convert to matrix representation.
Definition: SkeletalAnimation.h:30
Contains the state of a single joint at a particular time.
Definition: SkeletalAnimation.h:38
float mTime
Time of keyframe in seconds.
Definition: SkeletalAnimation.h:42
Resource for a skinned animation.
Definition: SkeletalAnimation.h:16
void Sample(float inTime, SkeletonPose &ioPose) const
Get the (interpolated) joint transforms at time inTime.
Definition: SkeletalAnimation.cpp:60
void ScaleJoints(float inScale)
Scale the size of all joints by inScale.
Definition: SkeletalAnimation.cpp:53
AnimatedJointVector & GetAnimatedJoints()
Definition: SkeletalAnimation.h:70
const AnimatedJointVector & GetAnimatedJoints() const
Get joint samples
Definition: SkeletalAnimation.h:69
float GetDuration() const
Get the length (in seconds) of this animation.
Definition: SkeletalAnimation.cpp:45
Array< Keyframe > KeyframeVector
Definition: SkeletalAnimation.h:45
Array< AnimatedJoint > AnimatedJointVector
Definition: SkeletalAnimation.h:57
Instance of a skeleton, contains the pose the current skeleton is in.
Definition: SkeletonPose.h:18
Definition: Vec3.h:16
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition: Vec3.inl:107