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.

101 lines
2.6 KiB

  1. //====== Copyright � 1996-2003, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef VMTPREVIEWPANEL_H
  7. #define VMTPREVIEWPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/Panel.h"
  12. #include "tier1/utlstring.h"
  13. #include "materialsystem/MaterialSystemUtil.h"
  14. #include "mathlib/vector.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CSheetExtended;
  19. //-----------------------------------------------------------------------------
  20. //
  21. // VMT Preview panel
  22. //
  23. //-----------------------------------------------------------------------------
  24. class CVMTPreviewPanel : public vgui::Panel
  25. {
  26. DECLARE_CLASS_SIMPLE( CVMTPreviewPanel, vgui::Panel );
  27. public:
  28. // constructor
  29. CVMTPreviewPanel( vgui::Panel *pParent, const char *pName );
  30. void SetVMT( const char *pMaterialName );
  31. const char *GetVMT() const;
  32. CSheetExtended* GetSheet();
  33. IMaterial* GetMaterial();
  34. bool VMTUsesSheets();
  35. int GetSheetSequenceCount();
  36. int GetCurrentSequence();
  37. int GetCurrentSecondarySequence();
  38. int GetRealSequenceNumber();
  39. void SetSheetSequence( int nSequence );
  40. void SetSecondarySheetSequence( int nSequence );
  41. // Paints the texture
  42. virtual void Paint( void );
  43. // View it in 3D or 2D mode
  44. void DrawIn3DMode( bool b3DMode );
  45. void SetSheetPreviewSpeed( float flPreviewSpeed );
  46. private:
  47. // Two different preview methods
  48. void DrawSphere( void );
  49. void DrawRectangle( void );
  50. // Set up a projection matrix for a 90 degree fov
  51. void SetupProjectionMatrix( int nWidth, int nHeight );
  52. void SetupOrthoMatrix( int nWidth, int nHeight );
  53. // Sets the camera to look at the the thing we're spinning around
  54. void LookAt( const Vector &vecLookAt, float flRadius );
  55. // Sets up lighting state
  56. void SetupLightingState();
  57. // Draw a sphere
  58. void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi );
  59. // Draw sprite-card based materials
  60. void RenderSheet( const Vector &vCenter, float flRadius );
  61. CUtlString m_VMTName;
  62. CMaterialReference m_Material;
  63. CSheetExtended* m_pMaterialSheet;
  64. CTextureReference m_pLightmapTexture;
  65. CTextureReference m_DefaultEnvCubemap;
  66. Vector m_LightDirection;
  67. Color m_LightColor;
  68. float m_flLightIntensity;
  69. Vector m_vecCameraDirection;
  70. float m_flLastRotationTime;
  71. bool m_bDrawIn3DMode;
  72. float m_flLastSwitchTime;
  73. float m_flSheetPreviewSpeed;
  74. int m_nCurrentSheetSequence;
  75. int m_nCurrentSecondarySheetSequence;
  76. };
  77. #endif // VMTPREVIEWPANEL_H