Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MAPSTUDIOMODEL_H
  7. #define MAPSTUDIOMODEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "MapHelper.h"
  12. #include "StudioModel.h"
  13. class CRender2D;
  14. class CRender3D;
  15. class CMapStudioModel : public CMapHelper
  16. {
  17. public:
  18. //
  19. // Factories.
  20. //
  21. static CMapClass *CreateMapStudioModel(CHelperInfo *pHelperInfo, CMapEntity *pParent);
  22. static CMapStudioModel *CreateMapStudioModel(const char *pszModelPath, bool bOrientedBBox, bool bReversePitch);
  23. static void AdvanceAnimation(float flInterval);
  24. //
  25. // Construction/destruction:
  26. //
  27. CMapStudioModel(void);
  28. ~CMapStudioModel(void);
  29. DECLARE_MAPCLASS(CMapStudioModel,CMapHelper)
  30. void CalcBounds(BOOL bFullUpdate = FALSE);
  31. float GetBoundingRadius( void );
  32. virtual CMapClass *Copy(bool bUpdateDependencies);
  33. virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);
  34. void Initialize(void);
  35. void Render2D(CRender2D *pRender);
  36. void Render3D(CRender3D *pRender);
  37. void GetAngles(QAngle& pfAngles);
  38. void SetAngles(QAngle& fAngles);
  39. void OnParentKeyChanged(const char* szKey, const char* szValue);
  40. bool RenderPreload(CRender3D *pRender, bool bNewContext);
  41. int SerializeRMF(std::fstream &File, BOOL bRMF);
  42. int SerializeMAP(std::fstream &File, BOOL bRMF);
  43. static void SetRenderDistance(float fRenderDistance);
  44. static void EnableAnimation(BOOL bEnable);
  45. bool IsVisualElement(void) { return(true); }
  46. bool ShouldRenderLast();
  47. const char* GetDescription() { return("Studio model"); }
  48. int GetFrame(void);
  49. int GetMaxFrame(void);
  50. void SetFrame(int nFrame);
  51. int GetSequence(void);
  52. int GetSequenceCount(void);
  53. void GetSequenceName(int nIndex, char *szName);
  54. void SetSequence(int nIndex);
  55. const char *GetModelName(void);
  56. // Returns the index of the sequence (does a case-insensitive search).
  57. // Returns -1 if the sequence doesn't exist.
  58. int GetSequenceIndex( const char *pSequenceName ) const;
  59. protected:
  60. float ComputeFade( CRender3D *pRender );
  61. float ComputeScreenFade( CRender3D *pRender );
  62. float ComputeScreenFade( CRender3D *pRender, float flMinSize, float flMaxSize );
  63. float ComputeScreenFadeInternal( CRender3D *pRender, float flMinSize, float flMaxSize );
  64. float ComputeDistanceFade( CRender3D *pRender );
  65. float ComputeLevelFade( CRender3D *pRender );
  66. void GetRenderAngles(QAngle &Angles);
  67. //
  68. // Implements CMapAtom transformation functions.
  69. //
  70. void DoTransform(const VMatrix &matrix);
  71. inline void ReversePitch(bool bReversePitch);
  72. inline void SetOrientedBounds(bool bOrientedBounds);
  73. StudioModel *m_pStudioModel; // Pointer to a studio model in the model cache.
  74. QAngle m_Angles; // Euler angles of this studio model.
  75. float m_flPitch; // Pitch (stored separately for lights -- yuck!)
  76. bool m_bPitchSet;
  77. int m_Skin; // the model skin
  78. int m_BodyGroup; // Bodygroups
  79. bool m_bOrientedBounds; // Whether the bounding box should consider the orientation of the model.
  80. // Note that this is not a true oriented bounding box, but an axial box
  81. // indicating the extents of the oriented model.
  82. bool m_bReversePitch; // Lights negate pitch, so models representing light sources in Hammer
  83. // must do so as well.
  84. float m_flFadeScale; // Multiplied by distance to camera before calculating fade.
  85. float m_flFadeMinDist; // The distance/pixels at which this model is fully visible.
  86. float m_flFadeMaxDist; // The distance/pixels at which this model is fully invisible.
  87. Color m_ModelRenderColor;
  88. int m_iSolid; // The collision setting of this model: 0 = not solid, 2 = bounding box, 6 = vphysics
  89. //
  90. // Data that is common to all studio models.
  91. //
  92. static float m_fRenderDistance; // Distance beyond which studio models render as bounding boxes.
  93. static BOOL m_bAnimateModels; // Whether to animate studio models.
  94. };
  95. //-----------------------------------------------------------------------------
  96. // Purpose: Sets whether this object has an oriented or axial bounding box.
  97. // Note that this is not a true oriented bounding box, but an axial box
  98. // indicating the extents of the oriented model.
  99. //-----------------------------------------------------------------------------
  100. void CMapStudioModel::SetOrientedBounds(bool bOrientedBounds)
  101. {
  102. m_bOrientedBounds = bOrientedBounds;
  103. }
  104. //-----------------------------------------------------------------------------
  105. // Purpose: Sets whether this object negates pitch.
  106. //-----------------------------------------------------------------------------
  107. void CMapStudioModel::ReversePitch(bool bReversePitch)
  108. {
  109. m_bReversePitch = bReversePitch;
  110. }
  111. #endif // MAPSTUDIOMODEL_H