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.

80 lines
2.1 KiB

  1. //========= Copyright 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. //-----------------------------------------------------------------------------
  19. //
  20. // VMT Preview panel
  21. //
  22. //-----------------------------------------------------------------------------
  23. class CVMTPreviewPanel : public vgui::Panel
  24. {
  25. DECLARE_CLASS_SIMPLE( CVMTPreviewPanel, vgui::Panel );
  26. public:
  27. // constructor
  28. CVMTPreviewPanel( vgui::Panel *pParent, const char *pName );
  29. void SetVMT( const char *pMaterialName );
  30. const char *GetVMT() const;
  31. // Paints the texture
  32. virtual void Paint( void );
  33. // View it in 3D or 2D mode
  34. void DrawIn3DMode( bool b3DMode );
  35. private:
  36. // Two different preview methods
  37. void DrawSphere( void );
  38. void DrawRectangle( void );
  39. // Set up a projection matrix for a 90 degree fov
  40. void SetupProjectionMatrix( int nWidth, int nHeight );
  41. void SetupOrthoMatrix( int nWidth, int nHeight );
  42. // Sets the camera to look at the the thing we're spinning around
  43. void LookAt( const Vector &vecLookAt, float flRadius );
  44. // Sets up lighting state
  45. void SetupLightingState();
  46. // Draw a sphere
  47. void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi );
  48. // Draw sprite-card based materials
  49. void RenderSpriteCard( const Vector &vCenter, float flRadius );
  50. CUtlString m_VMTName;
  51. CMaterialReference m_Material;
  52. CTextureReference m_pLightmapTexture;
  53. CTextureReference m_DefaultEnvCubemap;
  54. Vector m_LightDirection;
  55. Color m_LightColor;
  56. float m_flLightIntensity;
  57. Vector m_vecCameraDirection;
  58. float m_flLastRotationTime;
  59. bool m_bDrawIn3DMode;
  60. };
  61. #endif // VMTPREVIEWPANEL_H