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: 4fca1593ab01e3ad75a7d3920ed3b3bac50c8496 $ 00013 // 00014 00015 // HConstantFrameRate.h: interface for the HConstantFrameRate class. 00016 // 00018 00023 #ifndef HCONSTANTFRAMERATE_H 00024 #define HCONSTANTFRAMERATE_H 00025 00026 #ifdef H_PACK_8 00027 #pragma pack(push) 00028 #pragma pack(8) 00029 #endif 00030 00031 #include "HTools.h" 00032 #include "hic_types.h" 00033 00034 class HTClient; 00035 00039 enum ConstFRType 00040 { 00041 ConstFRNoSimpType, 00042 ConstFRNoSimpAAType, 00043 ConstFRWireframeBBoxType, 00044 ConstFRSolidBBoxType, 00045 ConstFRWireframeType, 00046 ConstFRLodClampType, 00047 ConstFRLodThresholdType, 00048 ConstFRUserType, 00049 ConstFRExtentType 00050 }; 00051 00055 enum HActivityType 00056 { 00057 NoActivity, 00058 MovementActivity, 00059 CuttingPlaneActivity, 00060 GeneralActivity 00061 }; 00062 00063 00067 enum DetailChangeMode 00068 { 00069 NoDetailChange, 00070 AllowDetailChangeOnce, 00071 AllowDetailChange 00072 }; 00073 00074 00075 class HConstantFrameRate; 00076 00077 class HBaseView; 00078 00084 class MVO_API HConstFRSimpType 00085 { 00086 public: 00087 int m_SimpLevelMin; 00088 int m_SimpLevelMax; 00091 HConstFRSimpType() 00092 { 00093 m_SimpLevelMin=0; 00094 m_SimpLevelMax=0; 00095 } 00096 00101 HConstFRSimpType(int min, int max) 00102 { 00103 m_SimpLevelMin=min; 00104 m_SimpLevelMax=max; 00105 } 00106 virtual ~HConstFRSimpType() {} 00107 00108 virtual void Reset(HConstantFrameRate *pCfr) {} 00109 00110 00117 virtual void Set(HConstantFrameRate *pCfr, int SimpLevel) = 0; 00124 virtual void Update(HConstantFrameRate *pCfr, int SimpLevel); 00125 00127 virtual ConstFRType GetType() = 0; 00129 int GetMinSimpLevel() { return m_SimpLevelMin; }; 00131 int GetMaxSimpLevel() { return m_SimpLevelMax; }; 00132 00134 static HConstFRSimpType **CreateList(int size) { return (new HConstFRSimpType *[size]); }; 00135 00136 }; 00137 00138 00144 class MVO_API HFrExtent : public HConstFRSimpType 00145 { 00146 public: 00148 HFrExtent() : HConstFRSimpType() { m_Multiplier = 5; m_bUseLOD = false; } 00149 00154 HFrExtent(int min, int max) : HConstFRSimpType(min,max) { m_Multiplier = 5; m_bUseLOD = false; } 00155 00156 virtual ~HFrExtent() {} 00162 void SetMultiplier(int mp) { m_Multiplier = mp; } 00169 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00175 void SetUseLod(bool ul) { m_bUseLOD = ul; } 00176 bool GetUseLod() const { return m_bUseLOD;} 00178 ConstFRType GetType() { return ConstFRExtentType; } 00185 static HConstFRSimpType * Create(int min, int max) {return new HFrExtent(min, max); }; 00186 00187 protected: 00188 int m_Multiplier; 00189 bool m_bUseLOD; 00190 }; 00191 00195 class MVO_API HFrNoSimpAA : public HConstFRSimpType 00196 { 00197 public: 00199 HFrNoSimpAA() : HConstFRSimpType(0, 1) {} 00200 00205 HFrNoSimpAA(int min, int max) : HConstFRSimpType(min,max) {}; 00206 00207 virtual ~HFrNoSimpAA() {} 00208 00216 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00218 ConstFRType GetType() { return ConstFRNoSimpAAType; } 00225 void Update(HConstantFrameRate *pCfr, int SimpLevel); 00226 00233 static HConstFRSimpType * Create(int min, int max) {return new HFrNoSimpAA(min, max); }; 00234 00235 }; 00236 00241 class MVO_API HFrNoSimp : public HConstFRSimpType 00242 { 00243 public: 00245 HFrNoSimp() : HConstFRSimpType(0, 1) {} 00250 HFrNoSimp(int min, int max) : HConstFRSimpType(min,max) {}; 00251 00252 virtual ~HFrNoSimp() {} 00253 00260 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00262 ConstFRType GetType() { return ConstFRNoSimpType; } 00263 00264 00271 static HConstFRSimpType * Create(int min, int max) {return new HFrNoSimp(min, max); }; 00272 00273 00274 }; 00275 00276 00281 class MVO_API HFrLodClamp : public HConstFRSimpType 00282 { 00283 public: 00285 HFrLodClamp() : HConstFRSimpType() { m_bSegmentSwitch = false; } 00290 HFrLodClamp(int min, int max) : HConstFRSimpType(min,max) {} 00291 00292 void Reset(HConstantFrameRate *pCfr); 00293 virtual ~HFrLodClamp() {} 00294 00303 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00305 ConstFRType GetType() { return ConstFRLodClampType; } 00312 static HConstFRSimpType * Create(int min, int max) {return new HFrLodClamp(min, max); }; 00313 void SetSegmentSwitch(bool ssl) { m_bSegmentSwitch = ssl; } 00314 bool m_bSegmentSwitch; 00315 00316 00317 }; 00318 00323 class MVO_API HFrLodThreshold : public HConstFRSimpType 00324 { 00325 public: 00327 HFrLodThreshold() : HConstFRSimpType() {} 00328 00333 HFrLodThreshold(int min, int max) : HConstFRSimpType(min,max) {} 00334 00335 virtual ~HFrLodThreshold() {} 00336 00343 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00345 ConstFRType GetType() { return ConstFRLodThresholdType; } 00352 static HConstFRSimpType * Create(int min, int max) {return new HFrLodThreshold(min, max); }; 00353 00354 }; 00355 00356 00361 class MVO_API HFrSolidBBox : public HConstFRSimpType 00362 { 00363 public: 00365 HFrSolidBBox() : HConstFRSimpType() {} 00370 HFrSolidBBox(int min, int max) : HConstFRSimpType(min,max) {} 00371 00372 virtual ~HFrSolidBBox() {} 00373 00380 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00382 ConstFRType GetType() { return ConstFRSolidBBoxType; } 00383 00385 static void RegisterCallbacks(); 00392 static HConstFRSimpType * Create(int min, int max) {return new HFrSolidBBox(min, max); }; 00393 00394 private: 00395 static void draw_solid_bbx_tree(HIC_Rendition *rendition, HIC_Segment_Info * geo3); 00396 static void draw_solid_bbx(HIC_Rendition *rendition, HIC_Segment_Info * geo3); 00397 00398 }; 00399 00404 class MVO_API HFrWireframeBBox : public HConstFRSimpType 00405 { 00406 public: 00408 HFrWireframeBBox() : HConstFRSimpType() {} 00409 00414 HFrWireframeBBox(int min, int max) : HConstFRSimpType(min,max) {} 00415 00416 virtual ~HFrWireframeBBox() {} 00417 00424 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00426 ConstFRType GetType() { return ConstFRWireframeBBoxType; } 00427 00429 static void RegisterCallbacks(); 00430 00431 00438 static HConstFRSimpType * Create(int min, int max) {return new HFrWireframeBBox(min, max); }; 00439 private: 00440 static void draw_wireframe_bbx(HIC_Rendition *rendition,HIC_Segment_Info * geo3); 00441 00442 }; 00443 00449 class MVO_API HFrWireframe : public HConstFRSimpType 00450 { 00451 public: 00452 00454 HFrWireframe() : HConstFRSimpType() {} 00455 00460 HFrWireframe(int min, int max) : HConstFRSimpType(min,max) {} 00461 00462 virtual ~HFrWireframe() {} 00463 00471 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00472 00474 ConstFRType GetType() { return ConstFRWireframeType; } 00475 00482 static HConstFRSimpType * Create(int min, int max) {return new HFrWireframe(min, max); }; 00483 00484 }; 00485 00486 00488 00493 class MVO_API HConstantFrameRate 00494 { 00495 friend class HConstFRSimpType; 00496 friend class HFrNoSimp; 00497 public: 00502 HConstantFrameRate(HBaseView *view); 00503 virtual ~HConstantFrameRate(); 00504 00505 HBaseView* GetView( void ) { return m_pHView; } 00512 void UpdateLevel(int SimpLevel, int SimpListPos); 00513 00514 protected: 00515 HBaseView *m_pHView; 00516 bool m_bConstFRActive; 00521 float m_TargetFrameRate; 00522 00527 HConstFRSimpType **m_pSimpList; 00528 00529 bool m_pOwnsList; 00530 00531 00532 int m_SimpLevel; 00533 int m_SimpListPos; 00535 int m_SimpListLength; 00540 DetailChangeMode m_SimplificationDecrease; 00541 DetailChangeMode m_SimplificationIncrease; 00542 DetailChangeMode m_SimplificationIncreaseOnIdle; 00544 int m_FrameRateCounter; 00549 DetailChangeMode m_DetailIncMode; 00550 DetailChangeMode m_DetailIncOnIdleMode; 00554 DetailChangeMode m_DetailDecMode; 00555 00556 float m_DeadZone; 00557 int m_lastupdown; 00561 bool m_bEmergencyDecrease; 00562 00566 HActivityType m_ActivityType; 00567 00573 void SetHoopsSimplificationOptions(int SimpLevel, int SimpListPos); 00574 00581 void AdjustListPointers(int &SimpLevel, int &SimpListPos); 00582 00583 00588 void AdjustDetail(float FrameRate); 00589 00590 00594 void StartTimer(); 00595 00599 void StopTimer(); 00600 00601 bool IsLowestDetail(); 00602 void ChangeDetail(int change, int *SimpLevel = 0, int *SimpListPos = 0); 00603 00604 00605 00606 public: 00607 00621 bool GetMode(HConstFRSimpType ***sd = 0L ,float *target_framerate = 0L, int *length = 0L); 00622 00632 void Init(float target_framerate=20.0, HConstFRSimpType **sd = 0, int length = 0, float deadzone =3.0); 00633 00636 void Shutdown(); 00637 00638 00639 bool GetActive() {return m_bConstFRActive;} 00646 void Watch(); 00647 00648 00655 void Start(); 00656 00661 void Stop(); 00662 00668 void IncreaseDetailTemp(); 00669 00675 bool ViewpointHasChanged(bool update = true); 00676 00681 void SetDetailIncMode (DetailChangeMode mode) {m_DetailIncMode=mode; m_SimplificationIncrease = mode;} 00682 void SetDetailIncOnIdleMode (DetailChangeMode mode) {m_DetailIncOnIdleMode=mode; m_SimplificationIncreaseOnIdle = mode;} 00683 00686 DetailChangeMode GetDetailIncMode () {return m_DetailIncMode; } 00687 00692 void SetDetailDecMode (DetailChangeMode mode) {m_DetailDecMode=mode; m_SimplificationDecrease = mode;} 00695 DetailChangeMode GetDetailDecMode () {return m_DetailDecMode; } 00698 void ResetListPointers() { m_SimpLevel=0; m_SimpListPos = 0; } 00699 00701 float GetTargetFrameRate( void ) { return m_TargetFrameRate; } 00705 void SetTargetFrameRate( float framerate ) { m_TargetFrameRate = framerate;} 00710 void SetDeadZone( float deadzone ) { m_DeadZone = deadzone;} 00714 void SetEmergencyDetailDecrease( bool detaildecrease ) { m_bEmergencyDecrease = detaildecrease;} 00719 void SetActivityType(HActivityType at) { m_ActivityType = at; } 00720 00723 HActivityType GetActivityType() { return m_ActivityType;} 00724 int GetSimpLevel() { return m_SimpLevel;} 00730 void AdjustLodOptions(); 00732 bool GetDetailIncreaseState() { return m_bIncreaseDetailTemp; } 00737 void SetDetailLevel ( int listpos, int simplevel) { m_SimpListPos = listpos; m_SimpLevel = simplevel; } 00738 00743 HConstFRSimpType * GetSimpType(ConstFRType stype); 00747 void SetSimpLevel(int simplevel) { m_SimpLevel = simplevel; } 00748 00751 void AdjustDefaultDetailLevelToModel(); 00752 00760 static bool Tick(float request_time, float actual_time, void * user_data); 00761 00762 void SetDisableIncreaseTemp(bool it) { m_bDisableIncreaseTemp = it; } 00763 void InitiateDelay() { m_bOneDelay = true; } 00764 int GetDetailLevelNum(); 00765 int GetTotalDetailLevelNum(); 00766 00767 void SetWatchActivity(bool wa) { m_bWatchActivity = wa; } 00768 void MajorDetailDecrease(); 00769 void MajorDetailIncrease(); 00770 00771 00772 private: 00773 bool m_bFullDetailTemp; 00774 bool m_bWatchActivity; 00775 bool m_bIncreaseDetailTemp; 00776 float m_oldPos[11]; 00777 HTClient * m_pUpdateTimerClient; 00778 bool m_bDisableIncreaseTemp; 00779 bool m_bOneDelay; 00780 float m_OneDelayStart; 00781 bool m_bAdjustNextTime; 00782 float m_AdjustTime; 00783 bool m_bIncrease; 00784 int m_CounterThreshold; 00785 int m_TempDetailIncrement; 00786 bool m_bFirstIncrease; 00787 00788 00789 }; 00790 00791 00792 #ifdef H_PACK_8 00793 #pragma pack(pop) 00794 #endif 00795 00796 #endif 00797 00798 00799 00800 00801 00802 00803 00804