W3DTerrainVisual.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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: W3DTerrainVisual.h ///////////////////////////////////////////////////////////////////////
  24. // W3D implementation details for visual aspects of terrain
  25. // Author: Colin Day, April 2001
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __W3DTERRAINVISUAL_H_
  29. #define __W3DTERRAINVISUAL_H_
  30. #include "GameClient/TerrainVisual.h"
  31. #include "W3DDevice/GameClient/W3DWater.h"
  32. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  33. class Matrix3D;
  34. class WaterHandle;
  35. class HeightMapRenderObjClass;
  36. class WorldHeightMap;
  37. //-------------------------------------------------------------------------------------------------
  38. /** W3D impelmentation of visual terrain details singleton */
  39. //-------------------------------------------------------------------------------------------------
  40. class W3DTerrainVisual : public TerrainVisual
  41. {
  42. public:
  43. W3DTerrainVisual();
  44. virtual ~W3DTerrainVisual();
  45. virtual void init( void );
  46. virtual void reset( void );
  47. virtual void update( void );
  48. virtual Bool load( AsciiString filename );
  49. void getTerrainColorAt( Real x, Real y, RGBColor *pColor );
  50. /// get the terrain tile type at the world location in the (x,y) plane ignoring Z
  51. TerrainType *getTerrainTile( Real x, Real y );
  52. /** intersect the ray with the terrain, if a hit occurs TRUE is returned
  53. and the result point on the terrain is returned in "result" */
  54. virtual Bool intersectTerrain( Coord3D *rayStart, Coord3D *rayEnd, Coord3D *result );
  55. //
  56. // water methods
  57. //
  58. /// enable/disable the water grid
  59. virtual void enableWaterGrid( Bool enable );
  60. /// set min/max height values allowed in water grid pointed to by waterTable
  61. virtual void setWaterGridHeightClamps( const WaterHandle *waterTable, Real minZ, Real maxZ );
  62. /// adjust fallof parameters for grid change method
  63. virtual void setWaterAttenuationFactors( const WaterHandle *waterTable,
  64. Real a, Real b, Real c, Real range );
  65. /// set the water table position and orientation in world space
  66. virtual void setWaterTransform( const WaterHandle *waterTable,
  67. Real angle, Real x, Real y, Real z );
  68. virtual void setWaterTransform( const Matrix3D *transform );
  69. virtual void getWaterTransform( const WaterHandle *waterTable, Matrix3D *transform );
  70. /// water grid resolution spacing
  71. virtual void setWaterGridResolution( const WaterHandle *waterTable,
  72. Real gridCellsX, Real gridCellsY, Real cellSize );
  73. virtual void getWaterGridResolution( const WaterHandle *waterTable,
  74. Real *gridCellsX, Real *gridCellsY, Real *cellSize );
  75. /// adjust the water grid in world coords by the delta
  76. virtual void changeWaterHeight( Real x, Real y, Real delta );
  77. /// adjust the velocity at a water grid point corresponding to the world x,y
  78. virtual void addWaterVelocity( Real worldX, Real worldY,
  79. Real velocity, Real preferredHeight );
  80. virtual Bool getWaterGridHeight( Real worldX, Real worldY, Real *height);
  81. virtual void setTerrainTracksDetail(void);
  82. virtual void setShoreLineDetail(void);
  83. /// Add a bib at location.
  84. void addFactionBib(Object *factionBuilding, Bool highlight, Real extra = 0);
  85. /// Remove a bib.
  86. void removeFactionBib(Object *factionBuilding);
  87. /// Add a bib at location.
  88. void addFactionBibDrawable(Drawable *factionBuilding, Bool highlight, Real extra = 0);
  89. /// Remove a bib.
  90. void removeFactionBibDrawable(Drawable *factionBuilding);
  91. virtual void removeAllBibs(void);
  92. virtual void removeBibHighlighting(void);
  93. //
  94. // Modify height.
  95. //
  96. virtual void setRawMapHeight(const ICoord2D *gridPos, Int height);
  97. /// Replace the skybox texture
  98. virtual void replaceSkyboxTextures(const AsciiString *oldTexName[NumSkyboxTextures], const AsciiString *newTexName[NumSkyboxTextures]);
  99. protected:
  100. // snapshot methods
  101. virtual void crc( Xfer *xfer );
  102. virtual void xfer( Xfer *xfer );
  103. virtual void loadPostProcess( void );
  104. HeightMapRenderObjClass *m_terrainRenderObject; ///< W3D render object for terrain
  105. WaterRenderObjClass *m_waterRenderObject; ///< W3D render object for water plane
  106. WorldHeightMap *m_terrainHeightMap; ///< height map used for render obj building
  107. Bool m_isWaterGridRenderingEnabled;
  108. AsciiString m_currentSkyboxTexNames[NumSkyboxTextures]; ///<store current texture names applied to skybox.
  109. AsciiString m_initialSkyboxTexNames[NumSkyboxTextures]; ///<store starting texture/default skybox textures.
  110. }; // end class W3DTerrainVisual
  111. #endif // end __W3DTERRAINVISUAL_H_