W3DPropBuffer.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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: W3DPropBuffer.h //////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: W3DPropBuffer.h
  36. //
  37. // Created: John Ahlquist, May 2001
  38. //
  39. // Desc: Draw buffer to handle all the props in a scene.
  40. //
  41. //-----------------------------------------------------------------------------
  42. #pragma once
  43. #ifndef __W3DPROP_BUFFER_H_
  44. #define __W3DPROP_BUFFER_H_
  45. //-----------------------------------------------------------------------------
  46. // Includes
  47. //-----------------------------------------------------------------------------
  48. #include "always.h"
  49. #include "rendobj.h"
  50. #include "w3d_file.h"
  51. #include "Lib/BaseType.h"
  52. #include "common/GameType.h"
  53. #include "Common/AsciiString.h"
  54. #include "common/GlobalData.h"
  55. //-----------------------------------------------------------------------------
  56. // Forward References
  57. //-----------------------------------------------------------------------------
  58. class RenderInfoClass;
  59. class LightClass;
  60. class W3DPropDrawModuleData;
  61. class W3DShroudMaterialPassClass;
  62. class GeometryInfo;
  63. //-----------------------------------------------------------------------------
  64. // Type Defines
  65. //-----------------------------------------------------------------------------
  66. /// The individual data for a prop.
  67. typedef struct {
  68. RenderObjClass *m_robj; ///< Render object for this kind of prop.
  69. Int id;
  70. Coord3D location; ///< Drawing location
  71. Int propType; ///< Type of prop. Index into m_propTypes
  72. ObjectShroudStatus ss;
  73. Bool visible; ///< Visible flag, updated each frame.
  74. SphereClass bounds; ///< Bounding sphere for culling to set the visible flag.
  75. } TProp;
  76. /// The individual data for a prop type.
  77. typedef struct {
  78. RenderObjClass *m_robj; ///< Render object for this kind of prop.
  79. AsciiString m_robjName; ///< Name of the render obj.
  80. SphereClass m_bounds; ///< Bounding boxes for the base prop models.
  81. } TPropType;
  82. //
  83. // W3DPropBuffer: Draw buffer for the props.
  84. //
  85. //
  86. class W3DPropBuffer : Snapshot
  87. {
  88. friend class BaseHeightMapRenderObjClass;
  89. public:
  90. W3DPropBuffer(void);
  91. ~W3DPropBuffer(void);
  92. /// Add a prop at location. Name is the w3d model name.
  93. void addProp(Int id, Coord3D location, Real angle, Real scale, const AsciiString &modelName);
  94. /// Remove a prop.
  95. void removeProp(Int id);
  96. /// Remove a prop.
  97. Bool updatePropPosition(Int id, const Coord3D &location, Real angle, Real scale);
  98. /// Let us know that the shroud has changed.
  99. void notifyShroudChanged(void);
  100. void removePropsForConstruction(
  101. const Coord3D* pos,
  102. const GeometryInfo& geom,
  103. Real angle
  104. );
  105. /// Add a type of prop. Name is the w3d model name.
  106. Int addPropType(const AsciiString &modelName);
  107. /// Empties the prop buffer.
  108. void clearAllProps(void);
  109. /// Draws the props. Uses camera for culling.
  110. void drawProps(RenderInfoClass &rinfo);
  111. /// Called when the view changes, and sort key needs to be recalculated.
  112. void doFullUpdate(void) {m_doCull = true;};
  113. protected:
  114. // snapshot methods
  115. virtual void crc( Xfer *xfer );
  116. virtual void xfer( Xfer *xfer );
  117. virtual void loadPostProcess( void );
  118. protected:
  119. enum { MAX_PROPS=4000};
  120. enum {MAX_TYPES = 64};
  121. TProp m_props[MAX_PROPS]; ///< The prop buffer. All props are stored here.
  122. Int m_numProps; ///< Number of props in m_props.
  123. Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
  124. Bool m_initialized; ///< True if the subsystem initialized.
  125. Bool m_doCull;
  126. TPropType m_propTypes[MAX_TYPES]; ///< Info about a kind of prop.
  127. Int m_numPropTypes; ///< Number of entries in m_propTypes.
  128. W3DShroudMaterialPassClass *m_propShroudMaterialPass; ///< Custom render pass which applies shrouds to objects
  129. LightClass *m_light;
  130. void cull(CameraClass * camera); ///< Culls the props.
  131. };
  132. #endif // end __W3DPROP_BUFFER_H_