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>
10
12
13class SkeletonPose;
14class StreamIn;
15class StreamOut;
16
18class JPH_EXPORT SkeletalAnimation : public RefTarget<SkeletalAnimation>
19{
21
22public:
25 {
27
28 public:
30 void FromMatrix(Mat44Arg inMatrix);
31
33 inline Mat44 ToMatrix() const { return Mat44::sRotationTranslation(mRotation, mTranslation); }
34
35 Quat mRotation = Quat::sIdentity();
36 Vec3 mTranslation = Vec3::sZero();
37 };
38
40 class Keyframe : public JointState
41 {
43
44 public:
45 float mTime = 0.0f;
46 };
47
49
59
61
63 float GetDuration() const;
64
66 void ScaleJoints(float inScale);
67
69 void SetIsLooping(bool inIsLooping) { mIsLooping = inIsLooping; }
70 bool IsLooping() const { return mIsLooping; }
71
73 void Sample(float inTime, SkeletonPose &ioPose) const;
74
76 const AnimatedJointVector & GetAnimatedJoints() const { return mAnimatedJoints; }
77 AnimatedJointVector & GetAnimatedJoints() { return mAnimatedJoints; }
78
80 void SaveBinaryState(StreamOut &inStream) const;
81
83
85 static AnimationResult sRestoreFromBinaryState(StreamIn &inStream);
86
87private:
88 AnimatedJointVector mAnimatedJoints;
89 bool mIsLooping = true;
90};
91
#define JPH_EXPORT
Definition Core.h:275
#define JPH_NAMESPACE_END
Definition Core.h:425
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
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:104
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:52
KeyframeVector mKeyframes
List of keyframes over time.
Definition SkeletalAnimation.h:57
String mJointName
Name of the joint.
Definition SkeletalAnimation.h:56
Contains the current state of a joint, a local space transformation relative to its parent joint.
Definition SkeletalAnimation.h:25
Mat44 ToMatrix() const
Convert to matrix representation.
Definition SkeletalAnimation.h:33
Contains the state of a single joint at a particular time.
Definition SkeletalAnimation.h:41
Resource for a skinned animation.
Definition SkeletalAnimation.h:19
AnimatedJointVector & GetAnimatedJoints()
Definition SkeletalAnimation.h:77
bool IsLooping() const
Definition SkeletalAnimation.h:70
const AnimatedJointVector & GetAnimatedJoints() const
Get joint samples.
Definition SkeletalAnimation.h:76
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:69
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