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 // HConstantFrameRate.h: interface for the HConstantFrameRate class. 00011 // 00013 00018 #ifndef HCONSTANTFRAMERATE_H 00019 #define HCONSTANTFRAMERATE_H 00020 00021 #ifdef H_PACK_8 00022 #pragma pack(push) 00023 #pragma pack(8) 00024 #endif 00025 00026 #include "HTools.h" 00027 #include "hic_types.h" 00028 00029 class HTClient; 00030 00034 enum ConstFRType 00035 { 00036 ConstFRNoSimpType, 00037 ConstFRNoSimpAAType, 00038 ConstFRWireframeBBoxType, 00039 ConstFRSolidBBoxType, 00040 ConstFRWireframeType, 00041 ConstFRLodClampType, 00042 ConstFRLodThresholdType, 00043 ConstFRUserType, 00044 ConstFRExtentType 00045 }; 00046 00050 enum HActivityType 00051 { 00052 NoActivity, 00053 MovementActivity, 00054 CuttingPlaneActivity, 00055 GeneralActivity 00056 }; 00057 00058 00062 enum DetailChangeMode 00063 { 00064 NoDetailChange, 00065 AllowDetailChangeOnce, 00066 AllowDetailChange 00067 }; 00068 00069 00070 class HConstantFrameRate; 00071 00072 class HBaseView; 00073 00079 class MVO_API HConstFRSimpType 00080 { 00081 public: 00082 int m_SimpLevelMin; 00083 int m_SimpLevelMax; 00086 HConstFRSimpType() 00087 { 00088 m_SimpLevelMin=0; 00089 m_SimpLevelMax=0; 00090 } 00091 00096 HConstFRSimpType(int min, int max) 00097 { 00098 m_SimpLevelMin=min; 00099 m_SimpLevelMax=max; 00100 } 00101 virtual ~HConstFRSimpType() {} 00102 00103 virtual void Reset(HConstantFrameRate *pCfr) { 00104 UNREFERENCED(pCfr); 00105 } 00106 00107 00114 virtual void Set(HConstantFrameRate *pCfr, int SimpLevel) = 0; 00121 virtual void Update(HConstantFrameRate *pCfr, int SimpLevel); 00122 00124 virtual ConstFRType GetType() = 0; 00126 int GetMinSimpLevel() { return m_SimpLevelMin; }; 00128 int GetMaxSimpLevel() { return m_SimpLevelMax; }; 00129 00131 static HConstFRSimpType **CreateList(int size) { return new HConstFRSimpType *[size]; }; 00132 00133 }; 00134 00135 00141 class MVO_API HFrExtent : public HConstFRSimpType 00142 { 00143 public: 00145 HFrExtent() : HConstFRSimpType() { m_Multiplier = 5; m_bUseLOD = false; } 00146 00151 HFrExtent(int min, int max) : HConstFRSimpType(min,max) { m_Multiplier = 5; m_bUseLOD = false; } 00152 00153 virtual ~HFrExtent() {} 00159 void SetMultiplier(int mp) { m_Multiplier = mp; } 00166 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00172 void SetUseLod(bool ul) { m_bUseLOD = ul; } 00173 bool GetUseLod() const { return m_bUseLOD;} 00175 ConstFRType GetType() { return ConstFRExtentType; } 00182 static HConstFRSimpType * Create(int min, int max) {return new HFrExtent(min, max); }; 00183 00184 protected: 00185 int m_Multiplier; 00186 bool m_bUseLOD; 00187 }; 00188 00192 class MVO_API HFrNoSimpAA : public HConstFRSimpType 00193 { 00194 public: 00196 HFrNoSimpAA() : HConstFRSimpType(0, 1) {} 00197 00202 HFrNoSimpAA(int min, int max) : HConstFRSimpType(min,max) {}; 00203 00204 virtual ~HFrNoSimpAA() {} 00205 00213 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00215 ConstFRType GetType() { return ConstFRNoSimpAAType; } 00222 void Update(HConstantFrameRate *pCfr, int SimpLevel); 00223 00230 static HConstFRSimpType * Create(int min, int max) {return new HFrNoSimpAA(min, max); }; 00231 00232 }; 00233 00238 class MVO_API HFrNoSimp : public HConstFRSimpType 00239 { 00240 public: 00242 HFrNoSimp() : HConstFRSimpType(0, 1) {} 00247 HFrNoSimp(int min, int max) : HConstFRSimpType(min,max) {}; 00248 00249 virtual ~HFrNoSimp() {} 00250 00257 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00259 ConstFRType GetType() { return ConstFRNoSimpType; } 00260 00261 00268 static HConstFRSimpType * Create(int min, int max) {return new HFrNoSimp(min, max); }; 00269 00270 00271 }; 00272 00273 00278 class MVO_API HFrLodClamp : public HConstFRSimpType 00279 { 00280 public: 00282 HFrLodClamp() : HConstFRSimpType() { m_bSegmentSwitch = false; } 00287 HFrLodClamp(int min, int max) : HConstFRSimpType(min,max) {} 00288 00289 void Reset(HConstantFrameRate *pCfr); 00290 virtual ~HFrLodClamp() {} 00291 00300 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00302 ConstFRType GetType() { return ConstFRLodClampType; } 00309 static HConstFRSimpType * Create(int min, int max) {return new HFrLodClamp(min, max); }; 00310 void SetSegmentSwitch(bool ssl) { m_bSegmentSwitch = ssl; } 00311 bool m_bSegmentSwitch; 00312 00313 00314 }; 00315 00320 class MVO_API HFrLodThreshold : public HConstFRSimpType 00321 { 00322 public: 00324 HFrLodThreshold() : HConstFRSimpType() {} 00325 00330 HFrLodThreshold(int min, int max) : HConstFRSimpType(min,max) {} 00331 00332 virtual ~HFrLodThreshold() {} 00333 00340 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00342 ConstFRType GetType() { return ConstFRLodThresholdType; } 00349 static HConstFRSimpType * Create(int min, int max) {return new HFrLodThreshold(min, max); }; 00350 00351 }; 00352 00353 00358 class MVO_API HFrSolidBBox : public HConstFRSimpType 00359 { 00360 public: 00362 HFrSolidBBox() : HConstFRSimpType() {} 00367 HFrSolidBBox(int min, int max) : HConstFRSimpType(min,max) {} 00368 00369 virtual ~HFrSolidBBox() {} 00370 00377 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00379 ConstFRType GetType() { return ConstFRSolidBBoxType; } 00380 00382 static void RegisterCallbacks(); 00389 static HConstFRSimpType * Create(int min, int max) {return new HFrSolidBBox(min, max); }; 00390 00391 private: 00392 static void draw_solid_bbx_tree(HIC_Rendition *rendition, HIC_Segment_Info * geo3); 00393 static void draw_solid_bbx(HIC_Rendition *rendition, HIC_Segment_Info * geo3); 00394 00395 }; 00396 00401 class MVO_API HFrWireframeBBox : public HConstFRSimpType 00402 { 00403 public: 00405 HFrWireframeBBox() : HConstFRSimpType() {} 00406 00411 HFrWireframeBBox(int min, int max) : HConstFRSimpType(min,max) {} 00412 00413 virtual ~HFrWireframeBBox() {} 00414 00421 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00423 ConstFRType GetType() { return ConstFRWireframeBBoxType; } 00424 00426 static void RegisterCallbacks(); 00427 00428 00435 static HConstFRSimpType * Create(int min, int max) {return new HFrWireframeBBox(min, max); }; 00436 private: 00437 static void draw_wireframe_bbx(HIC_Rendition *rendition,HIC_Segment_Info * geo3); 00438 00439 }; 00440 00446 class MVO_API HFrWireframe : public HConstFRSimpType 00447 { 00448 public: 00449 00451 HFrWireframe() : HConstFRSimpType() {} 00452 00457 HFrWireframe(int min, int max) : HConstFRSimpType(min,max) {} 00458 00459 virtual ~HFrWireframe() {} 00460 00468 void Set(HConstantFrameRate *pCfr, int SimpLevel); 00469 00471 ConstFRType GetType() { return ConstFRWireframeType; } 00472 00479 static HConstFRSimpType * Create(int min, int max) {return new HFrWireframe(min, max); }; 00480 00481 }; 00482 00483 00485 00490 class MVO_API HConstantFrameRate 00491 { 00492 friend class HConstFRSimpType; 00493 friend class HFrNoSimp; 00494 public: 00499 HConstantFrameRate(HBaseView *view); 00500 virtual ~HConstantFrameRate(); 00501 00502 HBaseView* GetView() { return m_pHView; } 00509 void UpdateLevel(int SimpLevel, int SimpListPos); 00510 00511 protected: 00512 HBaseView *m_pHView; 00513 bool m_bConstFRActive; 00518 float m_TargetFrameRate; 00519 00524 HConstFRSimpType **m_pSimpList; 00525 00526 bool m_pOwnsList; 00527 00528 00529 int m_SimpLevel; 00530 int m_SimpListPos; 00532 int m_SimpListLength; 00537 DetailChangeMode m_SimplificationDecrease; 00538 DetailChangeMode m_SimplificationIncrease; 00539 DetailChangeMode m_SimplificationIncreaseOnIdle; 00541 int m_FrameRateCounter; 00546 DetailChangeMode m_DetailIncMode; 00547 DetailChangeMode m_DetailIncOnIdleMode; 00551 DetailChangeMode m_DetailDecMode; 00552 00553 float m_DeadZone; 00554 int m_lastupdown; 00558 bool m_bEmergencyDecrease; 00559 00563 HActivityType m_ActivityType; 00564 00570 void SetHoopsSimplificationOptions(int SimpLevel, int SimpListPos); 00571 00578 void AdjustListPointers(int &SimpLevel, int &SimpListPos); 00579 00580 00585 void AdjustDetail(float FrameRate); 00586 00587 00591 void StartTimer(); 00592 00596 void StopTimer(); 00597 00598 bool IsLowestDetail(); 00599 void ChangeDetail(int change, int *SimpLevel = 0, int *SimpListPos = 0); 00600 00601 00602 00603 public: 00604 00618 bool GetMode(HConstFRSimpType ***sd = 0L ,float *target_framerate = 0L, int *length = 0L); 00619 00629 void Init(float target_framerate=20.0, HConstFRSimpType **sd = 0, int length = 0, float deadzone =3.0); 00630 00633 void Shutdown(); 00634 00635 00636 bool GetActive() {return m_bConstFRActive;} 00643 void Watch(); 00644 00645 00652 void Start(); 00653 00658 void Stop(); 00659 00665 void IncreaseDetailTemp(); 00666 00672 bool ViewpointHasChanged(bool update = true); 00673 00678 void SetDetailIncMode (DetailChangeMode mode) {m_DetailIncMode=mode; m_SimplificationIncrease = mode;} 00679 void SetDetailIncOnIdleMode (DetailChangeMode mode) {m_DetailIncOnIdleMode=mode; m_SimplificationIncreaseOnIdle = mode;} 00680 00683 DetailChangeMode GetDetailIncMode () {return m_DetailIncMode; } 00684 00689 void SetDetailDecMode (DetailChangeMode mode) {m_DetailDecMode=mode; m_SimplificationDecrease = mode;} 00692 DetailChangeMode GetDetailDecMode () {return m_DetailDecMode; } 00695 void ResetListPointers() { m_SimpLevel=0; m_SimpListPos = 0; } 00696 00698 float GetTargetFrameRate() { return m_TargetFrameRate; } 00702 void SetTargetFrameRate( float framerate ) { m_TargetFrameRate = framerate;} 00707 void SetDeadZone( float deadzone ) { m_DeadZone = deadzone;} 00711 void SetEmergencyDetailDecrease( bool detaildecrease ) { m_bEmergencyDecrease = detaildecrease;} 00716 void SetActivityType(HActivityType at) { m_ActivityType = at; } 00717 00720 HActivityType GetActivityType() { return m_ActivityType;} 00721 int GetSimpLevel() { return m_SimpLevel;} 00727 void AdjustLodOptions(); 00729 bool GetDetailIncreaseState() { return m_bIncreaseDetailTemp; } 00734 void SetDetailLevel ( int listpos, int simplevel) { m_SimpListPos = listpos; m_SimpLevel = simplevel; } 00735 00740 HConstFRSimpType * GetSimpType(ConstFRType stype); 00744 void SetSimpLevel(int simplevel) { m_SimpLevel = simplevel; } 00745 00748 void AdjustDefaultDetailLevelToModel(); 00749 00757 static bool Tick(float request_time, float actual_time, void * user_data); 00758 00759 void SetDisableIncreaseTemp(bool it) { m_bDisableIncreaseTemp = it; } 00760 void InitiateDelay() { m_bOneDelay = true; } 00761 int GetDetailLevelNum(); 00762 int GetTotalDetailLevelNum(); 00763 00764 void SetWatchActivity(bool wa) { m_bWatchActivity = wa; } 00765 void MajorDetailDecrease(); 00766 void MajorDetailIncrease(); 00767 00768 00769 private: 00770 bool m_bFullDetailTemp; 00771 bool m_bWatchActivity; 00772 bool m_bIncreaseDetailTemp; 00773 float m_oldPos[11]; 00774 HTClient * m_pUpdateTimerClient; 00775 bool m_bDisableIncreaseTemp; 00776 bool m_bOneDelay; 00777 float m_OneDelayStart; 00778 bool m_bAdjustNextTime; 00779 float m_AdjustTime; 00780 bool m_bIncrease; 00781 int m_CounterThreshold; 00782 int m_TempDetailIncrement; 00783 bool m_bFirstIncrease; 00784 00785 00786 }; 00787 00788 00789 #ifdef H_PACK_8 00790 #pragma pack(pop) 00791 #endif 00792 00793 #endif 00794 00795 00796 00797 00798 00799 00800 00801