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.

158 lines
4.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef MDLPANEL_H
  7. #define MDLPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/Panel.h"
  12. #include "datacache/imdlcache.h"
  13. #include "materialsystem/MaterialSystemUtil.h"
  14. #include "matsys_controls/potterywheelpanel.h"
  15. #include "tier3/mdlutils.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. namespace vgui
  20. {
  21. class IScheme;
  22. }
  23. //
  24. struct MDLAnimEventState_t
  25. {
  26. int m_nEventSequence;
  27. float m_flPrevEventCycle;
  28. };
  29. //-----------------------------------------------------------------------------
  30. // MDL Viewer Panel
  31. //-----------------------------------------------------------------------------
  32. class CMDLPanel : public CPotteryWheelPanel
  33. {
  34. DECLARE_CLASS_SIMPLE( CMDLPanel, CPotteryWheelPanel );
  35. public:
  36. // constructor, destructor
  37. CMDLPanel( vgui::Panel *pParent, const char *pName );
  38. virtual ~CMDLPanel();
  39. // Overriden methods of vgui::Panel
  40. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  41. virtual void OnTick();
  42. virtual void Paint();
  43. // Sets the current mdl
  44. virtual void SetMDL( MDLHandle_t handle, void *pProxyData = NULL );
  45. virtual void SetMDL( const char *pMDLName, void *pProxyData = NULL );
  46. // Sets the camera to look at the model
  47. void LookAtMDL( );
  48. // Sets the current LOD
  49. void SetLOD( int nLOD );
  50. // Sets the current sequence
  51. void SetSequence( int nSequence, bool bResetSequence = false );
  52. // Set the pose parameters
  53. void SetPoseParameters( const float *pPoseParameters, int nCount );
  54. bool SetPoseParameterByName( const char *pszName, float fValue );
  55. // Set the overlay sequence layers
  56. void SetSequenceLayers( const MDLSquenceLayer_t *pSequenceLayers, int nCount );
  57. void SetCollsionModel( bool bVisible );
  58. void SetGroundGrid( bool bVisible );
  59. void SetWireFrame( bool bVisible );
  60. void SetLockView( bool bLocked );
  61. void SetSkin( int nSkin );
  62. void SetLookAtCamera( bool bLookAtCamera );
  63. void SetIgnoreDoubleClick( bool bState );
  64. void SetThumbnailSafeZone( bool bVisible );
  65. // Bounds.
  66. bool GetBoundingBox( Vector &vecBoundsMin, Vector &vecBoundsMax );
  67. bool GetBoundingSphere( Vector &vecCenter, float &flRadius );
  68. virtual void SetModelAnglesAndPosition( const QAngle &angRot, const Vector &vecPos );
  69. // Attached models.
  70. void SetMergeMDL( MDLHandle_t handle, void *pProxyData = NULL, int nSkin = -1 );
  71. MDLHandle_t SetMergeMDL( const char *pMDLName, void *pProxyData = NULL, int nSkin = -1 );
  72. int GetMergeMDLIndex( void *pProxyData );
  73. int GetMergeMDLIndex( MDLHandle_t handle );
  74. CMDL *GetMergeMDL(MDLHandle_t handle );
  75. void ClearMergeMDLs( void );
  76. virtual void SetupFlexWeights( void ) { return; }
  77. // Events
  78. void DoAnimationEvents();
  79. void DoAnimationEvents( CStudioHdr *pStudioHdr, int nSeqNum, float flTime, bool bNoLoop, MDLAnimEventState_t *pEventState );
  80. virtual void FireEvent( const char *pszEventName, const char *pszEventOptions );
  81. void ResetAnimationEventState( MDLAnimEventState_t *pEventState );
  82. protected:
  83. virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight ) OVERRIDE;
  84. struct MDLData_t
  85. {
  86. CMDL m_MDL;
  87. matrix3x4_t m_MDLToWorld;
  88. bool m_bDisabled;
  89. float m_flCycleStartTime;
  90. };
  91. MDLData_t m_RootMDL;
  92. CUtlVector<MDLData_t> m_aMergeMDLs;
  93. static const int MAX_SEQUENCE_LAYERS = 8;
  94. int m_nNumSequenceLayers;
  95. MDLSquenceLayer_t m_SequenceLayers[ MAX_SEQUENCE_LAYERS ];
  96. MDLAnimEventState_t m_EventState;
  97. MDLAnimEventState_t m_SequenceLayerEventState[ MAX_SEQUENCE_LAYERS ];
  98. private:
  99. // paint it!
  100. virtual void OnPaint3D();
  101. virtual void PrePaint3D( IMatRenderContext *pRenderContext ) { };
  102. virtual void PostPaint3D( IMatRenderContext *pRenderContext ) { };
  103. virtual void RenderingRootModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { };
  104. virtual void RenderingMergedModel( IMatRenderContext *pRenderContext, CStudioHdr *pStudioHdr, MDLHandle_t mdlHandle, matrix3x4_t *pWorldMatrix ) { };
  105. virtual IMaterial* GetOverrideMaterial( MDLHandle_t mdlHandle ) { return NULL; }
  106. void OnMouseDoublePressed( vgui::MouseCode code );
  107. void DrawCollisionModel();
  108. void UpdateStudioRenderConfig( void );
  109. CTextureReference m_DefaultEnvCubemap;
  110. CTextureReference m_DefaultHDREnvCubemap;
  111. bool m_bDrawCollisionModel : 1;
  112. bool m_bGroundGrid : 1;
  113. bool m_bLockView : 1;
  114. bool m_bWireFrame : 1;
  115. bool m_bLookAtCamera : 1;
  116. bool m_bIgnoreDoubleClick : 1;
  117. bool m_bThumbnailSafeZone : 1;
  118. float m_PoseParameters[ MAXSTUDIOPOSEPARAM ];
  119. };
  120. #endif // MDLPANEL_H