Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HBhvBehaviorManager.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: 044719bad2d3156033df7d7158ffc98d2c2c4eab $
13 //
18 #ifndef _H_HBhvBehaviorManager_H
19 #define _H_HBhvBehaviorManager_H
20 
21 #ifdef H_PACK_8
22 #pragma pack(push)
23 #pragma pack(8)
24 #endif
25 
26 #include "HTools.h"
27 #include "HTManager.h"
28 #include "HBhvUtility.h"
29 #include "HBhvInterpolator.h"
30 
31 class HBhvTimeline;
32 class HBhvInterpolator;
33 class HBhvAnimation;
34 class HUtilityXMLGenerator;
35 class HUtilityXMLTag;
36 class HBaseModel;
37 
38 
40 class HBhvSensor;
41 class HBaseView;
42 
45 {
52 };
53 
54 
56 
86 class MVO_API HBhvTargetObject
87 {
88 public:
96  HBhvTargetObject(HBhvBehaviorManager *behaviourmanager, const char *name, const char *path, HPoint *pivot = 0);
97 
98 
100  const char *GetName() { return m_Name; }
101 
103  const char *GetPath() { return m_Path; }
104 
106  HC_KEY GetTargetKey();
107 
108  void SetTargetKey(HC_KEY key) { m_key = key; }
109 
111  const char *GetResolvedPath() { return m_ResolvedPath; }
112 
115  const char *GetType() { return m_Type; }
116 
122  bool IsEqual(const char *target);
123 
125  HBhvCameraType GetCameraType() { return m_CameraType; }
126 
136  static void ResolveTarget(const char *in, char *result, char *targettype, HBaseModel *model, HBhvCameraType &ctype);
137 
138  static void CreateTargetString(const char *type, const char *path, char *result, bool addquotes = false);
149 
153  void SetPivot(HPoint pv) { m_Pivot = pv; }
154 
162  void SetCollision(bool collision) { m_bCollision = collision; }
163 
165  bool GetCollision() { return m_bCollision; }
166 
172  void SetPivot(float x, float y, float z) { m_Pivot.Set(x,y,z); }
173 
175  void GetPivot(HPoint &pv) { pv = m_Pivot; }
176 
178  HPoint * GetPivot() { return &m_Pivot; }
179 
184  void Serialize(HUtilityXMLGenerator *xmlgen);
185 
189  static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData);
190  /*
191  void CalculateAdjustedPosition(HBhvTargetObject *parent);
192  void AdjustChildTargets();
193  void AddChildTarget(HBhvTargetObject *child);
194  void GetTranslationFromMatrix(HPoint &t);
195  void AddRotationToMatrix(float rot[16], float outrot[16]);
196  void AddPositionToMatrix(HPoint &trans);
197  void SetConstraintPoint(float x, float y, float z) { m_constrainpoint.Set(x,y,z); }
198  void SetLimitAxis(float x, float y, float z) { m_limitaxis.Set(x,y,z); }
199  */
200 
203  void FlagForCollision() { m_bHasMoved = true; }
206  void ResetForCollision() { m_bHasMoved = false; }
208  bool HasMoved() { return m_bHasMoved; }
209  void SetSerializeFromKey( bool sfk ) { m_bSerializeFromKey = sfk; }
210 
211 
212 protected:
214  static void CollapseTarget(const char *target, char *collapsedtarget);
215 
216  char m_Name[MVO_SMALL_BUFFER_SIZE];
217  char m_Path[MVO_SEGMENT_PATHNAME_BUFFER];
218  char m_ResolvedPath[MVO_SEGMENT_PATHNAME_BUFFER];
219  char m_Type[MVO_SMALL_BUFFER_SIZE];
225  bool m_bHasMoved;
226 // struct vlist_s * m_ChildTargetList;
227 // HPoint m_limitaxis;
228 // HPoint m_constrainpoint;
229 // HBhvTargetObject* m_ParentTarget;
230  bool m_bSerializeFromKey;
231 };
232 
233 
234 
236 
241 class MVO_API HBhvBehaviorManager : public HTClient
242 {
243 public:
254  HBhvBehaviorManager(HBaseModel *model, int tps = 10, int delay = 0, const char *name = 0, const char *version = 0, const char *vendor = 0);
255  virtual ~HBhvBehaviorManager();
256 
260  void SetTicksPerSecond(int tps) { m_Tps = tps; }
263  int GetTicksPerSecond() { return m_Tps; }
264 
269  void Serialize(HUtilityXMLGenerator *xmlgen);
270 
276  void ScheduleAnimation(HBhvAnimation* animation, float currenttime);
277 
287  HBhvAnimation * AddAnimation(const char *name, const char *target , HBhvTimeline *timeline, HBhvInterpolator *interpolator);
288 
293  void AddAnimation(HBhvAnimation *animation);
294 
299  virtual bool Tick( float request_time, float actual_time );
300 
303  vlist_s * GetAnimationList() { return m_AnimationList; }
304 
305 
309  int GetFreeName();
310 
312  void DeleteAllAnimations();
313 
321  HBhvAnimation * FindAnimation(const char *target, const char *interpolatortype);
322 
328  HBhvAnimation * FindAnimationByName(const char *name);
329 
333  void ScheduleAllAnimations(bool reset = false);
334 
339  void DeleteAnimation(HBhvAnimation *animation);
340 
349  HBhvTargetObject * CreateTargetObjectByPath(const char *name, const char *path);
350 
355  void AddTargetObject(HBhvTargetObject *targetobject);
356 
363  HBhvTargetObject * FindTargetObjectByName(const char *name);
364 
370  HBhvTargetObject * FindTargetObjectByPath(const char *path);
371 
376  void WriteToFile(const __wchar_t *filename);
377 #ifdef _MSC_VER
378  void WriteToFile(const unsigned short *filename);
379 #endif
380  void WriteToFile(const char *filename);
381 
387  static void ReadFromFile(HBaseModel *model, const __wchar_t *filename);
388 #ifdef _MSC_VER
389  static void ReadFromFile(HBaseModel *model, const unsigned short *filename);
390 #endif
391  static void ReadFromFile(HBaseModel *model, const char *filename);
392 
398  static void ProcessXMLData(HBaseModel *model, const char *buffer);
399 
403  static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData);
404 
406  HBaseModel * GetModel() { return m_pModel; }
407 
411  void SetCurrentTickByTime(float t) { m_CurrentTick = (t - m_StartTime) * m_Tps; }
412 
416  void SetCurrentTick(float tick);
417 
419  void SetCurrentTick();
420 
422  float GetCurrentTick() { return m_CurrentTick; }
423 
426  void SetCurrentTickByPercentage(float percentage);
427 
429  float GetCurrentTickByPercentage();
430 
432  void Rewind();
433 
435  bool IsPlaying() { return m_bPlaying; }
436 
438  HC_KEY GetActiveSceneKey();
439 
442  void SetActiveView(HBaseView *view);
443 
445  HBaseView * GetActiveView() { return m_pView; }
446 
448  bool GetRenderEveryTick() { return m_bRenderEveryFrame; }
449 
452  void SetRenderEveryTick(bool everytick) { m_bRenderEveryFrame = everytick; }
453 
455  bool GetUpdateCamera() { return m_bUpdateCamera; }
456 
458  bool IsAtFinalTick();
459 
462  void SetUpdateCamera(bool updatecamera) { m_bUpdateCamera = updatecamera; }
463 
469  int GetNextKeyframe(int ticknum, bool forward);
470 
473  void AddSensor(HBhvSensor *sensor);
474 
477  void RemoveScheduledAnimation(HBhvAnimation *animation);
478 
480  bool HasAnimations();
481 
483  int GetLastTick();
484 
488  HBhvSensor * FindSensorByName(const char *name);
489 
493  void ExecuteAnimations(float currenttick, float starttick);
494 
499  void SetContinuousPlay(bool cont) { m_bContinuousPlay = cont; }
500 
506  void SetInfinitePlay(bool inf) { m_bInfinitePlay = inf; }
507 
511  bool GetContinuousPlay() { return m_bContinuousPlay; }
512 
514  void CameraUpdated() { m_bCameraUpdated = true; }
515 
517  bool GetCameraUpdated() { return m_bCameraUpdated; }
518 
521  void Play();
522 
524  void Stop();
525 
527  void Continue();
528 
531  void SetPositionMatrix(float *mat) { for (int i=0;i<16;i++) m_positionmatrix[i] = mat[i]; }
533  void GetPositionMatrix(float *mat) { for (int i=0;i<16;i++) mat[i] = m_positionmatrix[i]; }
537  void SetTargetMatrix(float *mat) { for (int i=0;i<16;i++) m_targetmatrix[i] = mat[i]; }
540  void GetTargetMatrix(float *mat) { for (int i=0;i<16;i++) mat[i] = m_targetmatrix[i]; }
543  void SetFov(float fov) { m_fov = fov; }
545  void GetFov(float fov) { }
546 
548  void Reset();
549 
552  void DeactivateAllAnimations();
555  void ActivateAllAnimations();
560  void ActivateAnimationByName(const char *name, bool AllowPartial = true);
565  void DeactivateAnimationByName(const char *name, bool AllowPartial = true);
566 
567 
571  void SetStartTime(float time) { m_StartTime = time; }
572 
576  void SetMerge(bool merge) { m_bMerge = merge; }
578  bool GetMerge() { return m_bMerge; }
579 
585  HBhvAnimation * AddAnimation(const char *name, const char *targetpath, HPoint *pivot);
586 
594  void AddPositionKeyframe(const char *animname, int tick, HPoint pos, bool linear);
601  void AddQuatSquadKeyframe(const char *animname, int tick, HQuat rot, bool linear);
607  void AddMatrixKeyframe(const char *animname, int tick, float *matrix);
615  void AddSegmentMoveKeyframe(const char *animname, int tick, char *path);
626  void AddTrailKeyframe(const char *animname, int tick, HPoint pos, bool linear, TrailInterpolatorType *trailtype = 0, int *weight = 0, const char *style =0, const char *color = 0);
633  void AddAxisRotateKeyframe(const char *animname, int tick, float rot, HPoint *axis = 0);
640  void AddColorKeyframe(const char *animname, int tick, HPoint color, const char *colorcomponent = 0, const char *geomtype = 0);
645  void AddScaleKeyframe(const char *animname, int tick, HPoint scale);
651  void AddAttributeSwitchKeyframe(const char *animname, int tick, const char *att);
658  void AddVertexMorphInterpolator(const char *animname, int tick, const char *mident, bool discrete);
666  void AddColorMorphInterpolator(const char *animname, int tick, const char *mident, bool discrete);
672  void AddSegmentSwitchKeyframe(const char *animname, int tick, const char *ss);
678  void AddInstanceCreateKeyframe(const char *animname, int tick, const char *instance);
679 
688  void AddVertexMorphDataToAnimation(const char *animname, HPoint *md, int pnum, HBaseModel *model, int pos = -1);
697  void AddColorMorphDataToAnimation(const char *animname, HPoint *md, int pnum, HBaseModel *model, int pos = -1);
698 
699 
700 protected:
701 
705  void ResolveInstances();
706 
710  bool EvaluateCollision(HBhvTargetObject *tob);
716  HBhvInterpolator * AddKeyframe(const char *animname, const char *IntType, HKeyframe *keyframe, int tick);
717 
718  char m_Name[BHV_MAX_NAME_LENGTH];
719  char m_Version[BHV_MAX_VERSION_LENGTH];
720  char m_Vendor[BHV_MAX_VENDOR_LENGTH];
721  int m_Tps;
722  int m_Delay;
723  float m_StartTime;
727  struct vlist_s * m_AnimationList;
728  struct vlist_s * m_ScheduledAnimationList;
729  struct vlist_s * m_TargetObjectList;
730  struct vlist_s * m_SensorList;
733  bool m_bPlaying;
739  float m_positionmatrix[16];
740  float m_targetmatrix[16];
741  float m_fov;
743  bool m_bMerge;
745  bool m_bShellSelectionActive;
746 };
747 
748 
749 
750 #ifdef H_PACK_8
751 #pragma pack(pop)
752 #endif
753 
754 #endif
void SetStartTime(float time)
Definition: HBhvBehaviorManager.h:571
void SetCurrentTickByTime(float t)
Definition: HBhvBehaviorManager.h:411
void GetPositionMatrix(float *mat)
Definition: HBhvBehaviorManager.h:533
The HBhvTimeline class encpasulates an animation timeline.
Definition: HBhvTimeline.h:42
The HKeyframe class is the base class for all keyframe types.
Definition: HBhvUtility.h:260
const char * GetResolvedPath()
Definition: HBhvBehaviorManager.h:111
void SetMerge(bool merge)
Definition: HBhvBehaviorManager.h:576
int m_LastTick
Definition: HBhvBehaviorManager.h:725
The HQuat class defines the data type of a Quaternion.
Definition: HBhvUtility.h:86
const char * GetName()
Definition: HBhvBehaviorManager.h:100
const char * GetPath()
Definition: HBhvBehaviorManager.h:103
void SetPositionMatrix(float *mat)
Definition: HBhvBehaviorManager.h:531
bool m_bCollision
Definition: HBhvBehaviorManager.h:224
The HBhvBehaviorManager class stores and manages all animation related data.
Definition: HBhvBehaviorManager.h:241
bool m_bInfinitePlay
Definition: HBhvBehaviorManager.h:742
void GetPivot(HPoint &pv)
Definition: HBhvBehaviorManager.h:175
void FlagForCollision()
Definition: HBhvBehaviorManager.h:203
HBhvBehaviorManager * m_pBehaviorManager
Definition: HBhvBehaviorManager.h:221
HPoint m_Pivot
Definition: HBhvBehaviorManager.h:223
bool m_bHasMoved
Definition: HBhvBehaviorManager.h:225
#define HC_KEY
struct vlist_s * m_TargetObjectList
Definition: HBhvBehaviorManager.h:729
HBaseModel * GetModel()
Definition: HBhvBehaviorManager.h:406
#define BHV_MAX_NAME_LENGTH
Maximum Length of "Names" in animations.
Definition: HBhvUtility.h:44
bool m_bMerge
Definition: HBhvBehaviorManager.h:743
void CameraUpdated()
Definition: HBhvBehaviorManager.h:514
float m_fov
Definition: HBhvBehaviorManager.h:741
int m_Tps
Definition: HBhvBehaviorManager.h:721
void SetInfinitePlay(bool inf)
Definition: HBhvBehaviorManager.h:506
void GetTargetMatrix(float *mat)
Definition: HBhvBehaviorManager.h:540
Definition: HTManager.h:162
bool m_bContinuousPlay
Definition: HBhvBehaviorManager.h:737
int GetTicksPerSecond()
Definition: HBhvBehaviorManager.h:263
void SetRenderEveryTick(bool everytick)
Definition: HBhvBehaviorManager.h:452
vlist_s * GetAnimationList()
Definition: HBhvBehaviorManager.h:303
void ResetForCollision()
Definition: HBhvBehaviorManager.h:206
HPoint * GetPivot()
Definition: HBhvBehaviorManager.h:178
struct vlist_s * m_SensorList
Definition: HBhvBehaviorManager.h:730
int m_Delay
Definition: HBhvBehaviorManager.h:722
HBaseView * m_pView
Definition: HBhvBehaviorManager.h:734
The HBhvTargetObject class encapsulates various target types for animations and sensors.
Definition: HBhvBehaviorManager.h:86
There is no camera animation.
Definition: HBhvBehaviorManager.h:46
bool m_bCameraUpdated
Definition: HBhvBehaviorManager.h:738
The HBhvInterpolator class is the abstract base class for all interpolator types. ...
Definition: HBhvInterpolator.h:67
float GetCurrentTick()
Definition: HBhvBehaviorManager.h:422
The camera target is independently defined but works in conjunction with CameraPositionFree.
Definition: HBhvBehaviorManager.h:49
bool GetRenderEveryTick()
Definition: HBhvBehaviorManager.h:448
bool m_bRenderEveryFrame
Definition: HBhvBehaviorManager.h:735
The HBhvSensor class encapsulates an animation sensor.
Definition: HBhvSensor.h:38
bool GetContinuousPlay()
Definition: HBhvBehaviorManager.h:511
The HBaseModel class is used to store and manage model information.
Definition: HBaseModel.h:52
void SetPivot(float x, float y, float z)
Definition: HBhvBehaviorManager.h:172
void GetFov(float fov)
Definition: HBhvBehaviorManager.h:545
bool IsPlaying()
Definition: HBhvBehaviorManager.h:435
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
float m_CurrentTick
Definition: HBhvBehaviorManager.h:724
void SetFov(float fov)
Definition: HBhvBehaviorManager.h:543
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:337
HBhvCameraType m_CameraType
Definition: HBhvBehaviorManager.h:222
bool GetMerge()
Definition: HBhvBehaviorManager.h:578
Animation keyframe defines the camera target and position.
Definition: HBhvBehaviorManager.h:51
bool GetCameraUpdated()
Definition: HBhvBehaviorManager.h:517
The HBhvAnimation class defines an animation.
Definition: HBhvAnimation.h:47
bool GetUpdateCamera()
Definition: HBhvBehaviorManager.h:455
virtual bool Tick(float request_time, float actual_time)
Definition: HTManager.h:191
HBhvCameraType GetCameraType()
Definition: HBhvBehaviorManager.h:125
struct vlist_s * m_AnimationList
Definition: HBhvBehaviorManager.h:727
Animation is position driven. The target location is derived from the position location.
Definition: HBhvBehaviorManager.h:48
HBaseModel * m_pModel
Definition: HBhvBehaviorManager.h:732
bool m_bUpdateCamera
Definition: HBhvBehaviorManager.h:736
The camera position is independently defined but works in conjunction with CameraTargetFree.
Definition: HBhvBehaviorManager.h:50
HBhvCameraType
Definition: HBhvBehaviorManager.h:44
#define BHV_MAX_VENDOR_LENGTH
Maximum Length of "Vendor" string.
Definition: HBhvUtility.h:46
void SetContinuousPlay(bool cont)
Definition: HBhvBehaviorManager.h:499
bool m_bPlaying
Definition: HBhvBehaviorManager.h:733
float m_StartTime
Definition: HBhvBehaviorManager.h:723
HBaseView * GetActiveView()
Definition: HBhvBehaviorManager.h:445
Animation is target driven. The position location is derived from the target location.
Definition: HBhvBehaviorManager.h:47
void SetTicksPerSecond(int tps)
Definition: HBhvBehaviorManager.h:260
void SetCollision(bool collision)
Definition: HBhvBehaviorManager.h:162
struct vlist_s * m_ScheduledAnimationList
Definition: HBhvBehaviorManager.h:728
void SetPivot(HPoint pv)
Definition: HBhvBehaviorManager.h:153
bool GetCollision()
Definition: HBhvBehaviorManager.h:165
bool HasMoved()
Definition: HBhvBehaviorManager.h:208
void SetTargetMatrix(float *mat)
Definition: HBhvBehaviorManager.h:537
const char * GetType()
Definition: HBhvBehaviorManager.h:115
HC_KEY m_key
Definition: HBhvBehaviorManager.h:220
void SetUpdateCamera(bool updatecamera)
Definition: HBhvBehaviorManager.h:462
#define BHV_MAX_VERSION_LENGTH
Maximum Length of "Version" string.
Definition: HBhvUtility.h:45