DatasmithAnimationElements.h
1 // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
2 
3 #pragma once
4 
5 #include "IDatasmithSceneElements.h"
6 
7 #include "Templates/SharedPointer.h"
8 #include "Misc/FrameNumber.h"
9 #include "Misc/SecureHash.h"
10 
12 
13 class DATASMITHCORE_API IDatasmithBaseAnimationElement : public IDatasmithElement
14 {
15 public:
16  /** Set how the actor should behave once its animation completes */
17  virtual void SetCompletionMode(EDatasmithCompletionMode CompletionMode) = 0;
18 
19  /** Get how the actor behaves once this animation is complete */
20  virtual EDatasmithCompletionMode GetCompletionMode() const = 0;
21 };
22 
23 /** IDatasmithTransformAnimationElement holds the frames for an actor transform animation */
25 {
26 public:
28 
29  /** Add a frame of the given transform type to the animation */
30  virtual void AddFrame(EDatasmithTransformType TransformType, const FDatasmithTransformFrameInfo& FrameInfo) = 0;
31 
32  /** Return the number of frames of the given transform type in the animation */
33  virtual int32 GetFramesCount(EDatasmithTransformType TransformType) const = 0;
34 
35  /** Set the interpolation mode of the given transform type in the animation */
36  virtual void SetCurveInterpMode(EDatasmithTransformType TransformType, EDatasmithCurveInterpMode CurveInterpMode) = 0;
37 
38  /** Get the interpolation mode of the given transform type in the animation */
39  virtual EDatasmithCurveInterpMode GetCurveInterpMode(EDatasmithTransformType TransformType) const = 0;
40 
41  /** Return the frame of the given transform type at the given index or an invalid frame if the index was out of bounds */
42  virtual const FDatasmithTransformFrameInfo& GetFrame(EDatasmithTransformType TransformType, int32 Index) const = 0;
43 
44  /** Remove the frame of the given transform type at the given index from the animation */
45  virtual void RemoveFrame(EDatasmithTransformType TransformType, int32 Index) = 0;
46 
47  /** Gets which channels of this animation will be moved to the animation assets or serialized. All channels are enabled by default */
48  virtual EDatasmithTransformChannels GetEnabledTransformChannels() const = 0;
49 
50  /** Sets which channels of this animation will be moved to the animation assets or serialized. All channels are enabled by default */
51  virtual void SetEnabledTransformChannels(EDatasmithTransformChannels Channels) = 0;
52 };
53 
54 /** IDatasmithVisibilityAnimationElement holds the frames for an actor's visibility animation */
56 {
57 public:
59 
60  /** Add a frame to the animation */
61  virtual void AddFrame(const FDatasmithVisibilityFrameInfo& FrameInfo) = 0;
62 
63  /** Return the number of frames of the animation */
64  virtual int32 GetFramesCount() const = 0;
65 
66  /** Set the interpolation mode of the animation */
67  virtual void SetCurveInterpMode(EDatasmithCurveInterpMode CurveInterpMode) = 0;
68 
69  /** Get the interpolation mode of the animation */
70  virtual EDatasmithCurveInterpMode GetCurveInterpMode() const = 0;
71 
72  /** Return the frame of the animation at the given index or an invalid frame if the index was out of bounds */
73  virtual const FDatasmithVisibilityFrameInfo& GetFrame(int32 Index) const = 0;
74 
75  /** Remove the frame at the given index from the animation */
76  virtual void RemoveFrame(int32 Index) = 0;
77 };
78 
79 /** IDatasmithSubsequenceAnimationElement holds a reference to a IDatasmithLevelSequenceElement, to be played as a subsequence */
81 {
82 public:
84 
85  /** Get the frame where the subsequence starts */
86  virtual FFrameNumber GetStartTime() const = 0;
87 
88  /** Set the frame where the subsequence starts */
89  virtual void SetStartTime(FFrameNumber InStartTime) = 0;
90 
91  /** Get the subsequence duration in number of frames */
92  virtual int32 GetDuration() const = 0;
93 
94  /** Set the subsequence duration in number of frames */
95  virtual void SetDuration(int32 InDuration) = 0;
96 
97  /** Get the time scale used for the subsequence */
98  virtual float GetTimeScale() const = 0;
99 
100  /** Set the time scale used for the subsequence */
101  virtual void SetTimeScale(float InTimeScale) = 0;
102 
103  /** Get a pointer to the subsequence that this element references */
104  virtual TWeakPtr<IDatasmithLevelSequenceElement> GetSubsequence() const = 0;
105 
106  /** Set the subsequence that this element references */
107  virtual void SetSubsequence(TWeakPtr<IDatasmithLevelSequenceElement> InSubsequence) = 0;
108 };
109 
110 /** IDatasmithLevelSequenceElement holds a set of animations */
111 class DATASMITHCORE_API IDatasmithLevelSequenceElement : public IDatasmithElement
112 {
113 public:
114  virtual ~IDatasmithLevelSequenceElement() {}
115 
116  /** Get the output filename, it can be absolute or relative to the scene file */
117  virtual const TCHAR* GetFile() const = 0;
118 
119  /** Set the output filename, it can be absolute or relative to the scene file */
120  virtual void SetFile(const TCHAR* InFile) = 0;
121 
122  /** Return a MD5 hash of the content of the Level Sequence Element. Used in CalculateElementHash to quickly identify Element with identical content */
123  virtual FMD5Hash GetFileHash() const = 0;
124 
125  /** Set the MD5 hash of the Level Sequence file. This should be a hash of its content. */
126  virtual void SetFileHash(FMD5Hash Hash) = 0;
127 
128  /* Gets the frame rate for the animations in the level sequence */
129  virtual float GetFrameRate() const = 0;
130 
131  /* Sets the frame rate for the animations in the level sequence */
132  virtual void SetFrameRate(float FramePerSecs) = 0;
133 
134  /**
135  * Adds an animation to the level sequence.
136  *
137  * @param InAnimation the animation to add
138  */
139  virtual void AddAnimation(const TSharedRef< IDatasmithBaseAnimationElement >& InAnimation) = 0;
140 
141  /** Returns the number of animations in the level sequence */
142  virtual int32 GetAnimationsCount() const = 0;
143 
144  /** Returns the animation using this index */
145  virtual TSharedPtr< IDatasmithBaseAnimationElement > GetAnimation(int32 InIndex) = 0;
146 
147  /**
148  * Removes an animation from the level sequence.
149  *
150  * @param InAnimation the animation to remove
151  */
152  virtual void RemoveAnimation(const TSharedRef< IDatasmithBaseAnimationElement >& InAnimation) = 0;
153 };
FDatasmithVisibilityFrameInfo
FDatasmithVisibilityFrameInfo holds the visibility value for a frame.
Definition: DatasmithTypes.h:132
IDatasmithBaseAnimationElement
Definition: DatasmithAnimationElements.h:13
FDatasmithTransformFrameInfo
FDatasmithTransformFrameInfo holds the data for the transform values of a frame The transform values ...
Definition: DatasmithTypes.h:90
IDatasmithElement
Root class for every element in a Datasmith scene.
Definition: IDatasmithSceneElements.h:22
IDatasmithLevelSequenceElement
IDatasmithLevelSequenceElement holds a set of animations.
Definition: DatasmithAnimationElements.h:111
IDatasmithVisibilityAnimationElement
IDatasmithVisibilityAnimationElement holds the frames for an actor's visibility animation.
Definition: DatasmithAnimationElements.h:55
IDatasmithTransformAnimationElement
IDatasmithTransformAnimationElement holds the frames for an actor transform animation.
Definition: DatasmithAnimationElements.h:24
IDatasmithSubsequenceAnimationElement
IDatasmithSubsequenceAnimationElement holds a reference to a IDatasmithLevelSequenceElement,...
Definition: DatasmithAnimationElements.h:80