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:
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
85
86private:
87 AnimatedJointVector mAnimatedJoints;
88 bool mIsLooping = true;
89};
90
#define JPH_EXPORT
Definition Core.h:275
#define JPH_NAMESPACE_END
Definition Core.h:425
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
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: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
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:34
Mat44 ToMatrix() const
Convert to matrix representation.
Definition SkeletalAnimation.h:32
Vec3 mTranslation
Local space translation of the joint.
Definition SkeletalAnimation.h:35
Contains the state of a single joint at a particular time.
Definition SkeletalAnimation.h:40
float mTime
Time of keyframe in seconds.
Definition SkeletalAnimation.h:44
Resource for a skinned animation.
Definition SkeletalAnimation.h:18
void ScaleJoints(float inScale)
Scale the size of all joints by inScale.
Definition SkeletalAnimation.cpp:55
AnimatedJointVector & GetAnimatedJoints()
Definition SkeletalAnimation.h:76
bool IsLooping() const
Definition SkeletalAnimation.h:69
Result< Ref< SkeletalAnimation > > AnimationResult
Definition SkeletalAnimation.h:81
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: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
float GetDuration() const
Get the length (in seconds) of this animation.
Definition SkeletalAnimation.cpp:47
Array< Keyframe > KeyframeVector
Definition SkeletalAnimation.h:47
Array< AnimatedJoint > AnimatedJointVector
Definition SkeletalAnimation.h:59
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