Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

5.9 KB
Raw Blame
/*
**	Command & Conquer Generals Zero Hour(tm)
**	Copyright 2025 Electronic Arts Inc.
**
**	This program is free software: you can redistribute it and/or modify
**	it under the terms of the GNU General Public License as published by
**	the Free Software Foundation, either version 3 of the License, or
**	(at your option) any later version.
**
**	This program is distributed in the hope that it will be useful,
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**	GNU General Public License for more details.
**
**	You should have received a copy of the GNU General Public License
**	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
// Modified 2026 by İlyas Akın for the macOS/Linux port; see NOTICE.md and the git history.

////////////////////////////////////////////////////////////////////////////////
//																																						//
//  (c) 2001-2003 Electronic Arts Inc.																				//
//																																						//
////////////////////////////////////////////////////////////////////////////////

// FILE: W3DTerrainVisual.h ///////////////////////////////////////////////////////////////////////
// W3D implementation details for visual aspects of terrain
// Author: Colin Day, April 2001
///////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef __W3DTERRAINVISUAL_H_
#define __W3DTERRAINVISUAL_H_

#include "GameClient/TerrainVisual.h"
#include "W3DDevice/GameClient/W3DWater.h"

// FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
class Matrix3D;
class WaterHandle;
class BaseHeightMapRenderObjClass;
class WorldHeightMap;







//-------------------------------------------------------------------------------------------------
/** W3D impelmentation of visual terrain details singleton */
//-------------------------------------------------------------------------------------------------
class W3DTerrainVisual : public TerrainVisual
{

public:

	W3DTerrainVisual();
	virtual ~W3DTerrainVisual();

	virtual void init( void );
	virtual void reset( void );
	virtual void update( void );
	
	virtual Bool load( AsciiString filename );
	virtual void prewarmMapRenderData( void );

	void getTerrainColorAt( Real x, Real y, RGBColor *pColor );

	/// get the terrain tile type at the world location in the (x,y) plane ignoring Z
	TerrainType *getTerrainTile( Real x, Real y );

	/** intersect the ray with the terrain, if a hit occurs TRUE is returned
	and the result point on the terrain is returned in "result" */
	virtual Bool intersectTerrain( Coord3D *rayStart, Coord3D *rayEnd, Coord3D *result );

	//
	// water methods
	//
	/// the water grid was enabled/disabled (TerrainLogic's WaterGrid holds it)
	virtual void enableWaterGrid( Bool enable );

	virtual void setTerrainTracksDetail(void);
	virtual void setShoreLineDetail(void);

	/// Add a bib at location.  
	void addFactionBib(Object *factionBuilding, Bool highlight, Real extra = 0);
	/// Remove a bib.  
	void removeFactionBib(Object *factionBuilding);

	/// Add a bib at location.  
	void addFactionBibDrawable(Drawable *factionBuilding, Bool highlight, Real extra = 0);
	/// Remove a bib.  
	void removeFactionBibDrawable(Drawable *factionBuilding);

	virtual void removeAllBibs(void);
	virtual void removeBibHighlighting(void);

	virtual void addProp(const ThingTemplate *tt, const Coord3D *pos, Real angle);

	virtual void removeTreesAndPropsForConstruction(
		const Coord3D* pos, 
		const GeometryInfo& geom,
		Real angle
	);


	//
	// Modify height.
	//
	virtual void setRawMapHeight(const ICoord2D *gridPos, Int height);
	virtual Int getRawMapHeight(const ICoord2D *gridPos);

	/// Replace the skybox texture
	virtual void replaceSkyboxTextures(const AsciiString *oldTexName[NumSkyboxTextures], const AsciiString *newTexName[NumSkyboxTextures]);

  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
#ifdef DO_SEISMIC_SIMULATIONS
  virtual void addSeismicSimulation( const SeismicSimulationNode& sim );
#endif
  WorldHeightMap* getLogicHeightMap( void ) {return m_logicHeightMap;};
  WorldHeightMap* getClientHeightMap( void ) 
  {
#ifdef DO_SEISMIC_SIMULATIONS
    return m_clientHeightMap;
#else
    return m_logicHeightMap;
#endif
  } 
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////




protected:

	// snapshot methods
	virtual void crc( Xfer *xfer );
	virtual void xfer( Xfer *xfer );
	virtual void loadPostProcess( void );



#ifdef DO_SEISMIC_SIMULATIONS
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
  virtual void handleSeismicSimulations( void );
  SeismicSimulationList m_seismicSimulationList;
  virtual void updateSeismicSimulations( void ); /// walk the SeismicSimulationList and, well, do it.

  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
  ////////////////////////////////////////////////////
#endif



	BaseHeightMapRenderObjClass *m_terrainRenderObject;  ///< W3D render object for terrain
	WaterRenderObjClass	*m_waterRenderObject;	///< W3D render object for water plane

  WorldHeightMap *m_logicHeightMap;  ///< height map used for render obj building
  
#ifdef DO_SEISMIC_SIMULATIONS
  WorldHeightMap *m_clientHeightMap; ///< this is a workspace for animating the terrain elevations
#endif

  AsciiString	m_currentSkyboxTexNames[NumSkyboxTextures];	///<store current texture names applied to skybox.
	AsciiString m_initialSkyboxTexNames[NumSkyboxTextures];	///<store starting texture/default skybox textures.




};  // end class W3DTerrainVisual

#endif  // end __W3DTERRAINVISUAL_H_