Team Fortress 2 Source Code as on 22/4/2020
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.

147 lines
4.5 KiB

  1. //========= Copyright 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. virtual CMapClass *Copy(bool bUpdateDependencies);
  32. virtual CMapClass *CopyFrom(CMapClass *pFrom, bool bUpdateDependencies);
  33. void Initialize(void);
  34. void Render2D(CRender2D *pRender);
  35. void Render3D(CRender3D *pRender);
  36. void GetAngles(QAngle& pfAngles);
  37. void SetAngles(QAngle& fAngles);
  38. void OnParentKeyChanged(const char* szKey, const char* szValue);
  39. bool RenderPreload(CRender3D *pRender, bool bNewContext);
  40. int SerializeRMF(std::fstream &File, BOOL bRMF);
  41. int SerializeMAP(std::fstream &File, BOOL bRMF);
  42. static void SetRenderDistance(float fRenderDistance);
  43. static void EnableAnimation(BOOL bEnable);
  44. bool IsVisualElement(void) { return(true); }
  45. bool ShouldRenderLast();
  46. const char* GetDescription() { return("Studio model"); }
  47. int GetFrame(void);
  48. void SetFrame(int nFrame);
  49. int GetSequence(void);
  50. int GetSequenceCount(void);
  51. void GetSequenceName(int nIndex, char *szName);
  52. void SetSequence(int nIndex);
  53. // Returns the index of the sequence (does a case-insensitive search).
  54. // Returns -1 if the sequence doesn't exist.
  55. int GetSequenceIndex( const char *pSequenceName ) const;
  56. protected:
  57. inline float ComputeFade( CRender3D *pRender ) const;
  58. inline float ComputeDistanceFade( CRender3D *pRender ) const;
  59. inline float ComputeScreenFade( CRender3D *pRender ) const;
  60. void GetRenderAngles(QAngle &Angles);
  61. //
  62. // Implements CMapAtom transformation functions.
  63. //
  64. void DoTransform(const VMatrix &matrix);
  65. inline void ReversePitch(bool bReversePitch);
  66. inline void SetOrientedBounds(bool bOrientedBounds);
  67. StudioModel *m_pStudioModel; // Pointer to a studio model in the model cache.
  68. QAngle m_Angles; // Euler angles of this studio model.
  69. float m_flPitch; // Pitch (stored separately for lights -- yuck!)
  70. bool m_bPitchSet;
  71. int m_Skin; // the model skin
  72. bool m_bOrientedBounds; // Whether the bounding box should consider the orientation of the model.
  73. // Note that this is not a true oriented bounding box, but an axial box
  74. // indicating the extents of the oriented model.
  75. bool m_bReversePitch; // Lights negate pitch, so models representing light sources in Hammer
  76. // must do so as well.
  77. bool m_bScreenSpaceFade; // If true, min & max dist are pixel size in screen space.
  78. float m_flFadeScale; // Multiplied by distance to camera before calculating fade.
  79. float m_flFadeMinDist; // The distance/pixels at which this model is fully visible.
  80. float m_flFadeMaxDist; // The distance/pixels at which this model is fully invisible.
  81. int m_iSolid; // The collision setting of this model: 0 = not solid, 2 = bounding box, 6 = vphysics
  82. //
  83. // Data that is common to all studio models.
  84. //
  85. static float m_fRenderDistance; // Distance beyond which studio models render as bounding boxes.
  86. static BOOL m_bAnimateModels; // Whether to animate studio models.
  87. };
  88. //-----------------------------------------------------------------------------
  89. // Purpose: Sets whether this object has an oriented or axial bounding box.
  90. // Note that this is not a true oriented bounding box, but an axial box
  91. // indicating the extents of the oriented model.
  92. //-----------------------------------------------------------------------------
  93. void CMapStudioModel::SetOrientedBounds(bool bOrientedBounds)
  94. {
  95. m_bOrientedBounds = bOrientedBounds;
  96. }
  97. //-----------------------------------------------------------------------------
  98. // Purpose: Sets whether this object negates pitch.
  99. //-----------------------------------------------------------------------------
  100. void CMapStudioModel::ReversePitch(bool bReversePitch)
  101. {
  102. m_bReversePitch = bReversePitch;
  103. }
  104. #endif // MAPSTUDIOMODEL_H