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
8#include <Jolt/Core/Result.h>
11
13
14class SkeletonPose;
15
17class JPH_EXPORT SkeletalAnimation : public RefTarget<SkeletalAnimation>
18{
20
21public:
24 {
26
27 public:
29 void FromMatrix(Mat44Arg inMatrix);
30
32 inline Mat44 ToMatrix() const { return Mat44::sRotationTranslation(mRotation, mTranslation); }
33
34 Quat mRotation = Quat::sIdentity();
35 Vec3 mTranslation = Vec3::sZero();
36 };
37
39 class Keyframe : public JointState
40 {
42
43 public:
44 float mTime = 0.0f;
45 };
46
48
58
60
62 float GetDuration() const;
63
65 void ScaleJoints(float inScale);
66
68 void SetIsLooping(bool inIsLooping) { mIsLooping = inIsLooping; }
69 bool IsLooping() const { return mIsLooping; }
70
72 void Sample(float inTime, SkeletonPose &ioPose) const;
73
75 const AnimatedJointVector & GetAnimatedJoints() const { return mAnimatedJoints; }
76 AnimatedJointVector & GetAnimatedJoints() { return mAnimatedJoints; }
77
79 void SaveBinaryState(StreamOut &inStream) const;
80
82
84 static AnimationResult sRestoreFromBinaryState(StreamIn &inStream);
85
86private:
87 AnimatedJointVector mAnimatedJoints;
88 bool mIsLooping = true;
89};
90
#define JPH_EXPORT
Definition Core.h:271
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition STLAllocator.h:107
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
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:103
Definition Reference.h:35
Helper class that either contains a valid result or an error.
Definition Result.h:12
Contains the animation for a single joint.
Definition SkeletalAnimation.h:51
KeyframeVector mKeyframes
List of keyframes over time.
Definition SkeletalAnimation.h:56
String mJointName
Name of the joint.
Definition SkeletalAnimation.h:55
Contains the current state of a joint, a local space transformation relative to its parent joint.
Definition SkeletalAnimation.h:24
Mat44 ToMatrix() const
Convert to matrix representation.
Definition SkeletalAnimation.h:32
Contains the state of a single joint at a particular time.
Definition SkeletalAnimation.h:40
Resource for a skinned animation.
Definition SkeletalAnimation.h:18
AnimatedJointVector & GetAnimatedJoints()
Definition SkeletalAnimation.h:76
bool IsLooping() const
Definition SkeletalAnimation.h:69
const AnimatedJointVector & GetAnimatedJoints() const
Get joint samples.
Definition SkeletalAnimation.h:75
void SetIsLooping(bool inIsLooping)
If the animation is looping or not. If an animation is looping, the animation will continue playing a...
Definition SkeletalAnimation.h:68
Instance of a skeleton, contains the pose the current skeleton is in.
Definition SkeletonPose.h:18
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition Vec3.h:17
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:103