W3DRadar.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: W3DRadar.h ///////////////////////////////////////////////////////////////////////////////
  24. // Author: Colin Day, January 2002
  25. // Desc: W3D radar implementation, this has the necessary device dependent drawing
  26. // necessary for the radar
  27. ///////////////////////////////////////////////////////////////////////////////////////////////////
  28. #pragma once
  29. #ifndef __W3DRADAR_H_
  30. #define __W3DRADAR_H_
  31. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  32. #include "Common/Radar.h"
  33. #include "WW3D2/WW3DFormat.h"
  34. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  35. class TextureClass;
  36. class TerrainLogic;
  37. // PROTOTYPES /////////////////////////////////////////////////////////////////////////////////////
  38. //-------------------------------------------------------------------------------------------------
  39. /** W3D radar class. This has the device specific implementation of the radar such as
  40. * the drawing routines */
  41. //-------------------------------------------------------------------------------------------------
  42. class W3DRadar : public Radar
  43. {
  44. public:
  45. W3DRadar( void );
  46. ~W3DRadar( void );
  47. virtual void init( void ); ///< subsystem init
  48. virtual void update( void ); ///< subsystem update
  49. virtual void reset( void ); ///< subsystem reset
  50. virtual void newMap( TerrainLogic *terrain ); ///< reset radar for new map
  51. void draw( Int pixelX, Int pixelY, Int width, Int height ); ///< draw the radar
  52. virtual void clearShroud();
  53. virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting);
  54. virtual void refreshTerrain( TerrainLogic *terrain );
  55. protected:
  56. void drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );
  57. void drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );
  58. void initializeTextureFormats( void ); ///< find format to use for the radar texture
  59. void deleteResources( void ); ///< delete resources used
  60. void drawEvents( Int pixelX, Int pixelY, Int width, Int height); ///< draw all of the radar events
  61. void drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, const Coord3D *pos ); //< draw a hero icon
  62. void drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view box
  63. void buildTerrainTexture( TerrainLogic *terrain ); ///< create the terrain texture of the radar
  64. void drawIcons( Int pixelX, Int pixelY, Int width, Int height ); ///< draw all of the radar icons
  65. void renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero = FALSE ); ///< render an object list to the texture
  66. void interpolateColorForHeight( RGBColor *color,
  67. Real height,
  68. Real hiZ,
  69. Real midZ,
  70. Real loZ ); ///< "shade" color according to height value
  71. void reconstructViewBox( void ); ///< remake the view box
  72. void radarToPixel( const ICoord2D *radar, ICoord2D *pixel,
  73. Int radarUpperLeftX, Int radarUpperLeftY,
  74. Int radarWidth, Int radarHeight ); ///< convert radar coord to pixel location
  75. WW3DFormat m_terrainTextureFormat; ///< format to use for terrain texture
  76. Image *m_terrainImage; ///< terrain image abstraction for drawing
  77. TextureClass *m_terrainTexture; ///< terrain background texture
  78. WW3DFormat m_overlayTextureFormat; ///< format to use for overlay texture
  79. Image *m_overlayImage; ///< overlay image abstraction for drawing
  80. TextureClass *m_overlayTexture; ///< overlay texture
  81. WW3DFormat m_shroudTextureFormat; ///< format to use for shroud texture
  82. Image *m_shroudImage; ///< shroud image abstraction for drawing
  83. TextureClass *m_shroudTexture; ///< shroud texture
  84. Int m_textureWidth; ///< width for all radar textures
  85. Int m_textureHeight; ///< height for all radar textures
  86. //
  87. // we want to keep a flag that tells us when to reconstruct the view box, we want
  88. // to reconstruct the box on map change, and when the camera changes height
  89. // or orientation. We want to avoid making the view box every frame because
  90. // the 4 points visible on the edge of the screen will "jitter" unevenly as we
  91. // translate real world coords to integer radar spots
  92. //
  93. Bool m_reconstructViewBox; ///< true when we need to reconstruct the box
  94. Real m_viewAngle; ///< camera angle used for the view box we have
  95. Real m_viewZoom; ///< camera zoom used for the view box we have
  96. ICoord2D m_viewBox[ 4 ]; ///< radar cell points for the 4 corners of view box
  97. std::list<const Coord3D *> m_cachedHeroPosList; //< cache of hero positions for drawing icons in radar overlay
  98. };
  99. #endif // __W3DRADAR_H_