Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HBhvAnimation.h
00001 //
00002 // Copyright (c) 2000 by Tech Soft 3D, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft 3D shall pursue its civil
00006 // and criminal remedies in the event of unauthorized use or misappropriation
00007 // of its trade secrets.  Use of this information by anyone other than
00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 // $Id: 11aa2a544c3ad0ce6a27f1dfef56fcf19a5aad52 $
00013 //
00014 #ifndef _H_HBhvAnimation_H
00015 #define _H_HBhvAnimation_H
00016 
00017 #ifdef H_PACK_8
00018 #pragma pack(push)
00019 #pragma pack(8)
00020 #endif
00021 
00022 #include "HTools.h"
00023 #include "HBhvUtility.h"
00024 #include "HEventListener.h"
00025 
00026 class HBhvBehaviorManager;
00027 class HBhvTimeline;
00028 class HBhvTimelineInstance;
00029 class HBhvInterpolator;
00030 class HBhvInterpolatorInstance;
00031 class HUtilityXMLGenerator;
00032 class HUtilityXMLTag;
00033 class HKeyframe;
00034 class HBhvTargetObject;
00035 class HBhvAnimationInstance;
00036 
00037 
00039 
00047 class MVO_API HBhvAnimation 
00048 {
00049 public:
00055     HBhvAnimation(const char *name, HBhvBehaviorManager * BehaviorManager, HBhvAnimation *parentanimation = 0);
00056 
00058     virtual ~HBhvAnimation();   
00059 
00061     virtual const char * GetType() { return "HBhvAnimation"; } 
00062 
00063     
00065     const char * GetName() { return m_Name; }
00066 
00068     void SetName(const char *name);
00069 
00072     virtual bool Animate(float currenttime);
00073 
00077     virtual bool Animate(float currenttime, float starttime);
00078 
00082     void DeleteKeyframe(int keyframe);
00083 
00087     void DuplicateNextOrPrevious(int keyframe, bool next);
00088 
00092     void Duplicate(int newkeyframe, int oldkeyframe);
00093 
00097     void PlotCurve(bool rotations);
00098 
00100     void AdjustToTick(int totalticks);
00101 
00103     virtual void Serialize(HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt);
00105     virtual void Serialize(HUtilityXMLGenerator *xmlgen);
00106 
00110     static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData);
00111 
00113     HBhvBehaviorManager * GetBehaviorManager() { return m_pBehaviorManager; }
00114 
00116     void SetBehaviorManager(HBhvBehaviorManager *behaviourmanager) { m_pBehaviorManager = behaviourmanager; }
00117 
00119     int GetFirstTick();
00120 
00122     int GetLastTick();
00123 
00126     int GetLoop() { return m_Loop; }
00127 
00131     void SetLoop(int loop) {  m_Loop = loop; }
00132 
00134     HBhvTimeline *GetTimeline() { return m_pTimeline; }
00135 
00138     void SetTimeline( HBhvTimeline *timeline);
00139  
00143     HBhvAnimation * CreateInstance();
00144 
00146     struct vlist_s * GetInterpolatorList() { return m_InterpolatorList; }
00147 
00149     struct vlist_s * GetChildAnimationList() { return m_ChildAnimationList; }
00150 
00152     HBhvInterpolator *GetInterpolator();
00153 
00156     void AddInterpolator(HBhvInterpolator *interpolator);
00157 
00160     void AddChildAnimation(HBhvAnimation *childanimation);
00161 
00163     HBhvAnimation *GetParentAnimation() { return m_pParentAnimation; }
00164  
00167     void SetDelay(int delay) { m_Delay = delay; }
00168 
00170     int  GetDelay() { return m_Delay; }
00171 
00173     HBhvTargetObject * GetTarget() { return m_Target; } 
00174 
00176     HBhvAnimation * GetInstancedAnimation() { return m_pInstancedAnimation; }
00177 
00180     void SetInstancedAnimation(HBhvAnimation *animation) { m_pInstancedAnimation = animation; CloneAnimation(); }
00181 
00183     void Reset();
00184 
00188     void SetTargetByPath(const char *targetpath);
00189 
00194     void SetTargetByPath(const char *name, const char *targetpath);
00195 
00197     void SetTarget(HBhvTargetObject *target);
00198  
00204     bool GetInterpolator(int time, int &interval, HKeyframe **keyframe);
00205 
00209     void SetDefaultActive(bool active) { m_bDefaultActive = active; }
00210 
00213     bool GetDefaultActive() { return m_bDefaultActive; }
00214 
00217     void SetCurrentlyRunning(bool running) { m_bCurrentlyRunning = running; }
00218 
00220     bool GetCurrentlyRunning() { return m_bCurrentlyRunning; }
00221 
00223     float GetCurrentTick(); 
00224     
00232     void AdjustKeyframe(int keyframe, int delta, bool doall = true, bool relative = false);
00233     
00237     void CleanWithoutDelete();
00238 
00239 
00241     bool ExecuteOnce() { return m_bExecuteOnce; }
00246     void SetExecuteOnce(bool once) {m_bExecuteOnce = once; }
00247 
00248     void Evaluate(float currenttick, bool &hasPos, HPoint &pos, bool &hasQuat, HQuat &quat, bool &hasScale, HPoint &scale);
00249 
00251     void SetTargetScaleMatrix(float * target_matrix);
00252 
00253     float * GetTargetScaleMatrix() { return m_TargetScaleMatrix; }
00254     
00255 protected:
00256 
00260     void SetInstanceOf(const char *name);
00261 
00265     virtual bool AnimateInternal(float currenttick);
00266 
00268     void CloneAnimation();
00269 
00271     virtual void SerializeTarget(HUtilityXMLTag *xmlt);
00272 
00273     HBhvAnimation*          m_pInstancedAnimation;              
00274     HBhvTimelineInstance*   m_pTimelineInstance;                
00275     char                    m_InstanceOf[BHV_MAX_NAME_LENGTH];  
00276     HBhvTargetObject*       m_Target;                           
00277     bool                    m_bCurrentlyRunning;                
00278     bool                    m_bDefaultActive;                   
00279     HBhvBehaviorManager*    m_pBehaviorManager;                 
00280     HBhvAnimation*          m_pParentAnimation;                 
00281     HBhvTimeline*           m_pTimeline;                        
00282     struct vlist_s*         m_InterpolatorList;                 
00283     struct vlist_s*         m_ChildAnimationList;               
00284     char                    m_Name[BHV_MAX_NAME_LENGTH];        
00285     int m_Loop; 
00286     int m_Delay;    
00287     bool                m_bExecuteOnce;         
00288     float                   m_TargetScaleMatrix[16];            
00289 };
00290  
00291  
00292 
00293 #ifdef H_PACK_8
00294 #pragma pack(pop)
00295 #endif
00296 
00297 #endif
00298 
00299 
00300