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.

173 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef DMEPARTICLEPANEL_H
  8. #define DMEPARTICLEPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "matsys_controls/PotteryWheelPanel.h"
  13. #include "datamodel/dmattributetypes.h"
  14. #include "particles/particles.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class IMaterial;
  19. class CMeshBuilder;
  20. class Vector;
  21. class CParticleCollection;
  22. class CColorPickerButton;
  23. class CDmeParticleSystemDefinition;
  24. class CDmeParticleFunction;
  25. class CControlPointPage;
  26. namespace vgui
  27. {
  28. class ScrollBar;
  29. class IScheme;
  30. class PropertyPage;
  31. class PropertySheet;
  32. class Splitter;
  33. class Label;
  34. class TextEntry;
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Particle System Viewer Panel
  38. //-----------------------------------------------------------------------------
  39. class CParticleSystemPanel : public CPotteryWheelPanel
  40. {
  41. DECLARE_CLASS_SIMPLE( CParticleSystemPanel, CPotteryWheelPanel );
  42. public:
  43. // constructor, destructor
  44. CParticleSystemPanel( vgui::Panel *pParent, const char *pName );
  45. virtual ~CParticleSystemPanel();
  46. // Set the particle system to draw
  47. void SetParticleSystem( CDmeParticleSystemDefinition *pDef );
  48. void SetDmeElement( CDmeParticleSystemDefinition *pDef );
  49. CParticleCollection *GetParticleSystem();
  50. // Indicates that bounds should be drawn
  51. void RenderBounds( bool bEnable );
  52. // Indicates that cull sphere should be drawn
  53. void RenderCullBounds( bool bEnable );
  54. // Indicates that helpers should be drawn
  55. void RenderHelpers( bool bEnable );
  56. // Indicates which helper to draw
  57. void SetRenderedHelper( CDmeParticleFunction *pOp );
  58. virtual void OnTick();
  59. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  60. // Accessor for control point values
  61. const Vector& GetControlPointValue( int nControlPoint ) const;
  62. void SetControlPointValue( int nControlPoint, const Vector &value );
  63. private:
  64. // Shutdown, startup particle collection
  65. void StartupParticleCollection();
  66. void ShutdownParticleCollection();
  67. // Draw bounds
  68. void DrawBounds();
  69. void DrawCullBounds();
  70. // paint it!
  71. virtual void OnPaint3D();
  72. private:
  73. bool m_bRenderBounds : 1;
  74. bool m_bRenderCullBounds : 1;
  75. bool m_bRenderHelpers : 1;
  76. bool m_bPerformNameBasedLookup : 1;
  77. Vector m_pControlPointValue[MAX_PARTICLE_CONTROL_POINTS];
  78. DmObjectId_t m_RenderHelperId;
  79. float m_flLastTime;
  80. // Stores the id or name of the particle system being viewed
  81. DmObjectId_t m_ParticleSystemId;
  82. CUtlString m_ParticleSystemName;
  83. // The particle system to draw
  84. CParticleCollection *m_pParticleSystem;
  85. // A texture to use for a lightmap
  86. CTextureReference m_pLightmapTexture;
  87. // The default env_cubemap
  88. CTextureReference m_DefaultEnvCubemap;
  89. };
  90. //-----------------------------------------------------------------------------
  91. // Accessor for control point values
  92. //-----------------------------------------------------------------------------
  93. inline const Vector& CParticleSystemPanel::GetControlPointValue( int nControlPoint ) const
  94. {
  95. return m_pControlPointValue[nControlPoint];
  96. }
  97. inline void CParticleSystemPanel::SetControlPointValue( int nControlPoint, const Vector &value )
  98. {
  99. m_pControlPointValue[nControlPoint] = value;
  100. }
  101. //-----------------------------------------------------------------------------
  102. // This panel has a particle system viewer as well as controls
  103. //-----------------------------------------------------------------------------
  104. class CParticleSystemPreviewPanel : public vgui::EditablePanel
  105. {
  106. DECLARE_CLASS_SIMPLE( CParticleSystemPreviewPanel, vgui::EditablePanel );
  107. public:
  108. // constructor, destructor
  109. CParticleSystemPreviewPanel( vgui::Panel *pParent, const char *pName );
  110. virtual ~CParticleSystemPreviewPanel();
  111. // Set the material to draw
  112. void SetParticleSystem( CDmeParticleSystemDefinition *pDef );
  113. void SetParticleFunction( CDmeParticleFunction *pFunction );
  114. void SetDmeElement( CDmeParticleSystemDefinition *pDef );
  115. virtual void OnThink();
  116. private:
  117. MESSAGE_FUNC_PARAMS( OnCheckButtonChecked, "CheckButtonChecked", params );
  118. MESSAGE_FUNC_PARAMS( OnBackgroundColorChanged, "ColorPickerPicked", params );
  119. MESSAGE_FUNC_PARAMS( OnBackgroundColorPreview, "ColorPickerPreview", params );
  120. MESSAGE_FUNC_PARAMS( OnBackgroundColorCancel, "ColorPickerCancel", params );
  121. MESSAGE_FUNC( OnParticleSystemReconstructed, "ParticleSystemReconstructed" );
  122. vgui::Splitter *m_Splitter;
  123. CParticleSystemPanel *m_pParticleSystemPanel;
  124. vgui::PropertySheet *m_pControlSheet;
  125. vgui::PropertyPage *m_pRenderPage;
  126. CControlPointPage *m_pControlPointPage;
  127. vgui::CheckButton *m_pRenderCullBounds;
  128. vgui::CheckButton *m_pRenderBounds;
  129. vgui::CheckButton *m_pRenderHelpers;
  130. CColorPickerButton *m_pBackgroundColor;
  131. vgui::Label *m_pParticleCount;
  132. };
  133. #endif // DMEPARTICLEPANEL_H