W3DTerrainBackground.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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: W3DTerrainBackground.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: W3DTerrainBackground.h
  36. //
  37. // Created: John Ahlquist, May 2001
  38. //
  39. // Desc: Draw buffer to handle all the bibs in a scene.
  40. //
  41. //-----------------------------------------------------------------------------
  42. #pragma once
  43. #ifndef __W3DTERRAIN_BUFFER_H_
  44. #define __W3DTERRAIN_BUFFER_H_
  45. //-----------------------------------------------------------------------------
  46. // Includes
  47. //-----------------------------------------------------------------------------
  48. #include "always.h"
  49. #include "rendobj.h"
  50. #include "w3d_file.h"
  51. #include "dx8vertexbuffer.h"
  52. #include "dx8indexbuffer.h"
  53. #include "shader.h"
  54. #include "vertmaterial.h"
  55. #include "Lib/BaseType.h"
  56. #include "common/GameType.h"
  57. #include "Common/AsciiString.h"
  58. //-----------------------------------------------------------------------------
  59. // Forward References
  60. //-----------------------------------------------------------------------------
  61. class MeshClass;
  62. class WorldHeightMap;
  63. class TerrainTextureClass;
  64. //-----------------------------------------------------------------------------
  65. // Type Defines
  66. //-----------------------------------------------------------------------------
  67. //
  68. // W3DTerrainBackground: Draw buffer for the bibs.
  69. //
  70. //
  71. class W3DTerrainBackground
  72. {
  73. friend class HeightMapRenderObjClass;
  74. public:
  75. W3DTerrainBackground(void);
  76. ~W3DTerrainBackground(void);
  77. /// Draws the terrain.
  78. void drawVisiblePolys(RenderInfoClass & rinfo, Bool disableTextures);
  79. void setFlip(WorldHeightMap *htMap); ///< Sets the flip bit for required vertices.
  80. void doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, Bool doTextures );
  81. void doTesselatedUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, Bool doTextures );
  82. void allocateTerrainBuffers(WorldHeightMap *htMap, Int xOrigin, Int yOrigin, Int width); ///< Allocates the buffers.
  83. void updateCenter(CameraClass *camera); // notify camera moved [3/24/2003]
  84. void updateTexture(void); // notify camera moved [3/24/2003]
  85. Bool isCulled(void) {return m_cullStatus==CULL_STATUS_INVISIBLE;}
  86. Int getTexMultiplier(void) {return m_texMultiplier;}
  87. protected:
  88. enum {CULL_STATUS_UNKNOWN, CULL_STATUS_VISIBLE, CULL_STATUS_INVISIBLE} m_cullStatus;
  89. AABoxClass m_bounds;
  90. DX8VertexBufferClass *m_vertexTerrain; ///<Terrain vertex buffer.
  91. Int m_vertexTerrainSize; ///< Num vertices in bib buffer.
  92. DX8IndexBufferClass *m_indexTerrain; ///<indices defining a triangles for the bib drawing.
  93. Int m_indexTerrainSize; ///<indices available in m_indexTerrain.
  94. TerrainTextureClass *m_terrainTexture; ///<Terrain texture
  95. TerrainTextureClass *m_terrainTexture2X; ///<Terrain texture
  96. TerrainTextureClass *m_terrainTexture4X; ///<Terrain texture
  97. enum {TEX4X=4, TEX2X=2, TEX1X=1} m_texMultiplier;
  98. Int m_curNumTerrainVertices; ///<Number of vertices used in m_vertexTerrain.
  99. Int m_curNumTerrainIndices; ///<Number of indices used in b_indexTerrain;
  100. Int m_xOrigin;
  101. Int m_yOrigin;
  102. Int m_width;
  103. WorldHeightMap *m_map;
  104. Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
  105. Bool m_initialized; ///< True if the subsystem initialized.
  106. protected:
  107. typedef enum {HORIZONTAL, VERTICAL} TDirection;
  108. void freeTerrainBuffers(void); ///< Frees the index and vertex buffers.
  109. void fillVBRecursive(UnsignedShort *ib, Int xOffset, Int yOffset, Int width, UnsignedShort *ndx, Int &curIndex);
  110. void setFlipRecursive(Int xOffset, Int yOffset, Int width);
  111. Bool advanceLeft(ICoord2D &left, Int xOffset, Int yOffset, Int width);
  112. Bool advanceRight(ICoord2D &left, Int xOffset, Int yOffset, Int width);
  113. };
  114. #endif // end __W3DTERRAIN_BUFFER_H_