W3DCustomEdging.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. ** Command & Conquer Generals(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: W3DCustomEdging.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: W3DCustomEdging.h
  36. //
  37. // Created: John Ahlquist, May 2001
  38. //
  39. // Desc: Draw buffer to handle all the trees in a scene.
  40. //
  41. //-----------------------------------------------------------------------------
  42. #pragma once
  43. #ifndef __W3DCUSTOM_EDGING_H_
  44. #define __W3DCUSTOM_EDGING_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 WorldHeightMap;
  62. //-----------------------------------------------------------------------------
  63. // Type Defines
  64. //-----------------------------------------------------------------------------
  65. //
  66. // W3DCustomEdging: Draw buffer for the trees.
  67. //
  68. //
  69. class W3DCustomEdging
  70. {
  71. friend class HeightMapRenderObjClass;
  72. public:
  73. W3DCustomEdging(void);
  74. ~W3DCustomEdging(void);
  75. void addEdging(Coord3D location, Real scale, Real angle, AsciiString name, Bool visibleInMirror);
  76. /// Empties the tree buffer.
  77. void clearAllEdging(void);
  78. /// Draws the trees. Uses camera for culling.
  79. void drawEdging( WorldHeightMap *pMap, Int minX, Int maxX, Int minY, Int maxY,
  80. TextureClass * terrainTexture, TextureClass * cloudTexture, TextureClass * noiseTexture );
  81. /// Called when the view changes, and sort key needs to be recalculated.
  82. /// Normally sortKey gets calculated when a tree becomes visible.
  83. void doFullUpdate(void) {clearAllEdging();};
  84. protected:
  85. #define MAX_BLENDS 2000
  86. enum { MAX_EDGE_VERTEX=4*MAX_BLENDS,
  87. MAX_EDGE_INDEX=6*MAX_BLENDS};
  88. DX8VertexBufferClass *m_vertexEdging; ///<Edging vertex buffer.
  89. DX8IndexBufferClass *m_indexEdging; ///<indices defining a triangles for the tree drawing.
  90. Int m_curNumEdgingVertices; ///<Number of vertices used in m_vertexEdging.
  91. Int m_curNumEdgingIndices; ///<Number of indices used in b_indexEdging;
  92. Int m_curEdgingIndexOffset; ///<First index to draw at. We draw the trees backwards by filling up the index buffer backwards,
  93. // so any trees that don't fit are far away from the camera.
  94. Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
  95. Bool m_initialized; ///< True if the subsystem initialized.
  96. void allocateEdgingBuffers(void); ///< Allocates the buffers.
  97. void freeEdgingBuffers(void); ///< Frees the index and vertex buffers.
  98. void loadEdgingsInVertexAndIndexBuffers(WorldHeightMap *pMap, Int minX, Int maxX, Int minY, Int maxY);
  99. };
  100. #endif // end __W3DCUSTOM_EDGING_H_