IMovieSystem.h 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/ComponentBus.h>
  10. #include <AzCore/Component/EntityId.h>
  11. #include <AzCore/Math/Crc.h>
  12. #include <AzCore/Math/Quaternion.h>
  13. #include <AzCore/Math/Vector2.h>
  14. #include <AzCore/Math/Vector3.h>
  15. #include <AzCore/Math/Vector4.h>
  16. #include <Range.h>
  17. #include <AnimKey.h>
  18. #include <ISplines.h>
  19. #include <CryCommon/Maestro/Types/AnimValueType.h>
  20. #define DEFAULT_NEAR 0.2f
  21. #define DEFAULT_FOV (75.0f * gf_PI / 180.0f)
  22. // forward declaration.
  23. struct IAnimTrack;
  24. struct IAnimNode;
  25. struct IAnimSequence;
  26. struct IMovieSystem;
  27. struct IKey;
  28. class XmlNodeRef;
  29. struct ISplineInterpolator;
  30. namespace AZ
  31. {
  32. class SerializeContext;
  33. namespace Data
  34. {
  35. class AssetData;
  36. }
  37. }
  38. namespace Maestro
  39. {
  40. template<typename AssetType>
  41. struct AssetBlends;
  42. }
  43. typedef IMovieSystem* (* PFNCREATEMOVIESYSTEM)(struct ISystem*);
  44. #define LIGHT_ANIMATION_SET_NAME "_LightAnimationSet"
  45. #define MAX_ANIM_NAME_LENGTH 64
  46. //! Very high priority for cut scene sounds.
  47. #define MOVIE_SOUND_PRIORITY 230
  48. #if !defined(CONSOLE)
  49. #define MOVIESYSTEM_SUPPORT_EDITING
  50. #endif
  51. typedef std::vector<IAnimSequence*> AnimSequences;
  52. typedef AZStd::vector<AZStd::string> TrackEvents;
  53. // Forward declare
  54. enum class SequenceType;
  55. enum class AnimNodeType;
  56. enum class AnimValueType;
  57. enum class AnimParamType;
  58. // TODO: Refactor headers that are using these values so they are not need in header files
  59. // AnimValueType::Float is the default value
  60. #define kAnimValueDefault static_cast<AnimValueType>(0)
  61. // AnimValueType::Unknown
  62. #define kAnimValueUnknown static_cast<AnimValueType>(0xFFFFFFFF)
  63. // SequenceType::SequenceComponent is the default value
  64. #define kSequenceTypeDefault static_cast<SequenceType>(1)
  65. // AnimParamType::Invalid
  66. #define kAnimParamTypeInvalid static_cast<AnimParamType>(0xFFFFFFFF)
  67. // AnimParamType::ByString
  68. #define kAnimParamTypeByString static_cast<AnimParamType>(8)
  69. //! Flags that can be set on animation node.
  70. enum EAnimNodeFlags
  71. {
  72. eAnimNodeFlags_Expanded = BIT(0), //!< Deprecated, handled by sandbox now
  73. eAnimNodeFlags_EntitySelected = BIT(1), //!< Set if the referenced entity is selected in the editor
  74. eAnimNodeFlags_CanChangeName = BIT(2), //!< Set if this node allow changing of its name.
  75. eAnimNodeFlags_Disabled = BIT(3), //!< Disable this node.
  76. eAnimNodeFlags_DisabledForComponent = BIT(4), //!< Disable this node for a disabled or pending entity component.
  77. };
  78. enum ENodeExportType
  79. {
  80. eNodeExportType_Global = 0,
  81. eNodeExportType_Local = 1,
  82. };
  83. // Common parameters of animation node.
  84. class CAnimParamType
  85. {
  86. friend class CMovieSystem;
  87. friend class AnimSerializer;
  88. public:
  89. AZ_TYPE_INFO_WITH_NAME_DECL(CAnimParamType);
  90. static const uint kParamTypeVersion = 9;
  91. CAnimParamType();
  92. CAnimParamType(const AZStd::string& name);
  93. CAnimParamType(AnimParamType type);
  94. // Convert from old enum or int
  95. void operator =(AnimParamType type);
  96. void operator =(const AZStd::string& name);
  97. // Convert to enum. This needs to be explicit,
  98. // otherwise operator== will be ambiguous
  99. constexpr AnimParamType GetType() const { return m_type; }
  100. // Get name
  101. const char* GetName() const { return m_name.c_str(); }
  102. bool operator ==(const CAnimParamType& animParamType) const;
  103. bool operator !=(const CAnimParamType& animParamType) const;
  104. bool operator <(const CAnimParamType& animParamType) const;
  105. operator size_t() const
  106. {
  107. AZStd::hash<AnimParamType> paramTypeHasher;
  108. size_t retVal = paramTypeHasher(GetType());
  109. AZStd::hash_combine(retVal, AZ::Crc32(GetName()));
  110. return retVal;
  111. }
  112. void SaveToXml(XmlNodeRef& xmlNode) const;
  113. void LoadFromXml(const XmlNodeRef& xmlNode, const uint version = kParamTypeVersion);
  114. // Serialization
  115. void Serialize(XmlNodeRef& xmlNode, bool bLoading, const uint version = kParamTypeVersion);
  116. private:
  117. AnimParamType m_type;
  118. AZStd::string m_name;
  119. };
  120. //! Types of animation track.
  121. // Do not change values! they are serialized
  122. //
  123. // Attention: This should only be expanded if you add a completely new way how tracks store data!
  124. // If you just want to control a new parameter of an entity etc. extend EParamType
  125. //
  126. // Note: TCB splines are only for backward compatibility, Bezier is the default
  127. //
  128. enum EAnimCurveType : unsigned int
  129. {
  130. eAnimCurveType_TCBFloat = 1,
  131. eAnimCurveType_TCBVector = 2,
  132. eAnimCurveType_TCBQuat = 3,
  133. eAnimCurveType_BezierFloat = 4,
  134. eAnimCurveType_Unknown = 0xFFFFFFFF
  135. };
  136. enum ETrackMask
  137. {
  138. eTrackMask_MaskSound = 1 << 11, // Old: 1 << ATRACK_SOUND
  139. };
  140. //! Structure passed to Animate function.
  141. struct SAnimContext
  142. {
  143. SAnimContext();
  144. float time; //!< Current time in seconds.
  145. float dt; //!< Delta of time from previous animation frame in seconds.
  146. float fps; //!< Last calculated frames per second value.
  147. bool singleFrame; //!< This is not a playing animation, more a single-frame update.
  148. bool forcePlay; //!< Set when force playing animation.
  149. bool resetting; //!< Set when animation sequence is resetting.
  150. IAnimSequence* sequence; //!< Sequence in which animation performed.
  151. // TODO: Replace trackMask with something more type safe
  152. // TODO: Mask should be stored with dynamic length
  153. uint32 trackMask; //!< To update certain types of tracks only
  154. float startTime; //!< The start time of this playing sequence
  155. };
  156. //! Interface for movie-system implemented by user for advanced function-support
  157. struct IMovieUser
  158. {
  159. // <interfuscator:shuffle>
  160. virtual ~IMovieUser(){}
  161. //! Called when movie system requests a camera-change.
  162. virtual void SetActiveCamera(const AZ::EntityId& cameraEntityId) = 0;
  163. //! Called when movie system enters into cut-scene mode.
  164. virtual void BeginCutScene(IAnimSequence* pSeq, unsigned long dwFlags, bool bResetFX) = 0;
  165. //! Called when movie system exits from cut-scene mode.
  166. virtual void EndCutScene(IAnimSequence* pSeq, unsigned long dwFlags) = 0;
  167. //! Called when movie system wants to send a global event.
  168. virtual void SendGlobalEvent(const char* pszEvent) = 0;
  169. // </interfuscator:shuffle>
  170. };
  171. //! Callback-class
  172. struct IMovieCallback
  173. {
  174. //! Callback-reasons
  175. enum ECallbackReason
  176. {
  177. CBR_CHANGENODE, // Node is changing.
  178. CBR_CHANGETRACK // Track of the node is changing.
  179. };
  180. // <interfuscator:shuffle>
  181. virtual ~IMovieCallback(){}
  182. // Called by movie system.
  183. virtual void OnMovieCallback(ECallbackReason reason, IAnimNode* pNode) = 0;
  184. virtual bool IsSequenceCamUsed() const = 0;
  185. // </interfuscator:shuffle>
  186. };
  187. /** Interface of Animation Track.
  188. */
  189. struct IAnimTrack
  190. {
  191. AZ_TYPE_INFO_WITH_NAME_DECL(IAnimTrack);
  192. AZ_RTTI_NO_TYPE_INFO_DECL();
  193. AZ_CLASS_ALLOCATOR_DECL
  194. static void Reflect(AZ::ReflectContext* context);
  195. //! Flags that can be set on animation track.
  196. enum EAnimTrackFlags
  197. {
  198. eAnimTrackFlags_Linear = BIT(1), //!< Use only linear interpolation between keys.
  199. eAnimTrackFlags_Loop = BIT(2), //!< Play this track in a loop.
  200. eAnimTrackFlags_Cycle = BIT(3), //!< Cycle track.
  201. eAnimTrackFlags_Disabled = BIT(4), //!< Disable this track.
  202. //////////////////////////////////////////////////////////////////////////
  203. // Used by editor.
  204. //////////////////////////////////////////////////////////////////////////
  205. eAnimTrackFlags_Hidden = BIT(5), //!< Set when track is hidden in track view.
  206. eAnimTrackFlags_Muted = BIT(8), //!< Mute this sound track or music track. This only affects the playback in editor on these types of tracks.
  207. };
  208. // <interfuscator:shuffle>
  209. virtual ~IAnimTrack() {};
  210. // for intrusive_ptr support
  211. virtual void add_ref() = 0;
  212. virtual void release() = 0;
  213. //////////////////////////////////////////////////////////////////////////
  214. virtual EAnimCurveType GetCurveType() const = 0;
  215. virtual AnimValueType GetValueType() const = 0;
  216. #ifdef MOVIESYSTEM_SUPPORT_EDITING
  217. // This color is used for the editor.
  218. virtual ColorB GetCustomColor() const = 0;
  219. virtual void SetCustomColor(ColorB color) = 0;
  220. virtual bool HasCustomColor() const = 0;
  221. virtual void ClearCustomColor() = 0;
  222. #endif
  223. // Return what parameter of the node, this track is attached to.
  224. virtual const CAnimParamType& GetParameterType() const = 0;
  225. // Assign node parameter ID for this track.
  226. virtual void SetParameterType(CAnimParamType type) = 0;
  227. virtual void SetNode(IAnimNode* node) = 0;
  228. // Return Animation Sequence that owns this node.
  229. virtual IAnimNode* GetNode() const = 0;
  230. //////////////////////////////////////////////////////////////////////////
  231. // Animation track can contain sub-tracks (Position XYZ anim track have sub-tracks for x,y,z)
  232. // Get count of sub tracks.
  233. virtual int GetSubTrackCount() const = 0;
  234. // Retrieve pointer the specified sub track.
  235. virtual IAnimTrack* GetSubTrack(int nIndex) const = 0;
  236. virtual AZStd::string GetSubTrackName(int nIndex) const = 0;
  237. virtual void SetSubTrackName(int nIndex, const char* name) = 0;
  238. //////////////////////////////////////////////////////////////////////////
  239. virtual void GetKeyValueRange(float& fMin, float& fMax) const = 0;
  240. virtual void SetKeyValueRange(float fMin, float fMax) = 0;
  241. //! Return number of keys in track.
  242. virtual int GetNumKeys() const = 0;
  243. //! Return true if keys exists in this track
  244. virtual bool HasKeys() const = 0;
  245. //! Set number of keys in track.
  246. //! If needed adds empty keys at end or remove keys from end.
  247. virtual void SetNumKeys(int numKeys) = 0;
  248. //! Remove specified key.
  249. virtual void RemoveKey(int keyIndex) = 0;
  250. //! Get key at specified location.
  251. //! @param key Must be valid pointer to compatible key structure, to be filled with specified key location.
  252. virtual void GetKey(int keyIndex, IKey* key) const = 0;
  253. //! Get time of specified key.
  254. //! @return key time, or -1 if key with this index is not found.
  255. virtual float GetKeyTime(int keyIndex) const = 0;
  256. //! Get minimal legal time delta between keys.
  257. //! @return Minimal legal time delta between keys.
  258. virtual float GetMinKeyTimeDelta() const = 0;
  259. //! Find key at given time within minimal time delta between keys.
  260. //! @return Index of found key, or -1 if key with this time is not found.
  261. virtual int FindKey(float time) const = 0;
  262. //! Get flags of specified key.
  263. //! @return key flags, or -1 if key with this index is not found.
  264. virtual int GetKeyFlags(int keyIndex) = 0;
  265. //! Set key at specified location.
  266. //! @param key Must be valid pointer to compatible key structure.
  267. virtual void SetKey(int keyIndex, IKey* key) = 0;
  268. //! Set time of specified key.
  269. virtual void SetKeyTime(int keyIndex, float time) = 0;
  270. //! Set flags of specified key.
  271. virtual void SetKeyFlags(int keyIndex, int flags) = 0;
  272. //! Sort keys in track (after time of keys was modified).
  273. virtual void SortKeys() = 0;
  274. //! Get track flags.
  275. virtual int GetFlags() const = 0;
  276. //! Check if track is masked by mask
  277. // TODO: Mask should be stored with dynamic length
  278. virtual bool IsMasked(const uint32 mask) const = 0;
  279. //! Set track flags.
  280. virtual void SetFlags(int flags) = 0;
  281. //! Create key at given time, and return its index.
  282. //! @return Index of new key, or -1 if key is not created (for example, if a key at this time exists).
  283. virtual int CreateKey(float time) = 0;
  284. //! Clone key at specified index, adding minimal legal time delta between keys to the new key.
  285. //! @retun Index of new key if cloned, otherwise -1 (for example, if a key at increased time exists)).
  286. virtual int CloneKey(int srcKeyIndex, float timeOffset) = 0;
  287. //! Copy key at specified index from another track of SAME TYPE.
  288. //! @retun Index of new key if copied, otherwise -1 (for example, if a key at the source key time exists)).
  289. virtual int CopyKey(IAnimTrack* pFromTrack, int fromKeyIndex) = 0;
  290. //! Get info about specified key.
  291. //! @param keyIndex The index specifying the this key.
  292. //! @param description The short human readable text description of this key.
  293. //! @param duration The duration of this key in seconds.
  294. virtual void GetKeyInfo(int keyIndex, const char*& description, float& duration) const = 0;
  295. //////////////////////////////////////////////////////////////////////////
  296. // Get track value at specified time.
  297. // Interpolates keys if needed.
  298. // Applies a scale multiplier set in SetMultiplier(), if requested
  299. //////////////////////////////////////////////////////////////////////////
  300. virtual void GetValue(float time, float& value, bool applyMultiplier=false) const = 0;
  301. virtual void GetValue(float time, AZ::Vector3& value, bool applyMultiplier = false) const = 0;
  302. virtual void GetValue(float time, AZ::Vector4& value, bool applyMultiplier = false) const = 0;
  303. virtual void GetValue(float time, AZ::Quaternion& value) const = 0;
  304. virtual void GetValue(float time, bool& value) const = 0;
  305. virtual void GetValue(float time, Maestro::AssetBlends<AZ::Data::AssetData>& value) const = 0;
  306. virtual void GetValue(float time, AZStd::string& value) const = 0;
  307. //////////////////////////////////////////////////////////////////////////
  308. // Set track value at specified time.
  309. // Adds new keys if required.
  310. //////////////////////////////////////////////////////////////////////////
  311. virtual void SetValue(float time, const float& value, bool bDefault = false, bool applyMultiplier = false) = 0;
  312. virtual void SetValue(float time, const AZ::Vector3& value, bool bDefault = false, bool applyMultiplier = false) = 0;
  313. virtual void SetValue(float time, const AZ::Vector4& value, bool bDefault = false, bool applyMultiplier = false) = 0;
  314. virtual void SetValue(float time, const AZ::Quaternion& value, bool bDefault = false) = 0;
  315. virtual void SetValue(float time, const bool& value, bool bDefault = false) = 0;
  316. virtual void SetValue(float time, const Maestro::AssetBlends<AZ::Data::AssetData>& value, bool bDefault = false) = 0;
  317. virtual void SetValue(float time, const AZStd::string& value, bool bDefault = false) = 0;
  318. // Only for position tracks, offset all track keys by this amount.
  319. virtual void OffsetKeyPosition(const AZ::Vector3& value) = 0;
  320. // Used to update the data in tracks after the parent entity has been changed.
  321. virtual void UpdateKeyDataAfterParentChanged(const AZ::Transform& oldParentWorldTM, const AZ::Transform& newParentWorldTM) = 0;
  322. //! Assign active time range for this track.
  323. virtual void SetTimeRange(const Range& timeRange) = 0;
  324. //! Get active time range of this track.
  325. virtual Range GetTimeRange() const = 0;
  326. //! @deprecated - IAnimTracks use AZ::Serialization now. Legacy - Serialize this animation track to XML.
  327. virtual bool Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bLoadEmptyTracks = true) = 0;
  328. virtual bool SerializeSelection(XmlNodeRef& xmlNode, bool bLoading, bool bCopySelected = false, float fTimeOffset = 0) = 0;
  329. virtual void InitPostLoad(IAnimSequence* /*sequence*/) {};
  330. //! For custom track animate parameters.
  331. virtual void Animate([[maybe_unused]] SAnimContext& ec) {};
  332. // Get access to the internal spline of the track.
  333. virtual ISplineInterpolator* GetSpline() const { return 0; };
  334. //! @return True if a specified key is selected (has selected flag).
  335. virtual bool IsKeySelected([[maybe_unused]] int keyIndex) const { return false; }
  336. virtual void SelectKey([[maybe_unused]] int keyIndex, [[maybe_unused]] bool select) {}
  337. virtual void SetSortMarkerKey([[maybe_unused]] int keyIndex, [[maybe_unused]] bool enabled) {}
  338. virtual bool IsSortMarkerKey([[maybe_unused]] int keyIndex) const { return false; }
  339. //! Return the index of the key which lies right after the given key in time.
  340. //! @param key Index of key.
  341. //! @return Index of the next key in time. If the last key given, this returns -1.
  342. // In case of keys sorted, it's just 'key+1', but if not sorted, it can be another value.
  343. virtual int NextKeyByTime(int keyIndex) const;
  344. //! Get the animation layer index assigned. (only for character/look-at tracks ATM)
  345. virtual int GetAnimationLayerIndex() const { return -1; }
  346. //! Set the animation layer index. (only for character/look-at tracks ATM)
  347. virtual void SetAnimationLayerIndex([[maybe_unused]] int index) {}
  348. //! Returns whether the track responds to muting (false by default), which only affects the Editor.
  349. //! Tracks that use mute should override this, such as CSoundTrack
  350. //! @return Boolean of whether the track responds to muting or not
  351. virtual bool UsesMute() const { return false; }
  352. //! Set a multiplier which will be multiplied to track values in SetValue and divided out in GetValue if requested
  353. virtual void SetMultiplier(float trackValueMultiplier) = 0;
  354. // Expanded state interface
  355. virtual void SetExpanded(bool expanded) = 0;
  356. virtual bool GetExpanded() const = 0;
  357. virtual unsigned int GetId() const = 0;
  358. virtual void SetId(unsigned int id) = 0;
  359. // </interfuscator:shuffle>
  360. };
  361. /** Callback called by animation node when its animated.
  362. */
  363. struct IAnimNodeOwner
  364. {
  365. // <interfuscator:shuffle>
  366. virtual ~IAnimNodeOwner(){}
  367. virtual void OnNodeAnimated([[maybe_unused]] IAnimNode* pNode) {}
  368. virtual void OnNodeVisibilityChanged(IAnimNode* pNode, const bool bHidden) = 0;
  369. virtual void OnNodeReset([[maybe_unused]] IAnimNode* pNode) {}
  370. // mark the node's sequence object layer as modified
  371. virtual void MarkAsModified() = 0;
  372. // </interfuscator:shuffle>
  373. };
  374. /** Base class for all Animation nodes,
  375. can host multiple animation tracks, and execute them other time.
  376. Animation node is reference counted.
  377. */
  378. struct IAnimNode
  379. {
  380. public:
  381. AZ_TYPE_INFO_WITH_NAME_DECL(IAnimNode);
  382. AZ_RTTI_NO_TYPE_INFO_DECL()
  383. AZ_CLASS_ALLOCATOR_DECL;
  384. static void Reflect(AZ::ReflectContext* context);
  385. //////////////////////////////////////////////////////////////////////////
  386. // Supported params.
  387. //////////////////////////////////////////////////////////////////////////
  388. enum ESupportedParamFlags
  389. {
  390. eSupportedParamFlags_MultipleTracks = 0x01, // Set if parameter can be assigned multiple tracks.
  391. eSupportedParamFlags_Hidden = 0x02, // Hidden from the Track View UI.
  392. };
  393. struct SParamInfo
  394. {
  395. SParamInfo();
  396. SParamInfo(const char* _name, CAnimParamType _paramType, AnimValueType _valueType, ESupportedParamFlags _flags);
  397. AZStd::string name; // parameter name.
  398. CAnimParamType paramType; // parameter id.
  399. AnimValueType valueType; // value type, defines type of track to use for animating this parameter.
  400. ESupportedParamFlags flags; // combination of flags from ESupportedParamFlags.
  401. };
  402. using AnimParamInfos = AZStd::vector<SParamInfo>;
  403. // <interfuscator:shuffle>
  404. virtual ~IAnimNode() {};
  405. // for intrusive_ptr support
  406. virtual void add_ref() = 0;
  407. virtual void release() = 0;
  408. //! Set node name.
  409. virtual void SetName(const char* name) = 0;
  410. //! Get node name.
  411. virtual const char* GetName() const = 0;
  412. // Get Type of this node.
  413. virtual AnimNodeType GetType() const = 0;
  414. // Return Animation Sequence that owns this node.
  415. virtual IAnimSequence* GetSequence() const = 0;
  416. // Set the Animation Sequence that owns this node.
  417. virtual void SetSequence(IAnimSequence* sequence) = 0;
  418. // Called when sequence is activated / deactivated
  419. virtual void Activate(bool bActivate) = 0;
  420. // Set AnimNode flags.
  421. // @param flags One or more flags from EAnimNodeFlags.
  422. // @see EAnimNodeFlags
  423. virtual void SetFlags(int flags) = 0;
  424. // Get AnimNode flags.
  425. // @return flags set on node.
  426. // @see EAnimNodeFlags
  427. virtual int GetFlags() const = 0;
  428. // return true if flagsToCheck is set on the node or any of the node's parents
  429. virtual bool AreFlagsSetOnNodeOrAnyParent(EAnimNodeFlags flagsToCheck) const = 0;
  430. // AZ::Entity is bound/handled via their Id over EBuses, as opposed to directly with pointers.
  431. virtual void SetAzEntityId(const AZ::EntityId& id) = 0;
  432. virtual AZ::EntityId GetAzEntityId() const = 0;
  433. // Return movie system that created this node.
  434. virtual IMovieSystem* GetMovieSystem() const = 0;
  435. virtual void SetPos(float time, const AZ::Vector3& pos) = 0;
  436. virtual void SetRotate(float time, const AZ::Quaternion& rot) = 0;
  437. virtual void SetScale(float time, const AZ::Vector3& scale) = 0;
  438. //! Compute and return the offset which brings the current position to the given position
  439. virtual Vec3 GetOffsetPosition(const Vec3& position);
  440. //! Get current entity position.
  441. virtual Vec3 GetPos() = 0;
  442. //! Get current entity rotation.
  443. virtual Quat GetRotate() = 0;
  444. //! Get entity rotation at specified time.
  445. virtual Quat GetRotate(float time) = 0;
  446. //! Get current entity scale.
  447. virtual Vec3 GetScale() = 0;
  448. // General Set param.
  449. // Set float/vec3/vec4 parameter at given time.
  450. // @return true if parameter set, false if this parameter not exist in node.
  451. virtual bool SetParamValue(float time, CAnimParamType param, float value) = 0;
  452. virtual bool SetParamValue(float time, CAnimParamType param, const AZ::Vector3& value) = 0;
  453. virtual bool SetParamValue(float time, CAnimParamType param, const AZ::Vector4& value) = 0;
  454. // Get float/vec3/vec4 parameter at given time.
  455. // @return true if parameter exist, false if this parameter not exist in node.
  456. virtual bool GetParamValue(float time, CAnimParamType param, float& value) = 0;
  457. virtual bool GetParamValue(float time, CAnimParamType param, AZ::Vector3& value) = 0;
  458. virtual bool GetParamValue(float time, CAnimParamType param, AZ::Vector4& value) = 0;
  459. //! Evaluate animation node while not playing animation.
  460. virtual void StillUpdate() = 0;
  461. //! Evaluate animation to the given time.
  462. virtual void Animate(SAnimContext& ec) = 0;
  463. // Description:
  464. // Returns number of supported parameters by this animation node (position,rotation,scale,etc..).
  465. // Returns:
  466. // Number of supported parameters.
  467. virtual unsigned int GetParamCount() const = 0;
  468. // Description:
  469. // Returns the type of a param by index
  470. // Arguments:
  471. // nIndex - parameter index in range 0 <= nIndex < GetSupportedParamCount()
  472. virtual CAnimParamType GetParamType(unsigned int nIndex) const = 0;
  473. // Description:
  474. // Check if parameter is supported by this node.
  475. virtual bool IsParamValid(const CAnimParamType& paramType) const = 0;
  476. // Description:
  477. // Returns name of supported parameter of this animation node or NULL if not available
  478. // Arguments:
  479. // paramType - parameter id
  480. virtual AZStd::string GetParamName(const CAnimParamType& paramType) const = 0;
  481. // Description:
  482. // Returns the params value type
  483. virtual AnimValueType GetParamValueType(const CAnimParamType& paramType) const = 0;
  484. // Description:
  485. // Returns the params value type
  486. virtual ESupportedParamFlags GetParamFlags(const CAnimParamType& paramType) const = 0;
  487. // Called node data is re-initialized, such as when changing the entity associated with it.
  488. virtual void OnReset() = 0;
  489. //////////////////////////////////////////////////////////////////////////
  490. // Working with Tracks.
  491. //////////////////////////////////////////////////////////////////////////
  492. virtual int GetTrackCount() const = 0;
  493. // Return track assigned to the specified parameter.
  494. virtual IAnimTrack* GetTrackByIndex(int nIndex) const = 0;
  495. // Return first track assigned to the specified parameter.
  496. virtual IAnimTrack* GetTrackForParameter(const CAnimParamType& paramType) const = 0;
  497. // Return the i-th track assigned to the specified parameter in case of multiple tracks.
  498. virtual IAnimTrack* GetTrackForParameter(const CAnimParamType& paramType, uint32 index) const = 0;
  499. // Get the index of a given track among tracks with the same parameter type in this node.
  500. virtual uint32 GetTrackParamIndex(const IAnimTrack* pTrack) const = 0;
  501. // Creates a new track for given parameter, with possible remapping.
  502. virtual IAnimTrack* CreateTrack(const CAnimParamType& paramType, AnimValueType remapValueType = AnimValueType::Unknown) = 0;
  503. // Initializes track default values after de-serialization / user creation. Only called in editor.
  504. virtual void InitializeTrackDefaultValue(IAnimTrack* pTrack, const CAnimParamType& paramType, AnimValueType remapValueType = AnimValueType::Unknown) = 0;
  505. // Updates track default values before adding a new key at time, so that animated entity is not affected by adding a key
  506. virtual void UpdateTrackDefaultValue(float time, IAnimTrack* pTrack) = 0;
  507. // Assign animation track to parameter.
  508. // if track parameter is NULL track with parameter id param will be removed.
  509. virtual void SetTrack(const CAnimParamType& paramType, IAnimTrack* track) = 0;
  510. // Set time range for all tracks in this sequence.
  511. virtual void SetTimeRange(Range timeRange) = 0;
  512. // Remove track from anim node.
  513. virtual void AddTrack(IAnimTrack* pTrack) = 0;
  514. // Remove track from anim node.
  515. virtual bool RemoveTrack(IAnimTrack* pTrack) = 0;
  516. // Description:
  517. // Creates default set of tracks supported by this node.
  518. virtual void CreateDefaultTracks() = 0;
  519. // returns the tangent type to use for created keys. Override this if you have an animNode that you wish
  520. // to have tangents other than UNIFIED created for new keys.
  521. virtual int GetDefaultKeyTangentFlags() const { return SPLINE_KEY_TANGENT_UNIFIED; }
  522. //////////////////////////////////////////////////////////////////////////
  523. //////////////////////////////////////////////////////////////////////////
  524. //////////////////////////////////////////////////////////////////////////
  525. // Callback for animation node used by editor.
  526. // Register notification callback with animation node.
  527. virtual void SetNodeOwner(IAnimNodeOwner* pOwner) = 0;
  528. virtual IAnimNodeOwner* GetNodeOwner() = 0;
  529. /**
  530. * O3DE_DEPRECATION_NOTICE(GHI-9326)
  531. * Serialization for Sequence data in Component Entity Sequences now occurs through AZ::SerializeContext and the Sequence Component
  532. **/
  533. virtual void Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bLoadEmptyTracks) = 0;
  534. /**
  535. * O3DE_DEPRECATION_NOTICE(GHI-9326)
  536. * Serialization for Sequence data in Component Entity Sequences now occurs through AZ::SerializeContext and the Sequence Component
  537. **/
  538. virtual void SerializeAnims(XmlNodeRef& xmlNode, bool bLoading, bool bLoadEmptyTracks) = 0;
  539. // Sets up internal pointers post load from Sequence Component
  540. virtual void InitPostLoad(IAnimSequence* sequence) = 0;
  541. //////////////////////////////////////////////////////////////////////////
  542. //////////////////////////////////////////////////////////////////////////
  543. // Groups interface
  544. //////////////////////////////////////////////////////////////////////////
  545. virtual void SetParent(IAnimNode* pParent) = 0;
  546. virtual IAnimNode* GetParent() const = 0;
  547. virtual IAnimNode* HasDirectorAsParent() const = 0;
  548. //////////////////////////////////////////////////////////////////////////
  549. virtual void Render() = 0;
  550. virtual bool NeedToRender() const = 0;
  551. // Called from editor if dynamic params need updating
  552. virtual void UpdateDynamicParams() = 0;
  553. // </interfuscator:shuffle>
  554. // Used by AnimCameraNode
  555. virtual bool GetShakeRotation([[maybe_unused]] const float& time, [[maybe_unused]] Quat& rot){return false; }
  556. virtual void SetCameraShakeSeed([[maybe_unused]] const uint shakeSeed){};
  557. // override this method to handle explicit setting of time
  558. virtual void TimeChanged([[maybe_unused]] float newTime) {};
  559. // Compares all of the node's track values at the given time with the associated property value and
  560. // sets a key at that time if they are different to match the latter
  561. // Returns the number of keys set
  562. virtual int SetKeysForChangedTrackValues([[maybe_unused]] float time) { return 0; };
  563. // Callbacks used when Game/Simulation mode is started and stopped in the Editor. Override if you want to handle these events
  564. virtual void OnStartPlayInEditor() {};
  565. virtual void OnStopPlayInEditor() {};
  566. ////////////////////////////////////////////////////////////////////////////////
  567. // interface for Components - implemented by CAnimComponentNode
  568. // Override if the derived node has an associated component type (e.g. CAnimComponentNode)
  569. virtual void SetComponent([[maybe_unused]] AZ::ComponentId comopnentId, [[maybe_unused]] const AZ::Uuid& componentTypeId) {}
  570. // returns the componentId of the component the node is associate with, if applicable, or a AZ::InvalidComponentId otherwise
  571. virtual AZ::ComponentId GetComponentId() const { return AZ::InvalidComponentId; }
  572. // ~interface for Components
  573. ////////////////////////////////////////////////////////////////////////////////
  574. // Used to disable any animation that is overridden by a SceneNode during camera interpolation, such as
  575. // FoV, transform, nearZ
  576. virtual void SetSkipInterpolatedCameraNode([[maybe_unused]] const bool skipNodeCameraAnimation) {};
  577. // Expanded state interface
  578. virtual void SetExpanded(bool expanded) = 0;
  579. virtual bool GetExpanded() const = 0;
  580. // Return the node id. This id is unique within a given sequence.
  581. virtual int GetId() const = 0;
  582. };
  583. //! Track event listener
  584. struct ITrackEventListener
  585. {
  586. //! Reasons
  587. enum ETrackEventReason
  588. {
  589. eTrackEventReason_Added,
  590. eTrackEventReason_Removed,
  591. eTrackEventReason_Renamed,
  592. eTrackEventReason_Triggered,
  593. eTrackEventReason_MovedUp,
  594. eTrackEventReason_MovedDown,
  595. };
  596. // <interfuscator:shuffle>
  597. virtual ~ITrackEventListener(){}
  598. // Description:
  599. // Called when track event is updated
  600. // Arguments:
  601. // pSeq - Animation sequence
  602. // reason - Reason for update (see EReason)
  603. // event - Track event added
  604. // pUserData - Data to accompany reason
  605. virtual void OnTrackEvent(IAnimSequence* sequence, int reason, const char* event, void* pUserData) = 0;
  606. // </interfuscator:shuffle>
  607. };
  608. struct IAnimLegacySequenceObject
  609. {
  610. // <interfuscator:shuffle>
  611. virtual ~IAnimLegacySequenceObject() {}
  612. virtual void OnNameChanged() = 0;
  613. virtual void OnModified() = 0;
  614. // </interfuscator:shuffle>
  615. };
  616. struct IAnimStringTable
  617. {
  618. AZ_TYPE_INFO_WITH_NAME_DECL(IAnimStringTable);
  619. AZ_RTTI_NO_TYPE_INFO_DECL();
  620. virtual ~IAnimStringTable() {}
  621. // for intrusive_ptr support
  622. virtual void add_ref() = 0;
  623. virtual void release() = 0;
  624. virtual const char* Add(const char* p) = 0;
  625. };
  626. /** Animation sequence, operates on animation nodes contained in it.
  627. */
  628. struct IAnimSequence
  629. {
  630. AZ_TYPE_INFO_WITH_NAME_DECL(IAnimSequence);
  631. AZ_RTTI_NO_TYPE_INFO_DECL();
  632. AZ_CLASS_ALLOCATOR_DECL;
  633. static const int kSequenceVersion = 5;
  634. static void Reflect(AZ::ReflectContext* context);
  635. //! Flags used for SetFlags(),GetFlags(),SetParentFlags(),GetParentFlags() methods.
  636. enum EAnimSequenceFlags
  637. {
  638. eSeqFlags_PlayOnReset = BIT(0), //!< Start playing this sequence immediately after reset of movie system(Level load).
  639. eSeqFlags_OutOfRangeConstant = BIT(1), //!< Constant Out-Of-Range,time continues normally past sequence time range.
  640. eSeqFlags_OutOfRangeLoop = BIT(2), //!< Loop Out-Of-Range,time wraps back to the start of range when reaching end of range.
  641. eSeqFlags_CutScene = BIT(3), //!< Cut scene sequence.
  642. eSeqFlags_NoHUD = BIT(4), //!< @deprecated - Don`t display HUD
  643. eSeqFlags_NoPlayer = BIT(5), //!< Disable input and drawing of player
  644. eSeqFlags_NoGameSounds = BIT(9), //!< Suppress all game sounds.
  645. eSeqFlags_NoSeek = BIT(10), //!< Cannot seek in sequence.
  646. eSeqFlags_NoAbort = BIT(11), //!< Cutscene can not be aborted
  647. eSeqFlags_NoSpeed = BIT(13), //!< Cannot modify sequence speed - TODO: add interface control if required
  648. // eSeqFlags_CanWarpInFixedTime = BIT(14), //!< @deprecated - Timewarp by scaling a fixed time step - removed July 2017, unused
  649. eSeqFlags_EarlyMovieUpdate = BIT(15), //!< Turn the 'sys_earlyMovieUpdate' on during the sequence.
  650. eSeqFlags_LightAnimationSet = BIT(16), //!< A special unique sequence for light animations
  651. eSeqFlags_NoMPSyncingNeeded = BIT(17), //!< this sequence doesn't require MP net syncing
  652. eSeqFlags_DisplayAsFramesOrSeconds = BIT(18), //!< Display Start/End time as frames or seconds
  653. };
  654. IAnimSequence()
  655. {
  656. AZ_Trace("IAnimSequence", "IAnimSequence");
  657. }
  658. virtual ~IAnimSequence()
  659. {
  660. AZ_Trace("IAnimSequence", "~IAnimSequence");
  661. }
  662. // for intrusive_ptr support
  663. virtual void add_ref() = 0;
  664. virtual void release() = 0;
  665. //! Set the name of this sequence. (ex. "Intro" in the same case as above)
  666. virtual void SetName(const char* name) = 0;
  667. //! Get the name of this sequence. (ex. "Intro" in the same case as above)
  668. virtual const char* GetName() const = 0;
  669. //! Get the ID (unique in a level and consistent across renaming) of this sequence.
  670. virtual uint32 GetId () const = 0;
  671. //! Resets the ID to the next available ID - used on sequence loads into levels to resolve ID collisions
  672. virtual void ResetId() = 0;
  673. // Legacy sequence objects are connected by pointers. SequenceComponents are connected by AZ::EntityId
  674. virtual void SetLegacySequenceObject(IAnimLegacySequenceObject* legacySequenceObject) = 0;
  675. virtual IAnimLegacySequenceObject* GetLegacySequenceObject() const = 0;
  676. virtual void SetSequenceEntityId(const AZ::EntityId& entityOwnerId) = 0;
  677. virtual const AZ::EntityId& GetSequenceEntityId() const = 0;
  678. //! Set the currently active director node.
  679. virtual void SetActiveDirector(IAnimNode* pDirectorNode) = 0;
  680. //! Get the currently active director node, if any.
  681. virtual IAnimNode* GetActiveDirector() const = 0;
  682. //! Set animation sequence flags
  683. virtual void SetFlags(int flags) = 0;
  684. //! Get animation sequence flags
  685. virtual int GetFlags() const = 0;
  686. //! Get cutscene related animation sequence flags
  687. virtual int GetCutSceneFlags(const bool localFlags = false) const = 0;
  688. //! Set parent animation sequence
  689. virtual void SetParentSequence(IAnimSequence* pParentSequence) = 0;
  690. //! Get parent animation sequence
  691. virtual const IAnimSequence* GetParentSequence() const = 0;
  692. //! Check whether this sequence has the given sequence as a descendant through one of its sequence tracks.
  693. virtual bool IsAncestorOf(const IAnimSequence* sequence) const = 0;
  694. //! Return number of animation nodes in sequence.
  695. virtual int GetNodeCount() const = 0;
  696. //! Get animation node at specified index.
  697. virtual IAnimNode* GetNode(int index) const = 0;
  698. //! Add animation node to sequence.
  699. //! @return True if node added, same node will not be added 2 times.
  700. virtual bool AddNode(IAnimNode* node) = 0;
  701. // Reorders the array of nodes, so the specified node is placed after or before the given pivot node depending on the parameter 'next'.
  702. virtual void ReorderNode(IAnimNode* node, IAnimNode* pPivotNode, bool next) = 0;
  703. // Description:
  704. // Creates a new animation node with specified type.
  705. // Arguments:
  706. // nodeType - Type of node, one of AnimNodeType enums.
  707. virtual IAnimNode* CreateNode(AnimNodeType nodeType) = 0;
  708. // Description:
  709. // Creates a new animation node from serialized node XML.
  710. // Arguments:
  711. // node - Serialized form of node
  712. virtual IAnimNode* CreateNode(XmlNodeRef node) = 0;
  713. //! Remove animation node from sequence.
  714. virtual void RemoveNode(IAnimNode* node, bool removeChildRelationships /*=true*/) = 0;
  715. // Finds node by name, can be slow.
  716. // If the node belongs to a director, the director node also should be given
  717. // since there can be multiple instances of the same node(i.e. the same name)
  718. // across multiple director nodes.
  719. virtual IAnimNode* FindNodeByName(const char* sNodeName, const IAnimNode* pParentDirector) = 0;
  720. //! Remove all nodes from sequence.
  721. virtual void RemoveAll() = 0;
  722. // Activate sequence by binding sequence animations to nodes.
  723. // must be called prior animating sequence.
  724. virtual void Activate() = 0;
  725. /** Check if sequence is activated
  726. */
  727. virtual bool IsActivated() const = 0;
  728. // Deactivates sequence by unbinding sequence animations from nodes.
  729. virtual void Deactivate() = 0;
  730. // Pre-caches data associated with this anim sequence.
  731. virtual void PrecacheData(float startTime = 0.0f) = 0;
  732. // Update sequence while not playing animation.
  733. virtual void StillUpdate() = 0;
  734. // Render function call for some special node.
  735. virtual void Render() = 0;
  736. // Evaluate animations of all nodes in sequence.
  737. // Sequence must be activated before animating.
  738. virtual void Animate(const SAnimContext& ec) = 0;
  739. //! Set time range of this sequence.
  740. virtual void SetTimeRange(Range timeRange) = 0;
  741. //! Get time range of this sequence.
  742. virtual Range GetTimeRange() const = 0;
  743. //! Resets the sequence
  744. virtual void Reset(bool bSeekToStart) = 0;
  745. //! This can have more time-consuming tasks performed additional to tasks of the usual 'Reset()' method.
  746. virtual void ResetHard() = 0;
  747. // Called to pause sequence.
  748. virtual void Pause() = 0;
  749. // Called to resume sequence.
  750. virtual void Resume() = 0;
  751. /** Called to check if sequence is paused.
  752. */
  753. virtual bool IsPaused() const = 0;
  754. /** Called when a sequence is looped.
  755. */
  756. virtual void OnLoop() = 0;
  757. /** Move/Scale all keys in tracks from previous time range to new time range.
  758. */
  759. virtual void AdjustKeysToTimeRange(const Range& timeRange) = 0;
  760. /** Called when time was explicitly jumped to/set.
  761. */
  762. virtual void TimeChanged(float newTime) = 0;
  763. // fix up internal pointers after load from Sequence Component
  764. virtual void InitPostLoad() = 0;
  765. // Copy some nodes of this sequence to XML.
  766. virtual void CopyNodes(XmlNodeRef& xmlNode, IAnimNode** pSelectedNodes, uint32 count) = 0;
  767. // Paste nodes given by the XML to this sequence.
  768. virtual void PasteNodes(const XmlNodeRef& xmlNode, IAnimNode* pParent) = 0;
  769. // Summary:
  770. // Adds/removes track events in sequence.
  771. virtual bool AddTrackEvent(const char* szEvent) = 0;
  772. virtual bool RemoveTrackEvent(const char* szEvent) = 0;
  773. virtual bool RenameTrackEvent(const char* szEvent, const char* szNewEvent) = 0;
  774. virtual bool MoveUpTrackEvent(const char* szEvent) = 0;
  775. virtual bool MoveDownTrackEvent(const char* szEvent) = 0;
  776. virtual void ClearTrackEvents() = 0;
  777. // Summary:
  778. // Gets the track events in the sequence.
  779. virtual int GetTrackEventsCount() const = 0;
  780. // Summary:
  781. // Gets the specified track event in the sequence.
  782. virtual char const* GetTrackEvent(int iIndex) const = 0;
  783. virtual IAnimStringTable* GetTrackEventStringTable() = 0;
  784. // Summary:
  785. // Called to trigger a track event.
  786. virtual void TriggerTrackEvent(const char* event, const char* param = NULL) = 0;
  787. //! Track event listener
  788. virtual void AddTrackEventListener(ITrackEventListener* pListener) = 0;
  789. virtual void RemoveTrackEventListener(ITrackEventListener* pListener) = 0;
  790. // return the sequence type - legacy or new component entity
  791. virtual SequenceType GetSequenceType() const = 0;
  792. // Expanded state interface
  793. virtual void SetExpanded(bool expanded) = 0;
  794. virtual bool GetExpanded() const = 0;
  795. virtual unsigned int GetUniqueTrackIdAndGenerateNext() = 0;
  796. // </interfuscator:shuffle>
  797. };
  798. /** Movie Listener interface.
  799. Register at movie system to get notified about movie events
  800. */
  801. struct IMovieListener
  802. {
  803. enum EMovieEvent
  804. {
  805. eMovieEvent_Started = 0, // fired when sequence is started
  806. eMovieEvent_Stopped, // fired when sequence ended normally
  807. eMovieEvent_Aborted, // fired when sequence was aborted before normal end (STOP and ABORTED event are mutually exclusive!)
  808. eMovieEvent_Updated, // fired after sequence time or playback speed was updated
  809. eMovieEvent_RecordModeStarted, // fired when Record Mode is started
  810. eMovieEvent_RecordModeStopped, // fired when Record Mode is stopped
  811. };
  812. // <interfuscator:shuffle>
  813. virtual ~IMovieListener(){}
  814. //! callback on movie events
  815. virtual void OnMovieEvent(EMovieEvent movieEvent, IAnimSequence* pAnimSequence) = 0;
  816. // </interfuscator:shuffle>
  817. };
  818. /** Movie System interface.
  819. Main entrance point to engine movie capability.
  820. Enumerate available movies, update all movies, create animation nodes and tracks.
  821. */
  822. struct IMovieSystem
  823. {
  824. AZ_TYPE_INFO_WITH_NAME_DECL(IMovieSystem);
  825. AZ_RTTI_NO_TYPE_INFO_DECL();
  826. enum ESequenceStopBehavior
  827. {
  828. eSSB_LeaveTime = 0, // When sequence is stopped it remains in last played time.
  829. eSSB_GotoEndTime = 1, // Default behavior in game, sequence is animated at end time before stop.
  830. eSSB_GotoStartTime = 2, // Default behavior in editor, sequence is animated at start time before stop.
  831. };
  832. // <interfuscator:shuffle>
  833. virtual ~IMovieSystem(){}
  834. //! Release movie system.
  835. virtual void Release() = 0;
  836. //! Set the user.
  837. virtual void SetUser(IMovieUser* pUser) = 0;
  838. //! Get the user.
  839. virtual IMovieUser* GetUser() = 0;
  840. virtual IAnimSequence* CreateSequence(const char* sequence, bool bLoad = false, uint32 id = 0, SequenceType = kSequenceTypeDefault, AZ::EntityId entityId = AZ::EntityId()) = 0;
  841. virtual void AddSequence(IAnimSequence* sequence) = 0;
  842. virtual void RemoveSequence(IAnimSequence* sequence) = 0;
  843. virtual IAnimSequence* FindLegacySequenceByName(const char* sequence) const = 0;
  844. virtual IAnimSequence* FindSequence(const AZ::EntityId& componentEntitySequenceId) const = 0;
  845. virtual IAnimSequence* FindSequenceById(uint32 id) const = 0;
  846. virtual IAnimSequence* GetSequence(int i) const = 0;
  847. virtual int GetNumSequences() const = 0;
  848. virtual IAnimSequence* GetPlayingSequence(int i) const = 0;
  849. virtual int GetNumPlayingSequences() const = 0;
  850. virtual bool IsCutScenePlaying() const = 0;
  851. virtual uint32 GrabNextSequenceId() = 0;
  852. // called whenever a new sequence Id is set - to update nextSequenceId
  853. virtual void OnSetSequenceId(uint32 sequenceId) = 0;
  854. //////////////////////////////////////////////////////////////////////////
  855. //
  856. // If the name of a sequence changes, the keys that refer it in the
  857. // sequence track of the director node should be properly updated also.
  858. //
  859. // @param before The old name of the sequence.
  860. // @param after The new name of the sequence.
  861. // @return Number of modified sequence keys.
  862. //
  863. //////////////////////////////////////////////////////////////////////////
  864. virtual int OnSequenceRenamed(const char* before, const char* after) = 0;
  865. //////////////////////////////////////////////////////////////////////////
  866. //
  867. // If the name of a camera changes, the keys that refer it in the
  868. // camera track of the director node should be properly updated also.
  869. // This updates the name of the corresponding camera node also, if any.
  870. //
  871. // @param before The old name of the camera.
  872. // @param after The new name of the camera.
  873. // @return Number of modified camera keys.
  874. //
  875. //////////////////////////////////////////////////////////////////////////
  876. virtual int OnCameraRenamed(const char* before, const char* after) = 0;
  877. // Adds a listener to a sequence
  878. // @param sequence Pointer to sequence
  879. // @param pListener Pointer to an IMovieListener
  880. // @return true on successful add, false otherwise
  881. virtual bool AddMovieListener(IAnimSequence* sequence, IMovieListener* pListener) = 0;
  882. // Removes a listener from a sequence
  883. // @param sequence Pointer to sequence
  884. // @param pListener Pointer to an IMovieListener
  885. // @return true on successful removal, false otherwise
  886. virtual bool RemoveMovieListener(IAnimSequence* sequence, IMovieListener* pListener) = 0;
  887. virtual ISystem* GetSystem() = 0;
  888. // Remove all sequences from movie system.
  889. virtual void RemoveAllSequences() = 0;
  890. //////////////////////////////////////////////////////////////////////////
  891. // Sequence playback.
  892. //////////////////////////////////////////////////////////////////////////
  893. // Start playing sequence.
  894. // Call ignored if sequence is already playing.
  895. // @param sequence Name of sequence to play.
  896. virtual void PlaySequence(const char* pSequenceName, IAnimSequence* pParentSeq, bool bResetFX, bool bTrackedSequence, float startTime = -FLT_MAX, float endTime = -FLT_MAX) = 0;
  897. // Start playing sequence.
  898. // Call ignored if sequence is already playing.
  899. // @param sequence Pointer to Valid sequence to play.
  900. virtual void PlaySequence(IAnimSequence* sequence, IAnimSequence* pParentSeq, bool bResetFX, bool bTrackedSequence, float startTime = -FLT_MAX, float endTime = -FLT_MAX) = 0;
  901. // Stops currently playing sequence.
  902. // Ignored if sequence is not playing.
  903. // Returns true if sequence has been stopped. false otherwise
  904. // @param sequence Name of playing sequence to stop.
  905. virtual bool StopSequence(const char* pSequenceName) = 0;
  906. // Stop's currently playing sequence.
  907. // Ignored if sequence is not playing.
  908. // Returns true if sequence has been stopped. false otherwise
  909. // @param sequence Pointer to Valid sequence to stop.
  910. virtual bool StopSequence(IAnimSequence* sequence) = 0;
  911. /** Aborts a currently playing sequence.
  912. Ignored if sequence is not playing.
  913. Calls IMovieListener with MOVIE_EVENT_ABORTED event (MOVIE_EVENT_DONE is NOT called)
  914. Returns true if sequence has been aborted. false otherwise
  915. @param sequence Pointer to Valid sequence to stop.
  916. @param bLeaveTime If false, uses default stop behavior, otherwise leaves the sequence at time
  917. */
  918. virtual bool AbortSequence(IAnimSequence* sequence, bool bLeaveTime = false) = 0;
  919. // Stops all currently playing sequences.
  920. virtual void StopAllSequences() = 0;
  921. // Stops all playing cut-scene sequences.
  922. // This will not stop all sequences, but only those with CUT_SCENE flag set.
  923. virtual void StopAllCutScenes() = 0;
  924. // Checks if specified sequence is playing.
  925. virtual bool IsPlaying(IAnimSequence* seq) const = 0;
  926. /** Resets playback state of movie system,
  927. usually called after loading of level,
  928. */
  929. virtual void Reset(bool bPlayOnReset, bool bSeekToStart) = 0;
  930. // Sequences with PLAY_ONRESET flag will start playing after this call.
  931. virtual void PlayOnLoadSequences() = 0;
  932. // Update movie system while not playing animation.
  933. virtual void StillUpdate() = 0;
  934. // Updates movie system every frame before the entity system to animate all playing sequences.
  935. virtual void PreUpdate(const float dt) = 0;
  936. // Updates movie system every frame after the entity system to animate all playing sequences.
  937. virtual void PostUpdate(const float dt) = 0;
  938. // Render function call of some special node.
  939. virtual void Render() = 0;
  940. // Set and enable Fixed Step cvars
  941. virtual void EnableFixedStepForCapture(float step) = 0;
  942. // Disable Fixed Step cvars and return to previous settings
  943. virtual void DisableFixedStepForCapture() = 0;
  944. // Signal the capturing start.
  945. virtual void StartCapture(const ICaptureKey& key, int frame) = 0;
  946. // Signal the capturing end.
  947. virtual void EndCapture() = 0;
  948. // Actually turn on/off the capturing.
  949. // This is needed for the timing issue of turning on/off the capturing.
  950. virtual void ControlCapture() = 0;
  951. // Returns true if a Render Output capture is currently active.
  952. virtual bool IsCapturing() const = 0;
  953. // Set movie system into recording mode,
  954. // While in recording mode any changes made to node will be added as keys to tracks.
  955. virtual void SetRecording(bool recording) = 0;
  956. virtual bool IsRecording() const = 0;
  957. // Pause any playing sequences.
  958. virtual void Pause() = 0;
  959. // Resume playing sequences.
  960. virtual void Resume() = 0;
  961. // Pause cut scenes in editor.
  962. virtual void PauseCutScenes() = 0;
  963. // Resume cut scenes in editor.
  964. virtual void ResumeCutScenes() = 0;
  965. // Callback when animation-data changes
  966. virtual void SetCallback(IMovieCallback* pCallback) = 0;
  967. virtual IMovieCallback* GetCallback() = 0;
  968. virtual AZ::EntityId GetActiveCamera() const = 0;
  969. virtual void SetActiveCamera(const AZ::EntityId& entityId) = 0;
  970. virtual void SendGlobalEvent(const char* pszEvent) = 0;
  971. // Gets the float time value for a sequence that is already playing
  972. virtual float GetPlayingTime(IAnimSequence* pSeq) = 0;
  973. virtual float GetPlayingSpeed(IAnimSequence* pSeq) = 0;
  974. // Sets the time progression of an already playing cut-scene.
  975. // If IAnimSequence:NO_SEEK flag is set on pSeq, this call is ignored.
  976. virtual bool SetPlayingTime(IAnimSequence* pSeq, float fTime) = 0;
  977. virtual bool SetPlayingSpeed(IAnimSequence* pSeq, float fSpeed) = 0;
  978. // Set behavior pattern for stopping sequences.
  979. virtual void SetSequenceStopBehavior(ESequenceStopBehavior behavior) = 0;
  980. // Set the start and end time of an already playing cutscene.
  981. virtual bool GetStartEndTime(IAnimSequence* pSeq, float& fStartTime, float& fEndTime) = 0;
  982. virtual bool SetStartEndTime(IAnimSequence* pSeq, const float fStartTime, const float fEndTime) = 0;
  983. // Make the specified sequence go to a given frame time.
  984. // @param seqName A sequence name.
  985. // @param targetFrame A target frame to go to in time.
  986. virtual void GoToFrame(const char* seqName, float targetFrame) = 0;
  987. // Get the name of camera used for sequences instead of cameras specified in the director node.
  988. virtual const char* GetOverrideCamName() const = 0;
  989. // Get behavior pattern for stopping sequences.
  990. virtual IMovieSystem::ESequenceStopBehavior GetSequenceStopBehavior() = 0;
  991. // These are used to disable 'Ragdollize' events in the editor when the 'AI/Physics' is off.
  992. virtual bool IsPhysicsEventsEnabled() const = 0;
  993. virtual void EnablePhysicsEvents(bool enable) = 0;
  994. virtual void EnableBatchRenderMode(bool bOn) = 0;
  995. virtual bool IsInBatchRenderMode() const = 0;
  996. virtual void LoadParamTypeFromXml(CAnimParamType& animParamType, const XmlNodeRef& xmlNode, const uint version) = 0;
  997. virtual void SaveParamTypeToXml(const CAnimParamType& animParamType, XmlNodeRef& xmlNode) = 0;
  998. // Should only be called from CAnimParamType
  999. virtual void SerializeParamType(CAnimParamType& animParamType, XmlNodeRef& xmlNode, bool bLoading, const uint version) = 0;
  1000. // For buffering and presenting user notification messages in the Editor. Will also print as an AZ_Warning()
  1001. virtual void LogUserNotificationMsg(const AZStd::string& msg) = 0;
  1002. virtual void ClearUserNotificationMsgs() = 0;
  1003. virtual const AZStd::string& GetUserNotificationMsgs() const = 0;
  1004. // Call this from OnActivate() when a new sequence component entity is activated.
  1005. virtual void OnSequenceActivated(IAnimSequence* sequence) = 0;
  1006. #ifdef MOVIESYSTEM_SUPPORT_EDITING
  1007. virtual AnimNodeType GetNodeTypeFromString(const char* pString) const = 0;
  1008. virtual CAnimParamType GetParamTypeFromString(const char* pString) const = 0;
  1009. #endif
  1010. // fill in the animNodeType from the xmlNode description (or vice versa)
  1011. virtual void SerializeNodeType(AnimNodeType& animNodeType, XmlNodeRef& xmlNode, bool bLoading, const uint version, int flags) = 0;
  1012. // </interfuscator:shuffle>
  1013. };