W3DBibBuffer.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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: W3DBibBuffer.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: W3DBibBuffer.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 __W3DBIB_BUFFER_H_
  44. #define __W3DBIB_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. //-----------------------------------------------------------------------------
  63. // Type Defines
  64. //-----------------------------------------------------------------------------
  65. /// The individual data for a Bib.
  66. typedef struct {
  67. Vector3 m_corners[4]; ///< Drawing location
  68. Bool m_highlight; ///< Use the highlight texture.
  69. Int m_color; ///< Tint perhaps.
  70. ObjectID m_objectID; ///< The object id this bib corresponds to.
  71. DrawableID m_drawableID; ///< The object id this bib corresponds to.
  72. Bool m_unused; ///< True if this bib is currently unused.
  73. } TBib;
  74. //
  75. // W3DBibBuffer: Draw buffer for the bibs.
  76. //
  77. //
  78. class W3DBibBuffer
  79. {
  80. friend class BaseHeightMapRenderObjClass;
  81. public:
  82. W3DBibBuffer(void);
  83. ~W3DBibBuffer(void);
  84. /// Add a bib at location. Name is the w3d model name.
  85. void addBib(Vector3 corners[4], ObjectID id, Bool highlight);
  86. void addBibDrawable(Vector3 corners[4], DrawableID id, Bool highlight);
  87. /// Add a bib at location. Name is the w3d model name.
  88. void removeBib(ObjectID id);
  89. void removeBibDrawable(DrawableID id);
  90. /// Empties the bib buffer.
  91. void clearAllBibs(void);
  92. /// Removes highlighting.
  93. void removeHighlighting(void);
  94. /// Draws the bibs.
  95. void renderBibs();
  96. /// Called when the view changes, and sort key needs to be recalculated.
  97. /// Normally sortKey gets calculated when a bib becomes visible.
  98. protected:
  99. enum { INITIAL_BIB_VERTEX=256,
  100. INITIAL_BIB_INDEX=384,
  101. MAX_BIBS=1000};
  102. DX8VertexBufferClass *m_vertexBib; ///<Bib vertex buffer.
  103. Int m_vertexBibSize; ///< Num vertices in bib buffer.
  104. DX8IndexBufferClass *m_indexBib; ///<indices defining a triangles for the bib drawing.
  105. Int m_indexBibSize; ///<indices available in m_indexBib.
  106. TextureClass *m_bibTexture; ///<Bibs texture
  107. TextureClass *m_highlightBibTexture; ///<Bibs texture
  108. Int m_curNumBibVertices; ///<Number of vertices used in m_vertexBib.
  109. Int m_curNumBibIndices; ///<Number of indices used in b_indexBib;
  110. Int m_curNumNormalBibIndices; ///< Number of non-highlighted bib index.
  111. Int m_curNumNormalBibVertex; ///< Number of non-highlighted bib vertex.
  112. TBib m_bibs[MAX_BIBS]; ///< The bib buffer. All bibs are stored here.
  113. Int m_numBibs; ///< Number of bibs in m_bibs.
  114. Bool m_anythingChanged; ///< Set to true if visibility or sorting changed.
  115. Bool m_updateAllKeys; ///< Set to true when the view changes.
  116. Bool m_initialized; ///< True if the subsystem initialized.
  117. Bool m_isTerrainPass; ///< True if the terrain was drawn in this W3D scene render pass.
  118. void loadBibsInVertexAndIndexBuffers(void); ///< Fills the index and vertex buffers for drawing.
  119. void allocateBibBuffers(void); ///< Allocates the buffers.
  120. void freeBibBuffers(void); ///< Frees the index and vertex buffers.
  121. };
  122. #endif // end __W3DBIB_BUFFER_H_