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.

69 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef VTFPREVIEWPANEL_H
  7. #define VTFPREVIEWPANEL_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. // VTF Preview panel
  21. //
  22. //-----------------------------------------------------------------------------
  23. class CVTFPreviewPanel : public vgui::Panel
  24. {
  25. DECLARE_CLASS_SIMPLE( CVTFPreviewPanel, vgui::Panel );
  26. public:
  27. // constructor
  28. CVTFPreviewPanel( vgui::Panel *pParent, const char *pName );
  29. virtual ~CVTFPreviewPanel();
  30. void SetVTF( const char *pFullPath, bool bLoadImmediately = true );
  31. const char *GetVTF() const;
  32. // Paints the texture
  33. virtual void Paint( void );
  34. private:
  35. void PaintNormalMapTexture( void );
  36. void PaintCubeTexture( void );
  37. void PaintStandardTexture( void );
  38. void PaintVolumeTexture( void );
  39. // Set up a projection matrix for a 90 degree fov
  40. void SetupProjectionMatrix( int nWidth, int nHeight );
  41. // Sets the camera to look at the the thing we're spinning around
  42. void LookAt( const Vector &vecLookAt, float flRadius );
  43. // Draw a sphere
  44. void RenderSphere( const Vector &vCenter, float flRadius, int nTheta, int nPhi );
  45. CUtlString m_VTFName;
  46. CTextureReference m_PreviewTexture;
  47. CMaterialReference m_PreviewMaterial;
  48. int m_nTextureID;
  49. Vector m_vecCameraDirection;
  50. float m_flLastRotationTime;
  51. };
  52. #endif // VTFPREVIEWPANEL_H