Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
W3DRadar Class Reference

#include <W3DRadar.h>

Inherits Radar.

Public Member Functions

 W3DRadar (void)
 
 ~W3DRadar (void)
 
virtual void init (void)
 subsystem init
 
virtual void update (void)
 subsystem update
 
virtual void reset (void)
 subsystem reset
 
virtual void newMap (TerrainLogic *terrain)
 reset radar for new map
 
void draw (Int pixelX, Int pixelY, Int width, Int height)
 draw the radar
 
virtual void clearShroud ()
 empty the entire shroud
 
virtual void setShroudLevel (Int x, Int y, CellShroudStatus setting)
 set the shroud level at shroud cell x,y
 
virtual void refreshTerrain (TerrainLogic *terrain)
 refresh the water values for the radar
 
- Public Member Functions inherited from Radar
 Radar (void)
 
virtual ~Radar (void)
 
Bool isRadarWindow (GameWindow *window)
 
Bool radarToWorld (const ICoord2D *radar, Coord3D *world)
 radar point to world point on terrain
 
Bool radarToWorld2D (const ICoord2D *radar, Coord3D *world)
 radar point to world point (x,y only!)
 
Bool worldToRadar (const Coord3D *world, ICoord2D *radar)
 translate world point to radar (x,y)
 
Bool localPixelToRadar (const ICoord2D *pixel, ICoord2D *radar)
 translate pixel (with UL of radar being (0,0)) to logical radar coords
 
Bool screenPixelToWorld (const ICoord2D *pixel, Coord3D *world)
 translate pixel (with UL of the screen being (0,0)) to world position in the world
 
ObjectobjectUnderRadarPixel (const ICoord2D *pixel)
 return the object (if any) represented by the pixel coords passed in
 
void findDrawPositions (Int startX, Int startY, Int width, Int height, ICoord2D *ul, ICoord2D *lr)
 make translation for screen area of radar square to scaled aspect ratio preserving points inside the radar area
 
Bool isPriorityVisible (RadarPriorityType priority) const
 is the priority passed in a "visible" one on the radar
 
void createEvent (const Coord3D *world, RadarEventType type, Real secondsToLive=4.0f)
 create radar event at location in world
 
void createPlayerEvent (Player *player, const Coord3D *world, RadarEventType type, Real secondsToLive=4.0f)
 create radar event using player colors
 
Bool getLastEventLoc (Coord3D *eventPos)
 get last event loc (if any)
 
void tryUnderAttackEvent (const Object *obj)
 try to make an "under attack" event if it's the proper time
 
void tryInfiltrationEvent (const Object *obj)
 try to make an "infiltration" event if it's the proper time
 
Bool tryEvent (RadarEventType event, const Coord3D *pos)
 try to make a "stealth" event
 
void addObject (Object *obj)
 add object to radar
 
void removeObject (Object *obj)
 remove object from radar
 
void examineObject (Object *obj)
 re-examine object and resort if needed
 
void hide (Bool hide)
 hide/unhide the radar
 
Bool isRadarHidden (void)
 is radar hidden
 
void forceOn (Bool force)
 force the radar to be on
 
Bool isRadarForced (void)
 is radar forced on?
 
virtual void queueTerrainRefresh (void)
 queue a refresh of the terran at the next available time
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Member Functions

void drawSingleBeaconEvent (Int pixelX, Int pixelY, Int width, Int height, Int index)
 
void drawSingleGenericEvent (Int pixelX, Int pixelY, Int width, Int height, Int index)
 
void initializeTextureFormats (void)
 find format to use for the radar texture
 
void deleteResources (void)
 delete resources used
 
void drawEvents (Int pixelX, Int pixelY, Int width, Int height)
 draw all of the radar events
 
void drawHeroIcon (Int pixelX, Int pixelY, Int width, Int height, const Coord3D *pos)
 
void drawViewBox (Int pixelX, Int pixelY, Int width, Int height)
 draw view box
 
void buildTerrainTexture (TerrainLogic *terrain)
 create the terrain texture of the radar
 
void drawIcons (Int pixelX, Int pixelY, Int width, Int height)
 draw all of the radar icons
 
