00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00010 #ifndef _H_HBhvAnimation_H 00011 #define _H_HBhvAnimation_H 00012 00013 #ifdef H_PACK_8 00014 #pragma pack(push) 00015 #pragma pack(8) 00016 #endif 00017 00018 #include "HTools.h" 00019 #include "HBhvUtility.h" 00020 #include "HEventListener.h" 00021 00022 class HBhvBehaviorManager; 00023 class HBhvTimeline; 00024 class HBhvTimelineInstance; 00025 class HBhvInterpolator; 00026 class HBhvInterpolatorInstance; 00027 class HUtilityXMLGenerator; 00028 class HUtilityXMLTag; 00029 class HKeyframe; 00030 class HBhvTargetObject; 00031 class HBhvAnimationInstance; 00032 00033 00035 00043 class MVO_API HBhvAnimation 00044 { 00045 public: 00051 HBhvAnimation(const char *name, HBhvBehaviorManager * BehaviorManager, HBhvAnimation *parentanimation = 0); 00052 00054 virtual ~HBhvAnimation(); 00055 00057 virtual const char * GetType() { return "HBhvAnimation"; } 00058 00059 00061 const char * GetName() { return m_Name; } 00062 00064 void SetName(const char *name); 00065 00068 virtual bool Animate(float currenttime); 00069 00073 virtual bool Animate(float currenttime, float starttime); 00074 00078 void DeleteKeyframe(int keyframe); 00079 00083 void DuplicateNextOrPrevious(int keyframe, bool next); 00084 00088 void Duplicate(int newkeyframe, int oldkeyframe); 00089 00093 void PlotCurve(bool rotations); 00094 00096 void AdjustToTick(int totalticks); 00097 00099 virtual void Serialize(HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt); 00101 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00102 00106 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00107 00109 HBhvBehaviorManager * GetBehaviorManager() { return m_pBehaviorManager; } 00110 00112 void SetBehaviorManager(HBhvBehaviorManager *behaviourmanager) { m_pBehaviorManager = behaviourmanager; } 00113 00115 int GetFirstTick(); 00116 00118 int GetLastTick(); 00119 00122 int GetLoop() { return m_Loop; } 00123 00127 void SetLoop(int loop) { m_Loop = loop; } 00128 00130 HBhvTimeline *GetTimeline() { return m_pTimeline; } 00131 00134 void SetTimeline( HBhvTimeline *timeline); 00135 00139 HBhvAnimation * CreateInstance(); 00140 00142 struct vlist_s * GetInterpolatorList() { return m_InterpolatorList; } 00143 00145 struct vlist_s * GetChildAnimationList() { return m_ChildAnimationList; } 00146 00148 HBhvInterpolator *GetInterpolator(); 00149 00152 void AddInterpolator(HBhvInterpolator *interpolator); 00153 00156 void AddChildAnimation(HBhvAnimation *childanimation); 00157 00159 HBhvAnimation *GetParentAnimation() { return m_pParentAnimation; } 00160 00163 void SetDelay(int delay) { m_Delay = delay; } 00164 00166 int GetDelay() { return m_Delay; } 00167 00169 HBhvTargetObject * GetTarget() { return m_Target; } 00170 00172 HBhvAnimation * GetInstancedAnimation() { return m_pInstancedAnimation; } 00173 00176 void SetInstancedAnimation(HBhvAnimation *animation) { m_pInstancedAnimation = animation; CloneAnimation(); } 00177 00179 void Reset(); 00180 00184 void SetTargetByPath(const char *targetpath); 00185 00190 void SetTargetByPath(const char *name, const char *targetpath); 00191 00193 void SetTarget(HBhvTargetObject *target); 00194 00200 bool GetInterpolator(int time, int &interval, HKeyframe **keyframe); 00201 00205 void SetDefaultActive(bool active) { m_bDefaultActive = active; } 00206 00209 bool GetDefaultActive() { return m_bDefaultActive; } 00210 00213 void SetCurrentlyRunning(bool running) { m_bCurrentlyRunning = running; } 00214 00216 bool GetCurrentlyRunning() { return m_bCurrentlyRunning; } 00217 00219 float GetCurrentTick(); 00220 00228 void AdjustKeyframe(int keyframe, int delta, bool doall = true, bool relative = false); 00229 00233 void CleanWithoutDelete(); 00234 00235 00237 bool ExecuteOnce() { return m_bExecuteOnce; } 00242 void SetExecuteOnce(bool once) {m_bExecuteOnce = once; } 00243 00244 void Evaluate(float currenttick, bool &hasPos, HPoint &pos, bool &hasQuat, HQuat &quat, bool &hasScale, HPoint &scale); 00245 00247 void SetTargetScaleMatrix(float const * target_matrix); 00248 00249 float * GetTargetScaleMatrix() { return m_TargetScaleMatrix; } 00250 00251 protected: 00252 00256 void SetInstanceOf(const char *name); 00257 00261 virtual bool AnimateInternal(float currenttick); 00262 00264 void CloneAnimation(); 00265 00267 virtual void SerializeTarget(HUtilityXMLTag *xmlt); 00268 00269 HBhvAnimation* m_pInstancedAnimation; 00270 HBhvTimelineInstance* m_pTimelineInstance; 00271 char m_InstanceOf[BHV_MAX_NAME_LENGTH]; 00272 HBhvTargetObject* m_Target; 00273 bool m_bCurrentlyRunning; 00274 bool m_bDefaultActive; 00275 HBhvBehaviorManager* m_pBehaviorManager; 00276 HBhvAnimation* m_pParentAnimation; 00277 HBhvTimeline* m_pTimeline; 00278 struct vlist_s* m_InterpolatorList; 00279 struct vlist_s* m_ChildAnimationList; 00280 char m_Name[BHV_MAX_NAME_LENGTH]; 00281 int m_Loop; 00282 int m_Delay; 00283 bool m_bExecuteOnce; 00284 float m_TargetScaleMatrix[16]; 00285 }; 00286 00287 00288 00289 #ifdef H_PACK_8 00290 #pragma pack(pop) 00291 #endif 00292 00293 #endif 00294 00295 00296