Plasma Engine  2.0
Loading...
Searching...
No Matches
SimpleAnimationComponent.h
1#pragma once
2
3#include <Core/Messages/EventMessage.h>
4#include <Core/ResourceManager/ResourceHandle.h>
5#include <Core/World/ComponentManager.h>
6#include <GameEngine/Animation/PropertyAnimResource.h>
7#include <GameEngine/Animation/Skeletal/AnimationControllerComponent.h>
8#include <RendererCore/AnimationSystem/AnimPoseGenerator.h>
9#include <RendererCore/AnimationSystem/AnimationPose.h>
10#include <ozz/base/containers/vector.h>
11#include <ozz/base/maths/simd_math.h>
12#include <ozz/base/maths/soa_transform.h>
13
14class plEventTrack;
16
19
21
25class PL_GAMEENGINE_DLL plSimpleAnimationComponent : public plComponent
26{
28
30 // plComponent
31
32public:
33 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
34 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
35
36protected:
37 virtual void OnSimulationStarted() override;
38
40 // plJointAttachmentComponent
41
42public:
45
46 void SetAnimationClip(const plAnimationClipResourceHandle& hResource);
47 const plAnimationClipResourceHandle& GetAnimationClip() const;
48
49 void SetAnimationClipFile(const char* szFile); // [ property ]
50 const char* GetAnimationClipFile() const; // [ property ]
51
54
56 float m_fSpeed = 1.0f; // [ property ]
57
59 void SetNormalizedPlaybackPosition(float fPosition);
60
62 float GetNormalizedPlaybackPosition() const { return m_fNormalizedPlaybackPosition; }
63
66
67protected:
68 void Update();
69 bool UpdatePlaybackTime(plTime tDiff, const plEventTrack& eventTrack, plAnimPoseEventTrackSampleMode& out_trackSampling);
70
71 plEnum<plRootMotionMode> m_RootMotionMode;
72 float m_fNormalizedPlaybackPosition = 0.0f;
73 plTime m_Duration;
74 plAnimationClipResourceHandle m_hAnimationClip;
75 plSkeletonResourceHandle m_hSkeleton;
76 plTime m_ElapsedTimeSinceUpdate = plTime::MakeZero();
77
78 ozz::vector<ozz::math::SoaTransform> m_OzzLocalTransforms; // TODO: could be frame allocated
79};
Base class of all component types.
Definition Component.h:25
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void OnSimulationStarted()
This method is called once for active components, at the start of the next world update,...
Definition Component.cpp:144
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
An event track is a time line that contains named events.
Definition EventTrack.h:15
Plays a single animation clip on an animated mesh.
Definition SimpleAnimationComponent.h:26
plEnum< plAnimationInvisibleUpdateRate > m_InvisibleUpdateRate
How often to update the animation while the animated mesh is invisible.
Definition SimpleAnimationComponent.h:65
float GetNormalizedPlaybackPosition() const
Returns the normalized [0;1] sample position of the animation clip.
Definition SimpleAnimationComponent.h:62
plEnum< plPropertyAnimMode > m_AnimationMode
How to play the animation.
Definition SimpleAnimationComponent.h:53
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
For use in scripts to signal a custom event that some game event has occurred.
Definition CommonMessages.h:29
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE static constexpr plTime MakeZero()
Creates an instance of plTime that was initialized with zero.
Definition Time.h:42