void renderObjectList (const RadarObject *listHead, TextureClass *texture, Bool calcHero=FALSE)
 render an object list to the texture
 
void interpolateColorForHeight (RGBColor *color, Real height, Real hiZ, Real midZ, Real loZ)
 "shade" color according to height value
 
void reconstructViewBox (void)
 remake the view box
 
void radarToPixel (const ICoord2D *radar, ICoord2D *pixel, Int radarUpperLeftX, Int radarUpperLeftY, Int radarWidth, Int radarHeight)
 convert radar coord to pixel location
 
- Protected Member Functions inherited from Radar
virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
void internalCreateEvent (const Coord3D *world, RadarEventType type, Real secondsToLive, const RGBAColorInt *color1, const RGBAColorInt *color2)
 internal method for creating a radar event with specific colors
 
void deleteListResources (void)
 delete list radar resources used
 
Bool deleteFromList (Object *obj, RadarObject **list)
 try to remove object from specific list
 
Real getTerrainAverageZ () const
 
Real getWaterAverageZ () const
 
const RadarObjectgetObjectList () const
 
const RadarObjectgetLocalObjectList () const
 
void clearAllEvents (void)
 remove all radar events in progress
 
ObjectsearchListForRadarLocationMatch (RadarObject *listHead, ICoord2D *radarMatch)
 

Protected Attributes

WW3DFormat m_terrainTextureFormat
 format to use for terrain texture
 
Imagem_terrainImage
 terrain image abstraction for drawing
 
TextureClassm_terrainTexture
 terrain background texture
 
WW3DFormat m_overlayTextureFormat
 format to use for overlay texture
 
Imagem_overlayImage
 overlay image abstraction for drawing
 
TextureClassm_overlayTexture
 overlay texture
 
WW3DFormat m_shroudTextureFormat
 format to use for shroud texture
 
Imagem_shroudImage
 shroud image abstraction for drawing
 
TextureClassm_shroudTexture
 shroud texture
 
Int m_textureWidth
 width for all radar textures
 
Int m_textureHeight
 height for all radar textures
 
Bool m_reconstructViewBox
 true when we need to reconstruct the box
 
Real m_viewAngle
 camera angle used for the view box we have
 
Real m_viewZoom
 camera zoom used for the view box we have
 
ICoord2D m_viewBox [4]
 radar cell points for the 4 corners of view box
 
std::list< const Coord3D * > m_cachedHeroPosList
 
- Protected Attributes inherited from Radar
Bool m_radarHidden
 true when radar is not visible
 
Bool m_radarForceOn
 true when radar is forced to be on
 
RadarObjectm_objectList
 list of objects in the radar
 
RadarObjectm_localObjectList
 
Real m_terrainAverageZ
 average Z for terrain samples
 
Real m_waterAverageZ
 average Z for water samples
 
Real m_xSample
 
Real m_ySample
 
RadarEvent m_event [MAX_RADAR_EVENTS]
 our radar events
 
Int m_nextFreeRadarEvent
 index into m_event for where to store the next event
 
Int m_lastRadarEvent
 index of the most recent radar event
 
GameWindowm_radarWindow
 window we display the radar in
 
Region3D m_mapExtent
 extents of the current map
 
UnsignedInt m_queueTerrainRefreshFrame
 frame we requested the last terrain refresh on
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Additional Inherited Members

- Protected Types inherited from Radar
enum  { MAX_RADAR_EVENTS = 64 }
 

Detailed Description

W3D radar class. This has the device specific implementation of the radar such as the drawing routines

Definition at line 50 of file W3DRadar.h.

Constructor & Destructor Documentation

◆ W3DRadar()

W3DRadar::W3DRadar ( void )

Definition at line 823 of file W3DRadar.cpp.

◆ ~W3DRadar()

W3DRadar::~W3DRadar ( void )

Definition at line 856 of file W3DRadar.cpp.

Member Function Documentation

◆ buildTerrainTexture()

void W3DRadar::buildTerrainTexture ( TerrainLogic * terrain)
protected

create the terrain texture of the radar

Definition at line 1021 of file W3DRadar.cpp.

◆ clearShroud()

void W3DRadar::clearShroud ( )
virtual

empty the entire shroud

Implements Radar.

