/*
** Command & Conquer Generals(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. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: W3DWater.h ///////////////////////////////////////////////////
#pragma once
#ifndef __W3DWater_H_
#define __W3DWater_H_
#include "always.h"
#include "rendobj.h"
#include "w3d_file.h"
#include "dx8vertexbuffer.h"
#include "dx8indexbuffer.h"
#include "shader.h"
#include "vertmaterial.h"
#include "light.h"
#include "Lib/BaseType.h"
#include "Common/GameType.h"
#include "Common/Snapshot.h"
#define INVALID_WATER_HEIGHT 0.0f ///water height guaranteed to be below all terrain.
#define NUM_BUMP_FRAMES 32 ///number of animation frames in bump map
//Offsets in constant register file to Vertex shader constants
#define CV_ZERO 0
#define CV_ONE 1
#define CV_WORLDVIEWPROJ_0 2
#define CV_TEXPROJ_0 6
#define CV_PATCH_SCALE_OFFSET 10
class PolygonTrigger;
class WaterTracksRenderSystem;
class Xfer;
/// Custom render object that draws mirrors, water, and skies.
/**
This render object handles drawing reflected W3D scenes. It will only work
with rectangular planar surfaces and was tuned with an emphasis on water.
Since skies are only visible in reflections, this code will also
render clouds and sky bodies.
*/
class WaterRenderObjClass : public Snapshot,
public RenderObjClass
{
public:
enum WaterType
{
WATER_TYPE_0_TRANSLUCENT = 0, //translucent water, no reflection
WATER_TYPE_1_FB_REFLECTION, //legacy frame buffer reflection (non translucent)
WATER_TYPE_2_PVSHADER, //pixel/vertex shader, texture reflection
WATER_TYPE_3_GRIDMESH, //3D Mesh based water
WATER_TYPE_MAX // end of enumeration
};
WaterRenderObjClass(void);
~WaterRenderObjClass(void);
/////////////////////////////////////////////////////////////////////////////
// Render Object Interface (W3D methods)
/////////////////////////////////////////////////////////////////////////////
virtual RenderObjClass * Clone(void) const;
virtual int Class_ID(void) const;
virtual void Render(RenderInfoClass & rinfo);
/// @todo: Add methods for collision detection with water surface
// virtual Bool Cast_Ray(RayCollisionTestClass & raytest);
// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest);
// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest);
// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest);
// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest);
virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const;
// Get and set static sort level
virtual int Get_Sort_Level(void) const { return m_sortLevel; }
virtual void Set_Sort_Level(int level) { m_sortLevel = level;}
///allocate W3D resources needed to render water
void renderWater(void); /// m_gridCellsX-1 )
return FALSE;
if (gridY < 0)
return FALSE;
if (gridY > m_gridCellsY-1 )
return FALSE;
return TRUE;
}
extern WaterRenderObjClass *TheWaterRenderObj; ///