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:
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
86
87private:
88 AnimatedJointVector mAnimatedJoints;
89 bool mIsLooping = true;
90};
91
#define JPH_EXPORT
Definition Core.h:286
#define JPH_NAMESPACE_END
Definition Core.h:469
#define JPH_NAMESPACE_BEGIN
Definition Core.h:463
const Mat44 & Mat44Arg
Definition MathTypes.h:29
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
Definition Array.h:36
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
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
void FromMatrix(Mat44Arg inMatrix)
Convert from a local space matrix.
Definition SkeletalAnimation.cpp:41
Quat mRotation
Local space rotation of the joint.
Definition SkeletalAnimation.h:35
Mat44 ToMatrix() const
Convert to matrix representation.
Definition SkeletalAnimation.h:33
Vec3 mTranslation
Local space translation of the joint.
Definition SkeletalAnimation.h:36
Contains the state of a single joint at a particular time.
Definition SkeletalAnimation.h:41
float mTime
Time of keyframe in seconds.
Definition SkeletalAnimation.h:45
Resource for a skinned animation.
Definition SkeletalAnimation.h:19
void ScaleJoints(float inScale)
Scale the size of all joints by inScale.
Definition SkeletalAnimation.cpp:55
AnimatedJointVector & GetAnimatedJoints()
Definition SkeletalAnimation.h:77
bool IsLooping() const
Definition SkeletalAnimation.h:70
Result< Ref< SkeletalAnimation > > AnimationResult
Definition SkeletalAnimation.h:82
static AnimationResult sRestoreFromBinaryState(StreamIn &inStream)
Restore a saved ragdoll from inStream.
Definition SkeletalAnimation.cpp:132
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
float GetDuration() const
Get the length (in seconds) of this animation.
Definition SkeletalAnimation.cpp:47
Array< Keyframe > KeyframeVector
Definition SkeletalAnimation.h:48
Array< AnimatedJoint > AnimatedJointVector
Definition SkeletalAnimation.h:60
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:125