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.

170 lines
4.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef POTTERYWHEELPANEL_H
  7. #define POTTERYWHEELPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vgui_controls/EditablePanel.h"
  12. #include "materialsystem/MaterialSystemUtil.h"
  13. #include "tier2/camerautils.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. class IManipulator;
  18. class CPotteryWheelManip;
  19. class CBaseManipulator;
  20. class CTransformManipulator;
  21. class CDmxElement;
  22. namespace vgui
  23. {
  24. class IScheme;
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Pottery wheel Panel
  28. //-----------------------------------------------------------------------------
  29. class CPotteryWheelPanel : public vgui::EditablePanel
  30. {
  31. DECLARE_CLASS_SIMPLE( CPotteryWheelPanel, vgui::EditablePanel );
  32. public:
  33. // constructor, destructor
  34. CPotteryWheelPanel( vgui::Panel *pParent, const char *pName );
  35. virtual ~CPotteryWheelPanel();
  36. // Overriden methods of vgui::Panel
  37. virtual void ApplySettings( KeyValues *inResourceData );
  38. virtual void Init( int x, int y, int wide, int tall );
  39. virtual void Paint();
  40. virtual void OnKeyCodePressed ( vgui::KeyCode code );
  41. virtual void OnKeyCodeReleased( vgui::KeyCode code );
  42. virtual void OnMousePressed ( vgui::MouseCode code );
  43. virtual void OnMouseReleased( vgui::MouseCode code );
  44. virtual void OnCursorMoved( int x, int y );
  45. virtual void OnMouseWheeled( int delta );
  46. virtual void OnTick();
  47. virtual void OnMouseCaptureLost();
  48. // Sets the camera to look at the the thing we're spinning around
  49. void LookAt( const Vector &vecCenter, float flRadius );
  50. void LookAt( float flRadius );
  51. void ComputePanelPosition( const Vector &vecPosition, Vector2D *pPanelPos );
  52. void SetBackgroundColor( int r, int g, int b );
  53. void SetBackgroundColor( const Color& c );
  54. const Color& GetBackgroundColor() const;
  55. // Light probe
  56. void SetLightProbe( CDmxElement *pLightProbe );
  57. // Camera.
  58. int GetCameraFOV( void );
  59. void SetCameraFOV( float flFOV );
  60. void SetCameraPositionAndAngles( const Vector &vecPos, const QAngle &angDir, bool syncManipulators = true );
  61. void GetCameraPositionAndAngles( Vector &vecPos, QAngle &angDir );
  62. void SetCameraOffset( const Vector &vecOffset );
  63. void GetCameraOffset( Vector &vecOffset );
  64. void ResetCameraPivot( void );
  65. void ComputeCameraTransform( matrix3x4_t *pWorldToCamera );
  66. void UpdateCameraTransform();
  67. private:
  68. // Inherited classes must implement this
  69. virtual void OnPaint3D() = 0;
  70. protected:
  71. enum
  72. {
  73. MAX_LIGHT_COUNT = 4
  74. };
  75. struct LightInfo_t
  76. {
  77. LightDesc_t m_Desc;
  78. matrix3x4_t m_LightToWorld;
  79. };
  80. enum ManipulationMode_t
  81. {
  82. CAMERA_ROTATE,
  83. CAMERA_TRANSLATE,
  84. CAMERA_ZOOM,
  85. LIGHT_MODE,
  86. };
  87. virtual void EnterManipulationMode( ManipulationMode_t manipMode, bool bMouseCapture = true, vgui::MouseCode mouseCode = vgui::MouseCode( -1 ) );
  88. void Select();
  89. void AcceptManipulation( bool bReleaseMouseCapture = true );
  90. void CancelManipulation();
  91. void EnableMouseCapture( bool enable, vgui::MouseCode code = vgui::MouseCode( -1 ) );
  92. bool WarpMouse( int &x, int &y );
  93. IManipulator *m_pCurrentManip;
  94. int m_nManipStartX, m_nManipStartY;
  95. int m_nClickStartX, m_nClickStartY;
  96. // Re-apply the manipulators on a new model
  97. void ApplyManipulation();
  98. // Synchronize the manipulators with the current transform
  99. void SyncManipulation();
  100. bool HasLightProbe() const;
  101. ITexture *GetLightProbeCubemap( bool bHDR );
  102. void DrawGrid();
  103. CMaterialReference m_Wireframe;
  104. bool m_bRenderToTexture;
  105. virtual void SetupRenderState( int nDisplayWidth, int nDisplayHeight );
  106. private:
  107. void CreateDefaultLights();
  108. void DestroyLights();
  109. void ParseLightsFromKV( KeyValues *pLightsKV );
  110. CMaterialReference m_LightProbeBackground;
  111. CMaterialReference m_LightProbeHDRBackground;
  112. CTextureReference m_LightProbeCubemap;
  113. CTextureReference m_LightProbeHDRCubemap;
  114. Camera_t m_Camera;
  115. matrix3x4_t m_CameraPivot;
  116. int m_nLightCount;
  117. LightInfo_t m_Lights[MAX_LIGHT_COUNT];
  118. Vector4D m_vecAmbientCube[6];
  119. Color m_ClearColor;
  120. Vector m_vecCameraOffset;
  121. CTransformManipulator *m_pCameraRotate;
  122. CTransformManipulator *m_pCameraTranslate;
  123. CBaseManipulator *m_pCameraZoom;
  124. CPotteryWheelManip *m_pLightManip;
  125. vgui::MouseCode m_nCaptureMouseCode;
  126. int m_xoffset, m_yoffset;
  127. bool m_bHasLightProbe : 1;
  128. CPanelAnimationVar( bool, m_bUseParentBG, "useparentbg", "0" );
  129. };
  130. #endif // SIMPLEPOTTERYWHEELPANEL_H