1 /* 2 Copyright (C) 2005-2007 Feeling Software Inc. 3 Portions of the code are: 4 Copyright (C) 2005-2007 Sony Computer Entertainment America 5 6 MIT License: http://www.opensource.org/licenses/mit-license.php 7 */ 8 9 /** 10 @file FCDAnimationClip.h 11 This file contains the FCDAnimationClip class. 12 */ 13 14 #ifndef _FCD_ANIMATION_CLIP_H_ 15 #define _FCD_ANIMATION_CLIP_H_ 16 17 class FCDocument; 18 class FCDAnimation; 19 class FCDAnimationCurve; 20 21 class FCDEntityInstance; 22 23 typedef FUTrackedList<FCDAnimationCurve> FCDAnimationCurveTrackList; /**< A dynamically-sized tracking array of animation curves. */ 24 25 #ifndef _FCD_ENTITY_H_ 26 #include "FCDocument/FCDEntity.h" 27 #endif // _FCD_ENTITY_H_ 28 29 #ifndef _FCD_ENTITY_INSTANCE_H_ 30 #include "FCDocument/FCDEntityInstance.h" 31 #endif // _FCD_ENTITY__INSTANCE_H_ 32 33 /** 34 A COLLADA animation clip. 35 36 Animation clips are used to group together animation segments. 37 Animation clips are typically used to form complex animation sequences 38 where all the curves should only be used simultaneously. 39 40 @ingroup FCDocument 41 */ 42 class FCOLLADA_EXPORT FCDAnimationClip : public FCDEntity 43 { 44 private: 45 DeclareObjectType(FCDEntity); 46 FCDAnimationCurveTrackList curves; 47 48 DeclareParameter(float, FUParameterQualifiers::SIMPLE, start, FC("Start Time")); 49 DeclareParameter(float, FUParameterQualifiers::SIMPLE, end, FC("End Time")); 50 DeclareParameterContainer(FCDEntityInstance, animations, FC("Animation Instances")); 51 StringList names; // names are supported on animation_instances 52 53 public: 54 /** Constructor. 55 @param document The COLLADA document that holds this animation clip. */ 56 FCDAnimationClip(FCDocument* document); 57 58 /** Destructor. */ 59 virtual ~FCDAnimationClip(); 60 61 /** Copies the animation clip entity into a clone. 62 The clone may reside in another document. 63 @param clone The empty clone. If this pointer is NULL, a new animation clip 64 will be created and you will need to release the returned pointer manually. 65 @param cloneChildren Whether to recursively clone this entity's children. 66 @return The clone. */ 67 virtual FCDEntity* Clone(FCDEntity* clone = NULL, bool cloneChildren = false) const; 68 69 /** Retrieves the entity type for this class. This function is part 70 of the FCDEntity class interface. 71 @return The entity type: IMAGE. */ GetType()72 virtual Type GetType() const { return ANIMATION_CLIP; } 73 74 /** Retrieves the list of curves that are used by this animation clip. 75 @return The list of curves for the clip. */ GetClipCurves()76 FCDAnimationCurveTrackList& GetClipCurves() { return curves; } GetClipCurves()77 const FCDAnimationCurveTrackList& GetClipCurves() const { return curves; } /**< See above. */ 78 79 /** Inserts an existing curve within this animation clip. 80 @param curve An animation curve to be used within this clip. */ 81 void AddClipCurve(FCDAnimationCurve* curve); 82 83 /** Retrieves the start time marker position for this animation clip. 84 When using the animation clip, all the animation curves will need 85 to be synchronized in order for the animation to start at the start time. 86 @return The start time marker position, in seconds. */ GetStart()87 float GetStart() const { return start; } 88 89 /** Sets the start time marker position for this animation clip. 90 @param _start The new start time marker position. */ SetStart(float _start)91 void SetStart(float _start) { start = _start; SetDirtyFlag(); } 92 93 /** Retrieves the end time marker position for this animation clip. 94 When using the animation clip, all the animation curves will need 95 to be synchronized in order for the animation to complete at the end time. 96 @return The end time marker position, in seconds. */ GetEnd()97 float GetEnd() const { return end; } 98 99 /** Sets the end time marker position for this animation clip. 100 @param _end The end time marker position. */ SetEnd(float _end)101 void SetEnd(float _end) { end = _end; SetDirtyFlag(); } 102 103 /** Retrieves the number of instanced animations within this animation clip. 104 @return The number of instanced animations. */ GetAnimationCount()105 inline size_t GetAnimationCount() const { return animations.size(); } 106 107 /** Retrieves a given animation instanced by this clip. 108 @param index The index of the animation to retrieve. 109 @return The animation object at the given index. */ GetAnimation(size_t index)110 inline FCDAnimation* GetAnimation(size_t index) const { FUAssert(GetAnimationCount() > index, return NULL); return (FCDAnimation*) animations[index]->GetEntity(); }; 111 112 /** Sets the name of the animation at a given index. 113 @param name The name to give the animation at the given index. 114 @param index The index of the animation that will get the new name. */ SetAnimationName(const fm::string & name,size_t index)115 inline void SetAnimationName(const fm::string& name, size_t index) { if (names.size() <= index) names.resize(index + 1); names[index] = name; } 116 117 /** Retrieves the name of the animation at a given index. 118 @param index The index of the animation. 119 @return The name of the animation. */ GetAnimationName(size_t index)120 inline fm::string GetAnimationName(size_t index) const { return names[index]; } 121 122 /** [INTERNAL] Adds an animation instance. 123 @return The empty animation instance. */ 124 FCDEntityInstance* AddInstanceAnimation(); 125 126 /** [INTERNAL] Adds an animation instance. 127 @param animation The animation to instance. 128 @return The animation instance. */ 129 FCDEntityInstance* AddInstanceAnimation(FCDAnimation* animation); 130 }; 131 132 #endif // _FCD_ANIMATION_CLIP_H_ 133 134