TerrainVisual.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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: TerrainVisual.h //////////////////////////////////////////////////////////////////////////
  24. // Interface for visual representation of terrain on the client
  25. // Author: Colin Day, April 2001
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __TERRAINVISUAL_H_
  29. #define __TERRAINVISUAL_H_
  30. #include "Common/Terrain.h"
  31. #include "Common/Snapshot.h"
  32. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  33. class TerrainType;
  34. class WaterHandle;
  35. class Matrix3D;
  36. class Object;
  37. class Drawable;
  38. //-------------------------------------------------------------------------------------------------
  39. /** LOD values for terrain, keep this in sync with TerrainLODNames[] */
  40. //-------------------------------------------------------------------------------------------------
  41. typedef enum _TerrainLOD
  42. {
  43. TERRAIN_LOD_INVALID = 0,
  44. TERRAIN_LOD_MIN = 1, // note that this is less than max
  45. TERRAIN_LOD_STRETCH_NO_CLOUDS = 2,
  46. TERRAIN_LOD_HALF_CLOUDS = 3,
  47. TERRAIN_LOD_NO_CLOUDS = 4,
  48. TERRAIN_LOD_STRETCH_CLOUDS = 5,
  49. TERRAIN_LOD_NO_WATER = 6,
  50. TERRAIN_LOD_MAX = 7, // note that this is larger than min
  51. TERRAIN_LOD_AUTOMATIC = 8,
  52. TERRAIN_LOD_DISABLE = 9,
  53. TERRAIN_LOD_NUM_TYPES // keep this last
  54. } TerrainLOD;
  55. #ifdef DEFINE_TERRAIN_LOD_NAMES
  56. static char * TerrainLODNames[] =
  57. {
  58. "NONE",
  59. "MIN",
  60. "STRETCH_NO_CLOUDS",
  61. "HALF_CLOUDS",
  62. "NO_CLOUDS",
  63. "STRETCH_CLOUDS",
  64. "NO_WATER",
  65. "MAX",
  66. "AUTOMATIC",
  67. "DISABLE",
  68. NULL
  69. };
  70. #endif // end DEFINE_TERRAIN_LOD_NAMES
  71. //-------------------------------------------------------------------------------------------------
  72. /** Device independent implementation for visual terrain */
  73. //-------------------------------------------------------------------------------------------------
  74. class TerrainVisual : public Snapshot,
  75. public SubsystemInterface
  76. {
  77. public:
  78. enum {NumSkyboxTextures = 5};
  79. TerrainVisual();
  80. virtual ~TerrainVisual();
  81. virtual void init( void );
  82. virtual void reset( void );
  83. virtual void update( void );
  84. virtual Bool load( AsciiString filename );
  85. /// get color of texture on the terrain at location specified
  86. virtual void getTerrainColorAt( Real x, Real y, RGBColor *pColor ) = 0;
  87. /// get the terrain tile type at the world location in the (x,y) plane ignoring Z
  88. virtual TerrainType *getTerrainTile( Real x, Real y ) = 0;
  89. /** intersect the ray with the terrain, if a hit occurs TRUE is returned
  90. and the result point on the terrain is returned in "result" */
  91. virtual Bool intersectTerrain( Coord3D *rayStart,
  92. Coord3D *rayEnd,
  93. Coord3D *result ) { return FALSE; }
  94. //
  95. // water methods
  96. //
  97. virtual void enableWaterGrid( Bool enable ) = 0;
  98. /// set min/max height values allowed in water grid pointed to by waterTable
  99. virtual void setWaterGridHeightClamps( const WaterHandle *waterTable, Real minZ, Real maxZ ) = 0;
  100. /// adjust fallof parameters for grid change method
  101. virtual void setWaterAttenuationFactors( const WaterHandle *waterTable, Real a, Real b, Real c, Real range ) = 0;
  102. /// set the water table position and orientation in world space
  103. virtual void setWaterTransform( const WaterHandle *waterTable, Real angle, Real x, Real y, Real z ) = 0;
  104. virtual void setWaterTransform( const Matrix3D *transform ) = 0;
  105. /// get water transform parameters
  106. virtual void getWaterTransform( const WaterHandle *waterTable, Matrix3D *transform ) = 0;
  107. /// water grid resolution spacing
  108. virtual void setWaterGridResolution( const WaterHandle *waterTable, Real gridCellsX, Real gridCellsY, Real cellSize ) = 0;
  109. virtual void getWaterGridResolution( const WaterHandle *waterTable, Real *gridCellsX, Real *gridCellsY, Real *cellSize ) = 0;
  110. /// adjust the water grid in world coords by the delta
  111. virtual void changeWaterHeight( Real x, Real y, Real delta ) = 0;
  112. /// adjust the velocity at a water grid point corresponding to the world x,y
  113. virtual void addWaterVelocity( Real worldX, Real worldY, Real velocity, Real preferredHeight ) = 0;
  114. /// get height of water grid at specified position
  115. virtual Bool getWaterGridHeight( Real worldX, Real worldY, Real *height) = 0;
  116. /// set detail of terrain tracks.
  117. virtual void setTerrainTracksDetail(void)=0;
  118. virtual void setShoreLineDetail(void)=0;
  119. /// Add a bib for an object at location.
  120. virtual void addFactionBib(Object *factionBuilding, Bool highlight, Real extra = 0)=0;
  121. /// Remove a bib.
  122. virtual void removeFactionBib(Object *factionBuilding)=0;
  123. /// Add a bib for a drawable at location.
  124. virtual void addFactionBibDrawable(Drawable *factionBuilding, Bool highlight, Real extra = 0)=0;
  125. /// Remove a bib.
  126. virtual void removeFactionBibDrawable(Drawable *factionBuilding)=0;
  127. virtual void removeAllBibs(void)=0;
  128. virtual void removeBibHighlighting(void)=0;
  129. //
  130. // Modify height.
  131. //
  132. virtual void setRawMapHeight(const ICoord2D *gridPos, Int height)=0;
  133. /// Replace the skybox texture
  134. virtual void replaceSkyboxTextures(const AsciiString *oldTexName[NumSkyboxTextures], const AsciiString *newTexName[NumSkyboxTextures])=0;
  135. protected:
  136. // snapshot methods
  137. virtual void crc( Xfer *xfer );
  138. virtual void xfer( Xfer *xfer );
  139. virtual void loadPostProcess( void );
  140. AsciiString m_filenameString; ///< file with terrain data
  141. }; // end class TerrainVisual
  142. // EXTERNALS //////////////////////////////////////////////////////////////////////////////////////
  143. extern TerrainVisual *TheTerrainVisual; ///< singleton extern
  144. #endif // end __TERRAINVISUAL_H_