Definition at line 1256 of file W3DRadar.cpp.

◆ deleteResources()

void W3DRadar::deleteResources ( void )
protected

delete resources used

Delete resources used specifically in this W3D radar implemetation

Definition at line 140 of file W3DRadar.cpp.

◆ draw()

void W3DRadar::draw ( Int pixelX,
Int pixelY,
Int width,
Int height )
virtual

draw the radar

Actually draw the radar at the screen coordinates provided NOTE about how drawing works: The radar images are computed at samples across the map and are built into a "square" texture area. At the time of drawing and computing radar<->world coords we consider the "ratio" of width to height of the map dimensions so that when we draw we preserve the aspect ratio of the map and don't squish it in any direction that would cause the map to be distorted. Extra blank space is drawn around the radar images to keep the whole radar area covered when the map displayed is "long" or "tall"

Implements Radar.

Definition at line 1350 of file W3DRadar.cpp.

◆ drawEvents()

void W3DRadar::drawEvents ( Int pixelX,
Int pixelY,
Int width,
Int height )
protected

draw all of the radar events

Draw all the radar events

Definition at line 570 of file W3DRadar.cpp.

◆ drawHeroIcon()

void W3DRadar::drawHeroIcon ( Int pixelX,
Int pixelY,
Int width,
Int height,
const Coord3D * pos )
protected

Draw a hero icon at a position, given radar box upper left location and dimensions.

Definition at line 254 of file W3DRadar.cpp.

◆ drawIcons()

void W3DRadar::drawIcons ( Int pixelX,
Int pixelY,
Int width,
Int height )
protected

draw all of the radar icons

Draw all the radar icons

Definition at line 606 of file W3DRadar.cpp.

◆ drawSingleBeaconEvent()

void W3DRadar::drawSingleBeaconEvent ( Int pixelX,
Int pixelY,
Int width,
Int height,
Int index )
protected

< spin around this many angles going from big to small

Definition at line 371 of file W3DRadar.cpp.

◆ drawSingleGenericEvent()

void W3DRadar::drawSingleGenericEvent ( Int pixelX,
Int pixelY,
Int width,
Int height,
Int index )
protected

< spin around this many angles going from big to small

Definition at line 470 of file W3DRadar.cpp.

◆ drawViewBox()

void W3DRadar::drawViewBox ( Int pixelX,
Int pixelY,
Int width,
Int height )
protected

draw view box

Draw a "box" into the texture passed in that represents the viewable area for the tactical display into the game world

Definition at line 284 of file W3DRadar.cpp.

◆ init()

void W3DRadar::init ( void )
virtual

subsystem init

Radar initialization

Reimplemented from Radar.

Definition at line 867 of file W3DRadar.cpp.

◆ initializeTextureFormats()

void W3DRadar::initializeTextureFormats ( void )
protected

find format to use for the radar texture

Find the texture format we're going to use for the radar. The texture format must be supported by the hardware. The "more preferred" formats appear at the top of the format tables in order from most preferred to least preferred

Definition at line 103 of file W3DRadar.cpp.

◆ interpolateColorForHeight()

void W3DRadar::interpolateColorForHeight ( RGBColor * color,
Real height,
Real hiZ,
Real midZ,
Real loZ )
protected

"shade" color according to height value

Shade the color passed in using the height parameter to lighten and darken it. Colors will be interpolated using the value "height" across the range from loZ to hiZ. The midZ is the "middle" point, height values above it will be lightened, while lower ones are darkened.

Definition at line 750 of file W3DRadar.cpp.

◆ newMap()

void W3DRadar::newMap ( TerrainLogic * terrain)
virtual

reset radar for new map

Reset the radar for the new map data being given to it

Reimplemented from Radar.

Definition at line 1001 of file W3DRadar.cpp.

◆ radarToPixel()

void W3DRadar::radarToPixel ( const ICoord2D * radar,
ICoord2D * pixel,
Int radarUpperLeftX,
Int radarUpperLeftY,
Int radarWidth,
Int radarHeight )
protected

convert radar coord to pixel location

Convert radar position to actual pixel coord

Definition at line 235 of file W3DRadar.cpp.

◆ reconstructViewBox()

