FlatHeightMap.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #pragma once
  24. #ifndef __FLAT_HEIGHTMAP_H_
  25. #define __FLAT_HEIGHTMAP_H_
  26. #include "always.h"
  27. #include "rendobj.h"
  28. #include "w3d_file.h"
  29. #include "dx8vertexbuffer.h"
  30. #include "dx8indexbuffer.h"
  31. #include "dx8wrapper.h"
  32. #include "shader.h"
  33. #include "vertmaterial.h"
  34. #include "Lib/BaseType.h"
  35. #include "common/GameType.h"
  36. #include "WorldHeightMap.h"
  37. #include "BaseHeightMap.h"
  38. class W3DTerrainBackground;
  39. /// Custom render object that draws the heightmap and handles intersection tests.
  40. /**
  41. Custom W3D render object that's used to process the terrain. It handles
  42. virtually everything to do with the terrain, including: drawing, lighting,
  43. scorchmarks and intersection tests.
  44. */
  45. class FlatHeightMapRenderObjClass : public BaseHeightMapRenderObjClass
  46. {
  47. public:
  48. FlatHeightMapRenderObjClass(void);
  49. virtual ~FlatHeightMapRenderObjClass(void);
  50. // DX8_CleanupHook methods
  51. virtual void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset.
  52. virtual void ReAcquireResources(void); ///< Reacquire all resources after device reset.
  53. /////////////////////////////////////////////////////////////////////////////
  54. // Render Object Interface (W3D methods)
  55. /////////////////////////////////////////////////////////////////////////////
  56. virtual void Render(RenderInfoClass & rinfo);
  57. virtual void On_Frame_Update(void);
  58. ///allocate resources needed to render heightmap
  59. virtual int initHeightData(Int width, Int height, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator,Bool updateExtraPassTiles=TRUE);
  60. virtual Int freeMapResources(void); ///< free resources used to render heightmap
  61. virtual void updateCenter(CameraClass *camera, RefRenderObjListIterator *pLightsIterator);
  62. virtual void adjustTerrainLOD(Int adj);
  63. virtual void reset(void);
  64. virtual void oversizeTerrain(Int tilesToOversize);
  65. virtual void staticLightingChanged(void);
  66. virtual void doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, RefRenderObjListIterator *pLightsIterator);
  67. virtual int updateBlock(Int x0, Int y0, Int x1, Int y1, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator){return 0;};
  68. protected:
  69. W3DTerrainBackground *m_tiles;
  70. Int m_numTiles;
  71. Int m_tilesWidth;
  72. Int m_tilesHeight;
  73. enum { STATE_IDLE, // sleeping
  74. STATE_MOVING, // camera moving, updating visibility.
  75. STATE_MOVING2, // second moving state
  76. STATE_UPDATE_TEXTURES // Camera stopped, updating textures.
  77. } m_updateState;
  78. protected:
  79. void releaseTiles(void);
  80. };
  81. #endif // end __FLAT_HEIGHTMAP_H_