/* ** 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 . */ //////////////////////////////////////////////////////////////////////////////// // // // (c) 2001-2003 Electronic Arts Inc. // // // //////////////////////////////////////////////////////////////////////////////// #pragma once #ifndef __BASE_HEIGHTMAP_H_ #define __BASE_HEIGHTMAP_H_ #include "always.h" #include "rendobj.h" #include "w3d_file.h" #include "dx8vertexbuffer.h" #include "dx8indexbuffer.h" #include "dx8wrapper.h" #include "shader.h" #include "vertmaterial.h" #include "Lib/BaseType.h" #include "common/GameType.h" #include "WorldHeightMap.h" #define MAX_ENABLED_DYNAMIC_LIGHTS 20 typedef UnsignedByte HeightSampleType; //type of data to store in heightmap class W3DTreeBuffer; class W3DBibBuffer; class W3DRoadBuffer; class W3DBridgeBuffer; class W3DWaypointBuffer; class W3DTerrainLogic; class W3DAssetManager; class SimpleSceneClass; class W3DShroud; class W3DPropDrawModuleData; class W3DPropBuffer; class W3DTreeDrawModuleData; class GeometryInfo; #define no_TIMING_TESTS 1 #define no_PRE_TRANSFORM_VERTEX // Don't do this, not a performance win. jba. typedef struct { Int minX, maxX; Int minY, maxY; } TBounds; class LightMapTerrainTextureClass; class CloudMapTerrainTextureClass; class W3DDynamicLight; #define DO_SCORCH 1 #define DO_ROADS 1 #ifdef DO_SCORCH typedef struct { Vector3 location; Real radius; Int scorchType; } TScorch; #endif #define VERTEX_FORMAT VertexFormatXYZDUV2 #define DX8_VERTEX_FORMAT DX8_FVF_XYZDUV2 /// Custom render object that draws the heightmap and handles intersection tests. /** Custom W3D render object that's used to process the terrain. It handles virtually everything to do with the terrain, including: drawing, lighting, scorchmarks and intersection tests. */ class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHook, public Snapshot { public: BaseHeightMapRenderObjClass(void); virtual ~BaseHeightMapRenderObjClass(void); // DX8_CleanupHook methods virtual void ReleaseResources(void); ///< Release all dx8 resources so the device can be reset. virtual void ReAcquireResources(void); ///< Reacquire all resources after device reset. ///////////////////////////////////////////////////////////////////////////// // Render Object Interface (W3D methods) ///////////////////////////////////////////////////////////////////////////// virtual RenderObjClass * Clone(void) const; virtual int Class_ID(void) const; virtual void Render(RenderInfoClass & rinfo) = 0; virtual bool Cast_Ray(RayCollisionTestClass & raytest); // This CANNOT be Bool, as it will not inherit properly if you make Bool == Int virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const; virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const; virtual void On_Frame_Update(void); virtual void Notify_Added(SceneClass * scene); // Other VIRTUAL methods. [3/20/2003] ///allocate resources needed to render heightmap virtual int initHeightData(Int width, Int height, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator, Bool updateExtraPassTiles=TRUE); virtual Int freeMapResources(void); ///< free resources used to render heightmap virtual void updateCenter(CameraClass *camera, RefRenderObjListIterator *pLightsIterator); virtual void adjustTerrainLOD(Int adj); virtual void doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, RefRenderObjListIterator *pLightsIterator) = 0; virtual void staticLightingChanged(void); virtual void oversizeTerrain(Int tilesToOversize); virtual void reset(void); void redirectToHeightmap( WorldHeightMap *pMap ) { REF_PTR_RELEASE( m_map ); REF_PTR_SET(m_map, pMap); //update our heightmap pointer in case it changed since last call. } inline UnsignedByte getClipHeight(Int x, Int y) const { Int xextent = m_map->getXExtent() - 1; Int yextent = m_map->getYExtent() - 1; if (x < 0) x = 0; else if (x > xextent) x = xextent; if (y < 0) y = 0; else if (y > yextent) y = yextent; return m_map->getDataPtr()[x + y*m_map->getXExtent()]; } /// Update the macro texture (pass 3). void setTextureLOD(Int lod); /// m_showAsVisibleCliff; ShaderClass m_shaderClass; ///