void W3DRadar::reconstructViewBox ( void )
protected

remake the view box

Reconstruct the view box given the current camera settings

Definition at line 178 of file W3DRadar.cpp.

◆ refreshTerrain()

void W3DRadar::refreshTerrain ( TerrainLogic * terrain)
virtual

refresh the water values for the radar

Reimplemented from Radar.

Definition at line 1446 of file W3DRadar.cpp.

◆ renderObjectList()

void W3DRadar::renderObjectList ( const RadarObject * listHead,
TextureClass * texture,
Bool calcHero = FALSE )
protected

render an object list to the texture

Render an object list into the texture passed in

Definition at line 620 of file W3DRadar.cpp.

◆ reset()

void W3DRadar::reset ( void )
virtual

subsystem reset

Reset the radar to the initial empty state ready for new data

Reimplemented from Radar.

Definition at line 958 of file W3DRadar.cpp.

◆ setShroudLevel()

void W3DRadar::setShroudLevel ( Int x,
Int y,
CellShroudStatus setting )
virtual

set the shroud level at shroud cell x,y

Todo
srj – this really needs to smooth the display!

<

Todo
placeholder to get feedback on logic work while graphic side being decided

Implements Radar.

Definition at line 1276 of file W3DRadar.cpp.

◆ update()

void W3DRadar::update ( void )
virtual

subsystem update

Update

Reimplemented from Radar.

Definition at line 990 of file W3DRadar.cpp.

Member Data Documentation

◆ m_cachedHeroPosList

std::list<const Coord3D *> W3DRadar::m_cachedHeroPosList
protected

Definition at line 121 of file W3DRadar.h.

◆ m_overlayImage

Image* W3DRadar::m_overlayImage
protected

overlay image abstraction for drawing

Definition at line 99 of file W3DRadar.h.

◆ m_overlayTexture

TextureClass* W3DRadar::m_overlayTexture
protected

overlay texture

Definition at line 100 of file W3DRadar.h.

◆ m_overlayTextureFormat

WW3DFormat W3DRadar::m_overlayTextureFormat
protected

format to use for overlay texture

Definition at line 98 of file W3DRadar.h.

◆ m_reconstructViewBox

Bool W3DRadar::m_reconstructViewBox
protected

true when we need to reconstruct the box

Definition at line 116 of file W3DRadar.h.

◆ m_shroudImage

Image* W3DRadar::m_shroudImage
protected

shroud image abstraction for drawing

Definition at line 103 of file W3DRadar.h.

◆ m_shroudTexture

TextureClass* W3DRadar::m_shroudTexture
protected

shroud texture

Definition at line 104 of file W3DRadar.h.

◆ m_shroudTextureFormat

WW3DFormat W3DRadar::m_shroudTextureFormat
protected

format to use for shroud texture

Definition at line 102 of file W3DRadar.h.

◆ m_terrainImage

Image* W3DRadar::m_terrainImage
protected

terrain image abstraction for drawing

Definition at line 95 of file W3DRadar.h.

◆ m_terrainTexture

TextureClass* W3DRadar::m_terrainTexture
protected

terrain background texture

Definition at line 96 of file W3DRadar.h.

◆ m_terrainTextureFormat

WW3DFormat W3DRadar::m_terrainTextureFormat
protected

format to use for terrain texture

Definition at line 94 of file W3DRadar.h.

◆ m_textureHeight

Int W3DRadar::m_textureHeight
protected

height for all radar textures

Definition at line 107 of file W3DRadar.h.

◆ m_textureWidth

Int W3DRadar::m_textureWidth
protected

width for all radar textures

Definition at line 106 of file W3DRadar.h.

◆ m_viewAngle

Real W3DRadar::m_viewAngle
protected

camera angle used for the view box we have

Definition at line 117 of file W3DRadar.h.

◆ m_viewBox

ICoord2D W3DRadar::m_viewBox[4]
protected

radar cell points for the 4 corners of view box

Definition at line 119 of file W3DRadar.h.

◆ m_viewZoom

Real W3DRadar::m_viewZoom
protected

camera zoom used for the view box we have

Definition at line 118 of file W3DRadar.h.


The documentation for this class was generated from the following files: