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.

187 lines
5.5 KiB

  1. //====== Copyright � 1996-2005, 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 "mathlib/camera.h"
  14. //-----------------------------------------------------------------------------
  15. // Forward declarations
  16. //-----------------------------------------------------------------------------
  17. class IManipulator;
  18. class CPotteryWheelManip;
  19. class CBaseManipulator;
  20. class CTransformManipulator;
  21. class CRotationManipulator;
  22. class CTranslationManipulator;
  23. class CZoomManipulator;
  24. class CDmxElement;
  25. namespace vgui
  26. {
  27. class IScheme;
  28. }
  29. //-----------------------------------------------------------------------------
  30. // Pottery wheel Panel
  31. //-----------------------------------------------------------------------------
  32. class CPotteryWheelPanel : public vgui::EditablePanel
  33. {
  34. DECLARE_CLASS_SIMPLE( CPotteryWheelPanel, vgui::EditablePanel );
  35. public:
  36. // constructor, destructor
  37. CPotteryWheelPanel( vgui::Panel *pParent, const char *pName );
  38. virtual ~CPotteryWheelPanel();
  39. // Overriden methods of vgui::Panel
  40. virtual void Paint();
  41. virtual void RenderCapture();
  42. virtual void OnKeyCodePressed ( vgui::KeyCode code );
  43. virtual void OnKeyCodeReleased( vgui::KeyCode code );
  44. virtual void OnMousePressed ( vgui::MouseCode code );
  45. virtual void OnMouseDoublePressed( vgui::MouseCode code );
  46. virtual void OnMouseReleased( vgui::MouseCode code );
  47. virtual void OnCursorMoved( int x, int y );
  48. virtual void OnMouseWheeled( int delta );
  49. virtual void OnTick();
  50. virtual void OnMouseCaptureLost();
  51. // Sets the camera to look at the the thing we're spinning around
  52. void LookAt( const Vector &vecCenter, float flRadius );
  53. void LookAt( float flRadius );
  54. void ComputePanelPosition( const Vector &vecPosition, Vector2D *pPanelPos );
  55. void SetBackgroundColor( int r, int g, int b );
  56. void SetBackgroundColor( const Color& c );
  57. const Color& GetBackgroundColor() const;
  58. void SetGridColor( int r, int g, int b );
  59. // Light probe
  60. void SetLightProbe( CDmxElement *pLightProbe );
  61. // Simple light controls
  62. void ClearDirectionalLights();
  63. void AddDirectionalLight( const Color& color, const Vector& direction );
  64. void UpdateDirectionalLight( int idx, const Color& color, const Vector& direction );
  65. void SetLightAmbient( const Vector& ambient );
  66. // Camera.
  67. int GetCameraFOV( void );
  68. void SetCameraFOV( float flFOV );
  69. void SetCameraPositionAndAngles( const Vector &vecPos, const QAngle &angDir );
  70. void GetCameraPositionAndAngles( Vector &vecPos, QAngle &angDir );
  71. void SetCameraOffset( const Vector &vecOffset );
  72. void GetCameraOffset( Vector &vecOffset );
  73. void ResetCameraPivot( void );
  74. void ComputeCameraTransform( matrix3x4_t *pWorldToCamera );
  75. void UpdateCameraTransform();
  76. virtual void ResetView();
  77. // Allow the parent to be notified of mouse actions
  78. void SetParentMouseNotify( bool bParentMouseNotify );
  79. void EnableRenderingWithFlashlight( void *pvConfiguration );
  80. void * GetRenderingWithFlashlightConfiguration() const { return m_pvRenderingWithFlashlightConfiguration; }
  81. void SetSetupRenderStateDelayed( bool bDeferred ) { m_bSetupRenderStateDelayed = bDeferred; }
  82. void SetupRenderStateDelayed( ) { if ( m_bSetupRenderStateDelayed ) SetupRenderState( m_nRenderWidth, m_nRenderHeight ); }
  83. void SetRender3DSupersampled( bool bSupersampled ) { m_bRender3DSupersampled = bSupersampled; }
  84. protected:
  85. // Inherited classes must implement this
  86. virtual void OnPaint3D() = 0;
  87. bool IsPaint3dForRenderCapture() const { return m_bInRender3dForRenderCapture; }
  88. protected:
  89. enum ManipulationMode_t
  90. {
  91. CAMERA_ROTATE,
  92. CAMERA_TRANSLATE,
  93. CAMERA_ZOOM,
  94. LIGHT_MODE,
  95. };
  96. virtual void EnterManipulationMode( ManipulationMode_t manipMode, bool bMouseCapture = true, vgui::MouseCode mouseCode = vgui::MouseCode( -1 ) );
  97. void Select();
  98. void AcceptManipulation( bool bReleaseMouseCapture = true );
  99. void CancelManipulation();
  100. void EnableMouseCapture( bool enable, vgui::MouseCode code = vgui::MouseCode( -1 ) );
  101. bool WarpMouse( int &x, int &y );
  102. void CreateDefaultLights();
  103. MaterialLightingState_t m_LightingState;
  104. matrix3x4_t m_LightToWorld[MATERIAL_MAX_LIGHT_COUNT];
  105. IManipulator *m_pCurrentManip;
  106. int m_nManipStartX, m_nManipStartY;
  107. bool HasLightProbe() const;
  108. ITexture *GetLightProbeCubemap( bool bHDR );
  109. void DrawGrid();
  110. IMaterial *GetWireframeMaterial();
  111. Camera_t & GetCameraSettings() { return m_Camera; }
  112. private:
  113. void SetupRenderState( int nDisplayWidth, int nDisplayHeight );
  114. void DestroyLights();
  115. CMaterialReference m_Wireframe;
  116. CMaterialReference m_LightProbeBackground;
  117. CMaterialReference m_LightProbeHDRBackground;
  118. CTextureReference m_LightProbeCubemap;
  119. CTextureReference m_LightProbeHDRCubemap;
  120. Camera_t m_Camera;
  121. matrix3x4_t m_CameraPivot;
  122. Color m_ClearColor;
  123. Color m_GridColor;
  124. Vector m_vecCameraOffset;
  125. CRotationManipulator *m_pCameraRotate;
  126. CTranslationManipulator *m_pCameraTranslate;
  127. CZoomManipulator *m_pCameraZoom;
  128. CPotteryWheelManip *m_pLightManip;
  129. vgui::MouseCode m_nCaptureMouseCode;
  130. int m_xoffset, m_yoffset;
  131. bool m_bHasLightProbe : 1;
  132. bool m_bParentMouseNotify : 1;
  133. bool m_bSetupRenderStateDelayed : 1;
  134. bool m_bRender3DSupersampled : 1;
  135. bool m_bInRender3dForRenderCapture : 1;
  136. void * m_pvRenderingWithFlashlightConfiguration;
  137. int m_nRenderWidth, m_nRenderHeight;
  138. CPanelAnimationVar( bool, m_bUseParentBG, "useparentbg", "0" );
  139. };
  140. #endif // SIMPLEPOTTERYWHEELPANEL_H