IMovieSystem.h 51 KB

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