W3DScene.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: W3DScene.h ///////////////////////////////////////////////////////////
  24. //
  25. // Scene manger for display using W3DDispaly. A scene manager can customize
  26. // the rendering process, culling, material passes ...
  27. //
  28. // Author: Colin Day, April 2001
  29. //
  30. ///////////////////////////////////////////////////////////////////////////////
  31. #pragma once
  32. #ifndef __W3DSCENE_H_
  33. #define __W3DSCENE_H_
  34. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  35. // USER INCLUDES //////////////////////////////////////////////////////////////
  36. #include "WW3D2/Scene.h"
  37. #include "WW3D2/RInfo.h"
  38. #include "WW3D2/Coltest.h"
  39. #include "WW3D2/lightenvironment.h"
  40. ///////////////////////////////////////////////////////////////////////////////
  41. // PROTOTYPES /////////////////////////////////////////////////////////////////
  42. ///////////////////////////////////////////////////////////////////////////////
  43. class W3DDynamicLight;
  44. class LightClass;
  45. class Drawable;
  46. enum CustomScenePassModes;
  47. class MaterialPassClass;
  48. class W3DShroudMaterialPassClass;
  49. class W3DMaskMaterialPassClass;
  50. //-----------------------------------------------------------------------------
  51. // RTS3DScene
  52. //-----------------------------------------------------------------------------
  53. /** Scene management for 3D RTS game */
  54. //-----------------------------------------------------------------------------
  55. class RTS3DScene : public SimpleSceneClass, public SubsystemInterface
  56. {
  57. public:
  58. RTS3DScene(); ///< RTSScene constructor
  59. ~RTS3DScene(); ///< RTSScene desctructor
  60. /// ray picking against objects in scene
  61. Bool castRay(RayCollisionTestClass & raytest, Bool testAll, Int collisionType);
  62. /// customizable renderer for the RTS3DScene
  63. virtual void Customized_Render( RenderInfoClass &rinfo );
  64. virtual void Visibility_Check(CameraClass * camera);
  65. virtual void Render(RenderInfoClass & rinfo);
  66. void setCustomPassMode (CustomScenePassModes mode) {m_customPassMode = mode;}
  67. CustomScenePassModes getCustomPassMode (void) {return m_customPassMode;}
  68. void Flush(RenderInfoClass & rinfo); //draw queued up models.
  69. /// Drawing control method
  70. void drawTerrainOnly(Bool draw) {m_drawTerrainOnly = draw;};
  71. /// Drawing control method
  72. void renderSpecificDrawables(RenderInfoClass &rinfo, Int numDrawables, Drawable **theDrawables) ;
  73. /// Lighting methods
  74. void addDynamicLight(W3DDynamicLight * obj);
  75. void removeDynamicLight(W3DDynamicLight * obj);
  76. RefRenderObjListIterator * createLightsIterator(void);
  77. void destroyLightsIterator(RefRenderObjListIterator * it);
  78. RefRenderObjListClass *getDynamicLights(void) {return &m_dynamicLightList;};
  79. W3DDynamicLight *getADynamicLight(void);
  80. void setGlobalLight(LightClass *pLight,Int lightIndex=0);
  81. LightEnvironmentClass &getDefaultLightEnv(void) {return m_defaultLightEnv;}
  82. void init() {}
  83. void update() {}
  84. void draw();
  85. void reset(){}
  86. void doRender(CameraClass * cam);
  87. protected:
  88. void renderOneObject(RenderInfoClass &rinfo, RenderObjClass *robj, Int localPlayerIndex);
  89. void updateFixedLightEnvironments(RenderInfoClass & rinfo);
  90. void flushTranslucentObjects(RenderInfoClass & rinfo);
  91. void flushOccludedObjects(RenderInfoClass & rinfo);
  92. void flagOccludedObjects(CameraClass * camera);
  93. void flushOccludedObjectsIntoStencil(RenderInfoClass & rinfo);
  94. void updatePlayerColorPasses(void);
  95. protected:
  96. RefRenderObjListClass m_dynamicLightList;
  97. Bool m_drawTerrainOnly;
  98. LightClass *m_globalLight[LightEnvironmentClass::MAX_LIGHTS]; ///< The global directional light (sun, moon) Applies to objects.
  99. LightClass *m_scratchLight; ///< a workspace for copying global lights and modifying // MLorenzen
  100. Vector3 m_infantryAmbient; ///<scene ambient modified to make infantry easier to see
  101. LightClass *m_infantryLight[LightEnvironmentClass::MAX_LIGHTS]; ///< The global direction light modified to make infantry easier to see.
  102. Int m_numGlobalLights; ///<number of global lights
  103. LightEnvironmentClass m_defaultLightEnv; ///<default light environment applied to objects without custom/dynamic lighting.
  104. LightEnvironmentClass m_foggedLightEnv; ///<default light environment applied to objects without custom/dynamic lighting.
  105. W3DShroudMaterialPassClass *m_shroudMaterialPass; ///< Custom render pass which applies shrouds to objects
  106. W3DMaskMaterialPassClass *m_maskMaterialPass; ///< Custom render pass applied to entire scene used to mask out pixels.
  107. MaterialPassClass *m_heatVisionMaterialPass; ///< Custom render passed applied on top of objects with heatvision effect.
  108. MaterialPassClass *m_heatVisionOnlyPass; ///< Custom render pass applied in place of regular pass on objects with heat vision effect.
  109. MaterialPassClass *m_frenzyMaterialPass; ///< Custom render pass applied in place of regular pass on objects with FRENZY effect.
  110. ///Custom rendering passes for each possible player color on the map
  111. MaterialPassClass *m_occludedMaterialPass[MAX_PLAYER_COUNT];
  112. CustomScenePassModes m_customPassMode; ///< flag used to force a non-standard rendering of scene.
  113. Int m_translucentObjectsCount; ///< number of translucent objects to render this frame.
  114. RenderObjClass **m_translucentObjectsBuffer; ///< queue of current frame's translucent objects.
  115. Int m_occludedObjectsCount; ///<number of objects in current frame that need special rendering because occluded.
  116. RenderObjClass **m_potentialOccluders; ///<objects which may block other objects from being visible
  117. RenderObjClass **m_potentialOccludees; ///<objects which may be blocked from visibility by other objects.
  118. RenderObjClass **m_nonOccludersOrOccludees; ///<objects which are neither bockers or blockees (small rocks, shrubs, etc.).
  119. Int m_numPotentialOccluders;
  120. Int m_numPotentialOccludees;
  121. Int m_numNonOccluderOrOccludee;
  122. CameraClass *m_camera;
  123. }; // end class RTS3DScene
  124. //-----------------------------------------------------------------------------
  125. // RTS2DScene
  126. //-----------------------------------------------------------------------------
  127. /** Scene management for 2D overlay on top of 3D scene */
  128. //-----------------------------------------------------------------------------
  129. class RTS2DScene : public SimpleSceneClass, public SubsystemInterface
  130. {
  131. public:
  132. RTS2DScene();
  133. ~RTS2DScene();
  134. /// customizable renderer for the RTS2DScene
  135. virtual void Customized_Render( RenderInfoClass &rinfo );
  136. void init() {}
  137. void update() {}
  138. void draw();
  139. void reset(){}
  140. void doRender(CameraClass * cam);
  141. protected:
  142. RenderObjClass *m_status;
  143. CameraClass *m_camera;
  144. }; // end class RTS2DScene
  145. //-----------------------------------------------------------------------------
  146. // RTS3DInterfaceScene
  147. //-----------------------------------------------------------------------------
  148. /** Scene management for 3D interface overlay on top of 3D scene */
  149. //-----------------------------------------------------------------------------
  150. class RTS3DInterfaceScene : public SimpleSceneClass
  151. {
  152. public:
  153. RTS3DInterfaceScene();
  154. ~RTS3DInterfaceScene();
  155. /// customizable renderer for the RTS3DInterfaceScene
  156. virtual void Customized_Render( RenderInfoClass &rinfo );
  157. protected:
  158. }; // end class RTS3DInterfaceScene
  159. #endif // end __W3DSCENE_H_