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

Custom render object that draws mirrors, water, and skies. More...

#include <W3DWater.h>

Inherits Snapshot, and RenderObjClass.

Classes

struct  SEA_PATCH_VERTEX
 
struct  Setting
 
struct  WaterMeshData
 

Public Types

enum  WaterType {
  WATER_TYPE_0_TRANSLUCENT = 0 , WATER_TYPE_1_FB_REFLECTION , WATER_TYPE_2_PVSHADER , WATER_TYPE_3_GRIDMESH ,
  WATER_TYPE_MAX
}
 
- Public Types inherited from RenderObjClass
enum  { USER_DATA_MATERIAL_OVERRIDE = 0x01234567 }
 
enum  {
  CLASSID_UNKNOWN = 0xFFFFFFFF , CLASSID_MESH = 0 , CLASSID_HMODEL , CLASSID_DISTLOD ,
  CLASSID_PREDLODGROUP , CLASSID_TILEMAP , CLASSID_IMAGE3D , CLASSID_LINE3D ,
  CLASSID_BITMAP2D , CLASSID_CAMERA , CLASSID_DYNAMESH , CLASSID_DYNASCREENMESH ,
  CLASSID_TEXTDRAW , CLASSID_FOG , CLASSID_LAYERFOG , CLASSID_LIGHT ,
  CLASSID_PARTICLEEMITTER , CLASSID_PARTICLEBUFFER , CLASSID_SCREENPOINTGROUP , CLASSID_VIEWPOINTGROUP ,
  CLASSID_WORLDPOINTGROUP , CLASSID_TEXT2D , CLASSID_TEXT3D , CLASSID_NULL ,
  CLASSID_COLLECTION , CLASSID_FLARE , CLASSID_HLOD , CLASSID_AABOX ,
  CLASSID_OBBOX , CLASSID_SEGLINE , CLASSID_SPHERE , CLASSID_RING ,
  CLASSID_BOUNDFOG , CLASSID_DAZZLE , CLASSID_SOUND , CLASSID_SEGLINETRAIL ,
  CLASSID_LAND , CLASSID_SHDMESH , CLASSID_LAST = 0x0000FFFF
}
 
enum  AnimMode {
  ANIM_MODE_MANUAL = 0 , ANIM_MODE_LOOP , ANIM_MODE_ONCE , ANIM_MODE_LOOP_PINGPONG ,
  ANIM_MODE_LOOP_BACKWARDS , ANIM_MODE_ONCE_BACKWARDS
}
 

Public Member Functions

 WaterRenderObjClass (void)
 
 ~WaterRenderObjClass (void)
 
virtual RenderObjClassClone (void) const
 
virtual int Class_ID (void) const
 
virtual void Render (RenderInfoClass &rinfo)
 
virtual void Get_Obj_Space_Bounding_Sphere (SphereClass &sphere) const
 
virtual void Get_Obj_Space_Bounding_Box (AABoxClass &aabox) const
 
virtual int Get_Sort_Level (void) const
 
virtual void Set_Sort_Level (int level)
 
void renderWater (void)
 allocate W3D resources needed to render water
 
Int init (Real waterLevel, Real dx, Real dy, SceneClass *parentScene, WaterType type)
 
void reset (void)
 reset any resources we need to
 
void load (void)
 load/setup any map dependent features
 
void update (void)
 update phase of the water
 
void enableWaterGrid (Bool state)
 used to active custom water for special maps. (i.e DAM).
 
void updateMapOverrides (void)
 used to update any map specific map overrides for water appearance.
 
void setTimeOfDay (TimeOfDay tod)
 change sky/water for time of day
 
void toggleCloudLayer (Bool state)
 enables/disables the cloud layer
 
void updateRenderTargetTextures (CameraClass *cam)
 renders into any required textures.
 
void ReleaseResources (void)
 Release all dx8 resources so the device can be reset.
 
void ReAcquireResources (void)
 Reacquire all resources after device reset.
 
Real getWaterHeight (Real x, Real y)
 return water height at given point - for use by WB.
 
void setGridHeightClamps (Real minz, Real maxz)
 set min/max height values alllowed in grid
 
void addVelocity (Real worldX, Real worldY, Real zVelocity, Real preferredHeight)
 add velocity value
 
void changeGridHeight (Real x, Real y, Real delta)
 change height of grid at world point including neighbors within falloff.
 
void setGridChangeAttenuationFactors (Real a, Real b, Real c, Real range)
 adjust falloff parameters for grid change method.
 
void setGridTransform (Real angle, Real x, Real y, Real z)
 positoin/orientation of grid in space
 
void setGridTransform (const Matrix3D *transform)
 set transform by matrix
 
void getGridTransform (Matrix3D *transform)
 get grid transform matrix
 
void setGridResolution (Real gridCellsX, Real gridCellsY, Real cellSize)
 grid resolution and spacing
 
void getGridResolution (Real *gridCellsX, Real *gridCellsY, Real *cellSize)
 get grid resolution params
 
void setGridVertexHeight (Int x, Int y, Real value)
 
void getGridVertexHeight (Int x, Int y, Real *value)
 
Bool worldToGridSpace (Real worldX, Real worldY, Real &gridX, Real &gridY)
 convert from world coordinates to grid's local coordinate system.
 
void replaceSkyboxTexture (const AsciiString &oldTexName, const AsciiString &newTextName)
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 
- Public Member Functions inherited from RenderObjClass
 RenderObjClass (void)
 
 RenderObjClass (const RenderObjClass &src)
 
RenderObjClassoperator= (const RenderObjClass &)
 
virtual ~RenderObjClass (void)
 
virtual const char * Get_Name (void) const
 
virtual void Set_Name (const char *name)
 
virtual const char * Get_Base_Model_Name (void) const
 
virtual void Set_Base_Model_Name (const char *name)
 
virtual int Get_Num_Polys (void) const
 
virtual void Special_Render (SpecialRenderInfoClass &rinfo)
 
virtual void On_Frame_Update ()
 
virtual void Restart (void)
 
virtual void Add (SceneClass *scene)
 
virtual void Remove (void)
 
virtual SceneClassGet_Scene (void)
 
virtual SceneClassPeek_Scene (void)
 
virtual void Set_Container (RenderObjClass *con)
 
virtual void Validate_Transform (void) const
 
RenderObjClassGet_Container (void) const
 
virtual void Set_Transform (const Matrix3D &m)
 
virtual void Set_Position (const Vector3 &v)
 
const Matrix3DGet_Transform (void) const
 
const Matrix3DGet_Transform (bool &is_transform_identity) const
 
const Matrix3DGet_Transform_No_Validity_Check (void) const
 
const Matrix3DGet_Transform_No_Validity_Check (bool &is_transform_identity) const
 
bool Is_Transform_Identity () const
 
bool Is_Transform_Identity_No_Validity_Check () const
 
Vector3 Get_Position (void) const
 
virtual void Notify_Added (SceneClass *scene)
 
virtual void Notify_Removed (SceneClass *scene)
 
virtual int Get_Num_Sub_Objects (void) const
 
virtual RenderObjClassGet_Sub_Object (int index) const
 
virtual int Add_Sub_Object (RenderObjClass *subobj)
 
virtual int Remove_Sub_Object (RenderObjClass *robj)
 
virtual RenderObjClassGet_Sub_Object_By_Name (const char *name, int *index=NULL) const
 
virtual int Get_Num_Sub_Objects_On_Bone (int boneindex) const
 
virtual RenderObjClassGet_Sub_Object_On_Bone (int index, int boneindex) const
 
virtual int Get_Sub_Object_Bone_Index (RenderObjClass *subobj) const
 
virtual int Get_Sub_Object_Bone_Index (int LodIndex, int ModelIndex) const
 
virtual int Add_Sub_Object_To_Bone (RenderObjClass *subobj, int bone_index)
 
virtual int Add_Sub_Object_To_Bone (RenderObjClass *subobj, const char *bname)
 
virtual int Remove_Sub_Objects_From_Bone (int boneindex)
 
virtual int Remove_Sub_Objects_From_Bone (const char *bname)
 
virtual void Update_Sub_Object_Transforms (void)
 
virtual void Set_Animation (void)
 
virtual void Set_Animation (HAnimClass *motion, float frame, int anim_mode=ANIM_MODE_MANUAL)
 
virtual void Set_Animation (HAnimClass *motion0, float frame0, HAnimClass *motion1, float frame1, float percentage)
 
virtual void Set_Animation (HAnimComboClass *anim_combo)
 
virtual HAnimClassPeek_Animation (void)
 
virtual int Get_Num_Bones (void)
 
virtual const char * Get_Bone_Name (int bone_index)
 
virtual int Get_Bone_Index (const char *bonename)
 
virtual const Matrix3DGet_Bone_Transform (const char *bonename)
 
virtual const Matrix3DGet_Bone_Transform (int boneindex)
 
virtual void Capture_Bone (int bindex)
 
virtual void Release_Bone (int bindex)
 
virtual bool Is_Bone_Captured (int bindex) const
 
virtual void Control_Bone (int bindex, const Matrix3D &objtm, bool world_space_translation=false)
 
virtual const HTreeClassGet_HTree (void) const
 
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 bool Intersect (IntersectionClass *Intersection, IntersectionResultClass *Final_Result)
 
virtual bool Intersect_Sphere (IntersectionClass *Intersection, IntersectionResultClass *Final_Result)
 
virtual bool Intersect_Sphere_Quick (IntersectionClass *Intersection, IntersectionResultClass *Final_Result)
 
virtual const SphereClassGet_Bounding_Sphere (void) const
 
virtual const AABoxClassGet_Bounding_Box (void) const
 
virtual void Update_Obj_Space_Bounding_Volumes (void)
 
virtual void Prepare_LOD (CameraClass &camera)
 
virtual void Recalculate_Static_LOD_Factors (void)
 
virtual void Increment_LOD (void)
 
virtual void Decrement_LOD (void)
 
virtual float Get_Cost (void) const
 
virtual float Get_Value (void) const
 
virtual float Get_Post_Increment_Value (void) const
 
virtual void Set_LOD_Level (int lod)
 
virtual int Get_LOD_Level (void) const
 
virtual int Get_LOD_Count (void) const
 
virtual void Set_LOD_Bias (float bias)
 
virtual int Calculate_Cost_Value_Arrays (float screen_area, float *values, float *costs) const
 
virtual RenderObjClassGet_Current_LOD (void)
 
virtual bool Build_Dependency_List (DynamicVectorClass< StringClass > &file_list, bool recursive=true)
 
virtual bool Build_Texture_List (DynamicVectorClass< StringClass > &texture_file_list, bool recursive=true)
 
virtual void Create_Decal (DecalGeneratorClass *generator)
 
virtual void Delete_Decal (uint32 decal_id)
 
virtual MaterialInfoClassGet_Material_Info (void)
 
virtual void Set_User_Data (void *value, bool recursive=false)
 
virtual void * Get_User_Data ()
 
virtual int Get_Num_Snap_Points (void)
 
virtual void Get_Snap_Point (int index, Vector3 *set)
 
virtual float Get_Screen_Size (CameraClass &camera)
 
virtual void Scale (float scale)
 
virtual void Scale (float scalex, float scaley, float scalez)
 
virtual void Set_ObjectScale (float scale)
 
const float Get_ObjectScale (void) const
 
void Set_ObjectColor (unsigned int color)
 
const unsigned int Get_ObjectColor (void) const
 
virtual int Is_Really_Visible (void)
 
virtual int Is_Not_Hidden_At_All (void)
 
virtual int Is_Visible (void) const
 
virtual void Set_Visible (int onoff)
 
virtual int Is_Hidden (void) const
 
virtual void Set_Hidden (int onoff)
 
virtual int Is_Animation_Hidden (void) const
 
virtual void Set_Animation_Hidden (int onoff)
 
virtual int Is_Force_Visible (void) const
 
virtual void Set_Force_Visible (int onoff)
 
virtual int Is_Translucent (void) const
 
virtual void Set_Translucent (int onoff)
 
virtual int Is_Alpha (void) const
 
virtual void Set_Alpha (int onoff)
 
virtual int Is_Additive (void) const
 
virtual void Set_Additive (int onoff)
 
virtual int Get_Collision_Type (void) const
 
virtual void Set_Collision_Type (int type)
 
virtual bool Is_Complete (void)
 
virtual bool Is_In_Scene (void)
 
virtual float Get_Native_Screen_Size (void) const
 
virtual void Set_Native_Screen_Size (float screensize)
 
void Set_Sub_Objects_Match_LOD (int onoff)
 
int Is_Sub_Objects_Match_LOD_Enabled (void)
 
void Set_Sub_Object_Transforms_Dirty (bool onoff)
 
bool Are_Sub_Object_Transforms_Dirty (void)
 
void Set_Ignore_LOD_Cost (bool onoff)
 
bool Is_Ignoring_LOD_Cost (void)
 
void Set_Is_Self_Shadowed ()
 
void Unset_Is_Self_Shadowed ()
 
int Is_Self_Shadowed () const
 
virtual const PersistFactoryClassGet_Factory (void) const
 
virtual bool Save (ChunkSaveClass &csave)
 
virtual bool Load (ChunkLoadClass &cload)
 
RenderHookClassGet_Render_Hook (void)
 
void Set_Render_Hook (RenderHookClass *hook)
 
- Public Member Functions inherited from RefCountClass
 RefCountClass (void)
 
 RefCountClass (const RefCountClass &)
 
void Add_Ref (void) const
 
WWINLINE void Release_Ref (void) const
 
int Num_Refs (void) const
 
virtual void Delete_This (void)
 
- Public Member Functions inherited from PostLoadableClass
 PostLoadableClass (void)
 
virtual ~PostLoadableClass (void)
 
virtual void On_Post_Load (void)
 
bool Is_Post_Load_Registered (void)
 
void Set_Post_Load_Registered (bool onoff)
 
- Public Member Functions inherited from MultiListObjectClass
 MultiListObjectClass (void)
 
virtual ~MultiListObjectClass (void)
 
MultiListNodeClassGet_List_Node () const
 
void Set_List_Node (MultiListNodeClass *node)
 

Protected Types

enum  WaterMeshStatus { AT_REST = 0x00 , IN_MOTION = 0x01 }
 
- Protected Types inherited from RenderObjClass
enum  {
  COLL_TYPE_MASK = 0x000000FF , IS_VISIBLE = 0x00000100 , IS_NOT_HIDDEN = 0x00000200 , IS_NOT_ANIMATION_HIDDEN = 0x00000400 ,
  IS_FORCE_VISIBLE = 0x00000800 , BOUNDING_VOLUMES_VALID = 0x00002000 , IS_TRANSLUCENT = 0x00004000 , IGNORE_LOD_COST = 0x00008000 ,
  SUBOBJS_MATCH_LOD = 0x00010000 , SUBOBJ_TRANSFORMS_DIRTY = 0x00020000 , IS_ALPHA = 0x00040000 , IS_ADDITIVE = 0x00100000 ,
  IS_SELF_SHADOWED = 0x00080000 , IS_CHEATER = 0x00100000 , IS_REALLY_VISIBLE = IS_VISIBLE | IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN , IS_NOT_HIDDEN_AT_ALL = IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN ,
  DEFAULT_BITS = COLL_TYPE_ALL | IS_NOT_HIDDEN | IS_NOT_ANIMATION_HIDDEN
}
 

Protected Member Functions

void drawRiverWater (PolygonTrigger *pTrig)
 
void drawTrapezoidWater (Vector3 points[4])
 
void loadSetting (Setting *skySetting, TimeOfDay timeOfDay)
 init sky/water settings from GDF
 
void renderSky (void)
 draw the sky layer (clouds, stars, etc.)
 
void testCurvedWater (void)
 draw the sky layer (clouds, stars, etc.)
 
void renderSkyBody (Matrix3D *mat)
 draw the sky body (sun, moon, etc.)
 
void renderWaterMesh (void)
 draw the water surface mesh (deformed 3d mesh).
 
HRESULT initBumpMap (LPDIRECT3DTEXTURE8 *pTex, TextureClass *pBumpSource)
 copies data into bump-map format.
 
void renderMirror (CameraClass *cam)
 Draw reflected scene into texture.
 
void drawSea (RenderInfoClass &rinfo)
 
Bool getClippedWaterPlane (CameraClass *cam, AABoxClass *box)
 bounding box of frustum clipped polygon plane
 
void setupFlatWaterShader (void)
 
void setupJbaWaterShader (void)
 
void cleanupJbaWaterShader (void)
 
HRESULT generateIndexBuffer (int sizeX, int sizeY)
 Generate static index buufer.
 
HRESULT generateVertexBuffer (Int sizeX, Int sizeY, Int vertexSize, Bool doFill)
 Generate static vertex buffer.
 
virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
- Protected Member Functions inherited from RenderObjClass
virtual void Add_Dependencies_To_List (DynamicVectorClass< StringClass > &file_list, bool textures_only=false)
 
virtual void Update_Cached_Bounding_Volumes (void) const
 
virtual void Update_Sub_Object_Bits (void)
 
bool Bounding_Volumes_Valid (void) const
 
void Invalidate_Cached_Bounding_Volumes (void) const
 
void Validate_Cached_Bounding_Volumes (void) const
 
- Protected Member Functions inherited from RefCountClass
virtual ~RefCountClass (void)
 

Protected Attributes

DX8IndexBufferClassm_indexBuffer
 indices defining quad
 
SceneClassm_parentScene
 scene to be reflected
 
ShaderClass m_shaderClass
 shader or rendering state for heightmap
 
VertexMaterialClassm_vertexMaterialClass
 vertex lighting material
 
VertexMaterialClassm_meshVertexMaterialClass
 vertex lighting marial for 3D water.
 
LightClassm_meshLight
 light used for 3D Mesh Water.
 
TextureClassm_alphaClippingTexture
 used for faked clipping using alpha
 
Real m_dx
 x extent of water surface (offset from local center)
 
Real m_dy
 y extent of water surface (offset from local center)
 
Vector3 m_planeNormal
 water plane normal
 
Real m_planeDistance
 water plane distance
 
Real m_level
 level of water (hack for water)
 
Real m_uOffset
 current texture offset on u axis
 
Real m_vOffset
 current texture offset on v axis
 
Real m_uScrollPerMs
 texels per/ms scroll rate in u direction
 
Real m_vScrollPerMs
 texels per/ms scroll rate in v direction
 
Int m_LastUpdateTime
 time of last cloud update
 
Bool m_useCloudLayer
 flag if clouds are on/off
 
WaterType m_waterType
 type of water being used
 
Int m_sortLevel
 sort order after main scene is rendered
 
LPDIRECT3DDEVICE8 m_pDev
 pointer to D3D Device
 
LPDIRECT3DVERTEXBUFFER8 m_vertexBufferD3D
 D3D vertex buffer.
 
LPDIRECT3DINDEXBUFFER8 m_indexBufferD3D
 D3D index buffer.
 
Int m_vertexBufferD3DOffset
 location to start writing vertices
 
DWORD m_dwWavePixelShader
 handle to D3D pixel shader
 
DWORD m_dwWaveVertexShader
 handle to D3D vertex shader
 
Int m_numVertices
 number of vertices in D3D vertex buffer
 
Int m_numIndices
 number of indices in D3D index buffer
 
LPDIRECT3DTEXTURE8 m_pBumpTexture [NUM_BUMP_FRAMES]
 animation frames
 
LPDIRECT3DTEXTURE8 m_pBumpTexture2 [NUM_BUMP_FRAMES]
 animation frames
 
Int m_iBumpFrame
 current animation frame
 
Real m_fBumpScale
 scales bump map uv perturbation
 
TextureClassm_pReflectionTexture
 render target for reflection
 
RenderObjClassm_skyBox
 box around level
 
WaterTracksRenderSystemm_waterTrackSystem
 object responsible for rendering water wakes
 
WaterMeshDatam_meshData
 heightmap data for 3D Mesh based water.
 
UnsignedInt m_meshDataSize
 size of m_meshData
 
Bool m_meshInMotion
 TRUE once we've messed with velocities and are in motion.
 
Bool m_doWaterGrid
 allows/prevents water grid rendering.
 
Vector2 m_gridDirectionX
 vector along water grid's x-axis (scaled to world-space)
 
Vector2 m_gridDirectionY
 vector along water grid's y-axis (scaled to world-space)
 
Vector2 m_gridOrigin
 unit vector along water grid's x-axis
 
Real m_gridWidth
 object-space width of water grid
 
Real m_gridHeight
 object-space width of water grid
 
Real m_minGridHeight
 minimum height value allowed for water mesh
 
Real m_maxGridHeight
 maximum height value allowed for water mesh
 
Real m_gridChangeMaxRange
 maximum range of changeGridHeight() method
 
Real m_gridChangeAtt0
 
Real m_gridChangeAtt1
 
Real m_gridChangeAtt2
 
Real m_gridCellSize
 world-space width/height of each cell.
 
Int m_gridCellsX
 number of cells along width
 
Int m_gridCellsY
 number of cells along height
 
Real m_riverVOrigin
 
TextureClassm_riverTexture
 
TextureClassm_whiteTexture
 a texture containing only white used for NULL pixel shader stages.
 
TextureClassm_waterNoiseTexture
 
DWORD m_waterPixelShader
 D3D handle to pixel shader.
 
DWORD m_riverWaterPixelShader
 D3D handle to pixel shader.
 
DWORD m_trapezoidWaterPixelShader
 handle to D3D vertex shader
 
TextureClassm_waterSparklesTexture
 
Real m_riverXOffset
 
Real m_riverYOffset
 
Bool m_drawingRiver
 
Bool m_disableRiver
 
TextureClassm_riverAlphaEdge
 
TimeOfDay m_tod
 time of day setting for reflected cloud layer
 
Setting m_settings [TIME_OF_DAY_COUNT]
 settings for each time of day
 
- Protected Attributes inherited from RenderObjClass
unsigned long Bits
 
Matrix3D Transform
 
float ObjectScale
 
unsigned int ObjectColor
 
SphereClass CachedBoundingSphere
 
AABoxClass CachedBoundingBox
 
float NativeScreenSize
 
bool IsTransformIdentity
 
SceneClassScene
 
RenderObjClassContainer
 
void * User_Data
 
RenderHookClassRenderHook
 

Additional Inherited Members

- Static Public Member Functions inherited from RefCountClass
static int Total_Refs (void)
 
static RefCountClassAdd_Active_Ref (RefCountClass *obj)
 
static RefCountClassSet_Ref_Owner (RefCountClass *obj, char *file, int line)
 
static void Remove_Active_Ref (RefCountClass *obj)
 
static bool Validate_Active_Ref (RefCountClass *obj)
 
- Public Attributes inherited from RefCountClass
RefCountNodeClass ActiveRefNode
 
ActiveRefStruct ActiveRefInfo
 
- Static Public Attributes inherited from RenderObjClass
static const float AT_MIN_LOD = FLT_MAX
 
static const float AT_MAX_LOD = -1.0f
 
- Static Public Attributes inherited from RefCountClass
static RefCountListClass ActiveRefList
 

Detailed Description

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.

Definition at line 64 of file W3DWater.h.

Member Enumeration Documentation

◆ WaterMeshStatus

Enumerator
AT_REST 
IN_MOTION 

Definition at line 178 of file W3DWater.h.

◆ WaterType

Enumerator
WATER_TYPE_0_TRANSLUCENT 
WATER_TYPE_1_FB_REFLECTION 
WATER_TYPE_2_PVSHADER 
WATER_TYPE_3_GRIDMESH 
WATER_TYPE_MAX 

Definition at line 70 of file W3DWater.h.

Constructor & Destructor Documentation

◆ WaterRenderObjClass()

WaterRenderObjClass::WaterRenderObjClass ( void )

Constructor. Just nulls out some variables.

<D3D handle to pixel shader.

<D3D handle to pixel shader.

<D3D handle to pixel shader.

Definition at line 328 of file W3DWater.cpp.

◆ ~WaterRenderObjClass()

WaterRenderObjClass::~WaterRenderObjClass ( void )

Destructor. Releases w3d assets.

Definition at line 280 of file W3DWater.cpp.

Member Function Documentation

◆ addVelocity()

void WaterRenderObjClass::addVelocity ( Real worldX,
Real worldY,
Real zVelocity,
Real preferredHeight )

add velocity value

Definition at line 2476 of file W3DWater.cpp.

◆ changeGridHeight()

void WaterRenderObjClass::changeGridHeight ( Real x,
Real y,
Real delta )

change height of grid at world point including neighbors within falloff.

Definition at line 2542 of file W3DWater.cpp.

◆ Class_ID()

Int WaterRenderObjClass::Class_ID ( void ) const
virtual

returns the class id, so the scene can tell what kind of render object it has.

Reimplemented from RenderObjClass.

Definition at line 412 of file W3DWater.cpp.

◆ cleanupJbaWaterShader()

void WaterRenderObjClass::cleanupJbaWaterShader ( void )
protected

◆ Clone()

RenderObjClass * WaterRenderObjClass::Clone ( void ) const
virtual

Not used, but required virtual method.

Implements RenderObjClass.

Definition at line 420 of file W3DWater.cpp.

◆ crc()

void WaterRenderObjClass::crc ( Xfer * xfer)
protectedvirtual

CRC

Implements Snapshot.

Definition at line 3446 of file W3DWater.cpp.

◆ drawRiverWater()

void WaterRenderObjClass::drawRiverWater ( PolygonTrigger * pTrig)
protected
Todo
: Figure out why rivers don't draw without reset of all states.

Definition at line 2714 of file W3DWater.cpp.

◆ drawSea()

void WaterRenderObjClass::drawSea ( RenderInfoClass & rinfo)
protected

Draw the surface of the water

Draws the water surface using a custom D3D vertex/pixel shader and a reflection texture. Only tested to work on GeForce3.

Definition at line 1790 of file W3DWater.cpp.

◆ drawTrapezoidWater()

void WaterRenderObjClass::drawTrapezoidWater ( Vector3 points[4])
protected

Definition at line 3046 of file W3DWater.cpp.

◆ enableWaterGrid()

void WaterRenderObjClass::enableWaterGrid ( Bool state)

used to active custom water for special maps. (i.e DAM).

Definition at line 1185 of file W3DWater.cpp.

◆ generateIndexBuffer()

HRESULT WaterRenderObjClass::generateIndexBuffer ( int sizeX,
int sizeY )
protected

Generate static index buufer.

Create and fill a D3D index buffer with water surface strip indices

Definition at line 704 of file W3DWater.cpp.

◆ generateVertexBuffer()

HRESULT WaterRenderObjClass::generateVertexBuffer ( Int sizeX,
Int sizeY,
Int vertexSize,
Bool doStatic )
protected

Generate static vertex buffer.

Create and fill a D3D vertex buffer with water surface vertices

Definition at line 625 of file W3DWater.cpp.

◆ Get_Obj_Space_Bounding_Box()

void WaterRenderObjClass::Get_Obj_Space_Bounding_Box ( AABoxClass & box) const
virtual

WW3D method that returns object bounding box used in collision detection

Reimplemented from RenderObjClass.

Definition at line 398 of file W3DWater.cpp.

◆ Get_Obj_Space_Bounding_Sphere()

void WaterRenderObjClass::Get_Obj_Space_Bounding_Sphere ( SphereClass & sphere) const
virtual
Todo
: Add methods for collision detection with water surface

WW3D method that returns object bounding sphere used in frustum culling

Reimplemented from RenderObjClass.

Definition at line 384 of file W3DWater.cpp.

◆ Get_Sort_Level()

virtual int WaterRenderObjClass::Get_Sort_Level ( void ) const
inlinevirtual

Reimplemented from RenderObjClass.

Definition at line 98 of file W3DWater.h.

◆ getClippedWaterPlane()

Bool WaterRenderObjClass::getClippedWaterPlane ( CameraClass * cam,
AABoxClass * box )
protected

bounding box of frustum clipped polygon plane

Clips the water plane to the current camera frustum and returns a bounding box enclosing the clipped plane. Returns false if water plane is not visible.

Todo
: generate proper sized polygon

Definition at line 1750 of file W3DWater.cpp.

◆ getGridResolution()

void WaterRenderObjClass::getGridResolution ( Real * gridCellsX,
Real * gridCellsY,
Real * cellSize )

get grid resolution params

Definition at line 2654 of file W3DWater.cpp.

◆ getGridTransform()

void WaterRenderObjClass::getGridTransform ( Matrix3D * transform)

get grid transform matrix

Definition at line 2622 of file W3DWater.cpp.

◆ getGridVertexHeight()

void WaterRenderObjClass::getGridVertexHeight ( Int x,
Int y,
Real * value )
inline

Definition at line 125 of file W3DWater.h.

◆ getWaterHeight()

Real WaterRenderObjClass::getWaterHeight ( Real x,
Real y )

return water height at given point - for use by WB.

Utility function used to query water heights in a manner that works in both RTS and WB.

Definition at line 2674 of file W3DWater.cpp.

◆ init()

Int WaterRenderObjClass::init ( Real waterLevel,
Real dx,
Real dy,
SceneClass * parentScene,
WaterType type )

Initializes water with dimensions and parent scene. During rendering, we will render a water surface of given dimensions and reflect the parent scene in its surface. For now, waters are forced to be rectangles.

Hack for now

Todo
: calculate a real normal/distance for arbitrary planes.

Definition at line 991 of file W3DWater.cpp.

◆ initBumpMap()

HRESULT WaterRenderObjClass::initBumpMap ( LPDIRECT3DTEXTURE8 * pTex,
TextureClass * pBumpSource )
protected

copies data into bump-map format.

Copies raw bits from pBumpSrc (a regular grayscale texture) into a D3D bump-map format.

Definition at line 430 of file W3DWater.cpp.

◆ load()

void WaterRenderObjClass::load ( void )

load/setup any map dependent features

Definition at line 979 of file W3DWater.cpp.

◆ loadPostProcess()

void WaterRenderObjClass::loadPostProcess ( void )
protectedvirtual

Load post process

Implements Snapshot.

Definition at line 3509 of file W3DWater.cpp.

◆ loadSetting()

void WaterRenderObjClass::loadSetting ( Setting * setting,
TimeOfDay timeOfDay )
protected

init sky/water settings from GDF

Copies GDF settings dealing with a particular time of day into our own structures. Also allocates any required W3D assets (textures).

Definition at line 1363 of file W3DWater.cpp.

◆ ReAcquireResources()

void WaterRenderObjClass::ReAcquireResources ( void )

Reacquire all resources after device reset.

(Re)allocates all W3D assets after a reset..

Definition at line 843 of file W3DWater.cpp.

◆ ReleaseResources()

void WaterRenderObjClass::ReleaseResources ( void )

Release all dx8 resources so the device can be reset.

Releases all w3d assets, to prepare for Reset device call.

Definition at line 806 of file W3DWater.cpp.

◆ Render()

void WaterRenderObjClass::Render ( RenderInfoClass & rinfo)
virtual

Renders (draws) the water. Algorithm: Draw reflected scene. Draw reflected sky layer(s) and bodies. Clear Zbuffer Fill Zbuffer by drawing water surface (allows proper sorting into regular scene). Draw non-reflected scene (done in regular app render loop).

This algorithm doesn't apply to translucent water, which is rendered into a texture and rendered at end of scene.

Implements RenderObjClass.

Definition at line 1523 of file W3DWater.cpp.

◆ renderMirror()

void WaterRenderObjClass::renderMirror ( CameraClass * cam)
protected

Draw reflected scene into texture.

Renders the reflected scene into an offscreen texture.

Definition at line 1435 of file W3DWater.cpp.

◆ renderSky()

void WaterRenderObjClass::renderSky ( void )
protected

draw the sky layer (clouds, stars, etc.)

Renders (draws) the sky plane. Will apply current time-of-day settings including some simple UV scrolling animation.

Definition at line 2050 of file W3DWater.cpp.

◆ renderSkyBody()

void WaterRenderObjClass::renderSkyBody ( Matrix3D * mat)
protected

draw the sky body (sun, moon, etc.)

Renders (draws) the sky body. Used for moon and sun. We rotate the image so that it always faces the camera. This removes perspective and helps hide that it's a flat image.

Todo
: Add code to render properly sorted sun sky body.
Todo
: hacked so only works for reflections across xy plane

Definition at line 2139 of file W3DWater.cpp.

◆ renderWater()

void WaterRenderObjClass::renderWater ( void )

allocate W3D resources needed to render water

draw the water surface (flat)

Renders (draws) the water surface.

Definition at line 2002 of file W3DWater.cpp.

◆ renderWaterMesh()

void WaterRenderObjClass::renderWaterMesh ( void )
protected

draw the water surface mesh (deformed 3d mesh).

Renders (draws) the water surface mesh geometry. This is a work-in-progress! Do not use this code!

Definition at line 2242 of file W3DWater.cpp.

◆ replaceSkyboxTexture()

void WaterRenderObjClass::replaceSkyboxTexture ( const AsciiString & oldTexName,
const AsciiString & newTextName )

Definition at line 1325 of file W3DWater.cpp.

◆ reset()

void WaterRenderObjClass::reset ( void )

reset any resources we need to

Definition at line 1145 of file W3DWater.cpp.

◆ Set_Sort_Level()

virtual void WaterRenderObjClass::Set_Sort_Level ( int level)
inlinevirtual

Reimplemented from RenderObjClass.

Definition at line 99 of file W3DWater.h.

◆ setGridChangeAttenuationFactors()

void WaterRenderObjClass::setGridChangeAttenuationFactors ( Real a,
Real b,
Real c,
Real range )

adjust falloff parameters for grid change method.

Definition at line 2586 of file W3DWater.cpp.

◆ setGridHeightClamps()

void WaterRenderObjClass::setGridHeightClamps ( Real minz,
Real maxz )

set min/max height values alllowed in grid

Definition at line 2470 of file W3DWater.cpp.

◆ setGridResolution()

void WaterRenderObjClass::setGridResolution ( Real gridCellsX,
Real gridCellsY,
Real cellSize )

grid resolution and spacing

Definition at line 2630 of file W3DWater.cpp.

◆ setGridTransform() [1/2]

void WaterRenderObjClass::setGridTransform ( const Matrix3D * transform)

set transform by matrix

Definition at line 2614 of file W3DWater.cpp.

◆ setGridTransform() [2/2]

void WaterRenderObjClass::setGridTransform ( Real angle,
Real x,
Real y,
Real z )

positoin/orientation of grid in space

Definition at line 2594 of file W3DWater.cpp.

◆ setGridVertexHeight()

void WaterRenderObjClass::setGridVertexHeight ( Int x,
Int y,
Real value )
inline

Definition at line 2460 of file W3DWater.cpp.

◆ setTimeOfDay()

void WaterRenderObjClass::setTimeOfDay ( TimeOfDay tod)

change sky/water for time of day

Adjusts various water/sky rendering settings that depend on time of day.

Definition at line 1352 of file W3DWater.cpp.

◆ setupFlatWaterShader()

void WaterRenderObjClass::setupFlatWaterShader ( void )
protected

Definition at line 2948 of file W3DWater.cpp.

◆ setupJbaWaterShader()

void WaterRenderObjClass::setupJbaWaterShader ( void )
protected

Definition at line 197 of file W3DWater.cpp.

◆ testCurvedWater()

void WaterRenderObjClass::testCurvedWater ( void )
protected

draw the sky layer (clouds, stars, etc.)

◆ toggleCloudLayer()

void WaterRenderObjClass::toggleCloudLayer ( Bool state)
inline

enables/disables the cloud layer

Definition at line 110 of file W3DWater.h.

◆ update()

void WaterRenderObjClass::update ( void )

update phase of the water

Update phase for water if we need it. This called once per client frame reguardless of how fast the logic framerate is running

< this is close enough to at rest

< when we're close enought to at rest height and velocity we will stop

< use with up force of 15.0

Definition at line 1217 of file W3DWater.cpp.

◆ updateMapOverrides()

void WaterRenderObjClass::updateMapOverrides ( void )

used to update any map specific map overrides for water appearance.

Definition at line 1134 of file W3DWater.cpp.

◆ updateRenderTargetTextures()

void WaterRenderObjClass::updateRenderTargetTextures ( CameraClass * cam)

renders into any required textures.

Our water may use effects that require run-time rendered textures. These textures need to be updated before we start rendering to the main screen render target because D3D doesn't multiple render targets.

Definition at line 1425 of file W3DWater.cpp.

◆ worldToGridSpace()

Bool WaterRenderObjClass::worldToGridSpace ( Real worldX,
Real worldY,
Real & gridX,
Real & gridY )
inline

convert from world coordinates to grid's local coordinate system.

Definition at line 272 of file W3DWater.h.

◆ xfer()

void WaterRenderObjClass::xfer ( Xfer * xfer)
protectedvirtual

Xfer Version Info: 1: Initial version

Implements Snapshot.

Definition at line 3456 of file W3DWater.cpp.

Member Data Documentation

◆ m_alphaClippingTexture

TextureClass* WaterRenderObjClass::m_alphaClippingTexture
protected

used for faked clipping using alpha

Definition at line 138 of file W3DWater.h.

◆ m_disableRiver

Bool WaterRenderObjClass::m_disableRiver
protected

Definition at line 221 of file W3DWater.h.

◆ m_doWaterGrid

Bool WaterRenderObjClass::m_doWaterGrid
protected

allows/prevents water grid rendering.

Definition at line 193 of file W3DWater.h.

◆ m_drawingRiver

Bool WaterRenderObjClass::m_drawingRiver
protected

Definition at line 220 of file W3DWater.h.

◆ m_dwWavePixelShader

DWORD WaterRenderObjClass::m_dwWavePixelShader
protected

handle to D3D pixel shader

Definition at line 166 of file W3DWater.h.

◆ m_dwWaveVertexShader

DWORD WaterRenderObjClass::m_dwWaveVertexShader
protected

handle to D3D vertex shader

Definition at line 167 of file W3DWater.h.

◆ m_dx

Real WaterRenderObjClass::m_dx
protected

x extent of water surface (offset from local center)

Definition at line 139 of file W3DWater.h.

◆ m_dy

Real WaterRenderObjClass::m_dy
protected

y extent of water surface (offset from local center)

Definition at line 140 of file W3DWater.h.

◆ m_fBumpScale

Real WaterRenderObjClass::m_fBumpScale
protected

scales bump map uv perturbation

Definition at line 173 of file W3DWater.h.

◆ m_gridCellSize

Real WaterRenderObjClass::m_gridCellSize
protected

world-space width/height of each cell.

Definition at line 206 of file W3DWater.h.

◆ m_gridCellsX

Int WaterRenderObjClass::m_gridCellsX
protected

number of cells along width

Definition at line 207 of file W3DWater.h.

◆ m_gridCellsY

Int WaterRenderObjClass::m_gridCellsY
protected

number of cells along height

Definition at line 208 of file W3DWater.h.

◆ m_gridChangeAtt0

Real WaterRenderObjClass::m_gridChangeAtt0
protected

Definition at line 203 of file W3DWater.h.

◆ m_gridChangeAtt1

Real WaterRenderObjClass::m_gridChangeAtt1
protected

Definition at line 204 of file W3DWater.h.

◆ m_gridChangeAtt2

Real WaterRenderObjClass::m_gridChangeAtt2
protected

Definition at line 205 of file W3DWater.h.

◆ m_gridChangeMaxRange

Real WaterRenderObjClass::m_gridChangeMaxRange
protected

maximum range of changeGridHeight() method

Definition at line 202 of file W3DWater.h.

◆ m_gridDirectionX

Vector2 WaterRenderObjClass::m_gridDirectionX
protected

vector along water grid's x-axis (scaled to world-space)

Definition at line 195 of file W3DWater.h.

◆ m_gridDirectionY

Vector2 WaterRenderObjClass::m_gridDirectionY
protected

vector along water grid's y-axis (scaled to world-space)

Definition at line 196 of file W3DWater.h.

◆ m_gridHeight

Real WaterRenderObjClass::m_gridHeight
protected

object-space width of water grid

Definition at line 199 of file W3DWater.h.

◆ m_gridOrigin

Vector2 WaterRenderObjClass::m_gridOrigin
protected

unit vector along water grid's x-axis

Definition at line 197 of file W3DWater.h.

◆ m_gridWidth

Real WaterRenderObjClass::m_gridWidth
protected

object-space width of water grid

Definition at line 198 of file W3DWater.h.

◆ m_iBumpFrame

Int WaterRenderObjClass::m_iBumpFrame
protected

current animation frame

Definition at line 172 of file W3DWater.h.

◆ m_indexBuffer

DX8IndexBufferClass* WaterRenderObjClass::m_indexBuffer
protected

indices defining quad

Definition at line 132 of file W3DWater.h.

◆ m_indexBufferD3D

LPDIRECT3DINDEXBUFFER8 WaterRenderObjClass::m_indexBufferD3D
protected

D3D index buffer.

Definition at line 164 of file W3DWater.h.

◆ m_LastUpdateTime

Int WaterRenderObjClass::m_LastUpdateTime
protected

time of last cloud update

Definition at line 148 of file W3DWater.h.

◆ m_level

Real WaterRenderObjClass::m_level
protected

level of water (hack for water)

Definition at line 143 of file W3DWater.h.

◆ m_maxGridHeight

Real WaterRenderObjClass::m_maxGridHeight
protected

maximum height value allowed for water mesh

Definition at line 201 of file W3DWater.h.

◆ m_meshData

WaterMeshData* WaterRenderObjClass::m_meshData
protected

heightmap data for 3D Mesh based water.

Definition at line 190 of file W3DWater.h.

◆ m_meshDataSize

UnsignedInt WaterRenderObjClass::m_meshDataSize
protected

size of m_meshData

Definition at line 191 of file W3DWater.h.

◆ m_meshInMotion

Bool WaterRenderObjClass::m_meshInMotion
protected

TRUE once we've messed with velocities and are in motion.

Definition at line 192 of file W3DWater.h.

◆ m_meshLight

LightClass* WaterRenderObjClass::m_meshLight
protected

light used for 3D Mesh Water.

Definition at line 137 of file W3DWater.h.

◆ m_meshVertexMaterialClass

VertexMaterialClass* WaterRenderObjClass::m_meshVertexMaterialClass
protected

vertex lighting marial for 3D water.

Definition at line 136 of file W3DWater.h.

◆ m_minGridHeight

Real WaterRenderObjClass::m_minGridHeight
protected

minimum height value allowed for water mesh

Definition at line 200 of file W3DWater.h.

◆ m_numIndices

Int WaterRenderObjClass::m_numIndices
protected

number of indices in D3D index buffer

Definition at line 169 of file W3DWater.h.

◆ m_numVertices

Int WaterRenderObjClass::m_numVertices
protected

number of vertices in D3D vertex buffer

Definition at line 168 of file W3DWater.h.

◆ m_parentScene

SceneClass* WaterRenderObjClass::m_parentScene
protected

scene to be reflected

Definition at line 133 of file W3DWater.h.

◆ m_pBumpTexture

LPDIRECT3DTEXTURE8 WaterRenderObjClass::m_pBumpTexture[NUM_BUMP_FRAMES]
protected

animation frames

Definition at line 170 of file W3DWater.h.

◆ m_pBumpTexture2

LPDIRECT3DTEXTURE8 WaterRenderObjClass::m_pBumpTexture2[NUM_BUMP_FRAMES]
protected

animation frames

Definition at line 171 of file W3DWater.h.

◆ m_pDev

LPDIRECT3DDEVICE8 WaterRenderObjClass::m_pDev
protected

pointer to D3D Device

Definition at line 162 of file W3DWater.h.

◆ m_planeDistance

Real WaterRenderObjClass::m_planeDistance
protected

water plane distance

Definition at line 142 of file W3DWater.h.

◆ m_planeNormal

Vector3 WaterRenderObjClass::m_planeNormal
protected

water plane normal

Definition at line 141 of file W3DWater.h.

◆ m_pReflectionTexture

TextureClass* WaterRenderObjClass::m_pReflectionTexture
protected

render target for reflection

Definition at line 174 of file W3DWater.h.

◆ m_riverAlphaEdge

TextureClass* WaterRenderObjClass::m_riverAlphaEdge
protected

Definition at line 222 of file W3DWater.h.

◆ m_riverTexture

TextureClass* WaterRenderObjClass::m_riverTexture
protected

Definition at line 211 of file W3DWater.h.

◆ m_riverVOrigin

Real WaterRenderObjClass::m_riverVOrigin
protected

Definition at line 210 of file W3DWater.h.

◆ m_riverWaterPixelShader

DWORD WaterRenderObjClass::m_riverWaterPixelShader
protected

D3D handle to pixel shader.

Definition at line 215 of file W3DWater.h.

◆ m_riverXOffset

Real WaterRenderObjClass::m_riverXOffset
protected

Definition at line 218 of file W3DWater.h.

◆ m_riverYOffset

Real WaterRenderObjClass::m_riverYOffset
protected

Definition at line 219 of file W3DWater.h.

◆ m_settings

Setting WaterRenderObjClass::m_settings[TIME_OF_DAY_COUNT]
protected

settings for each time of day

Definition at line 242 of file W3DWater.h.

◆ m_shaderClass

ShaderClass WaterRenderObjClass::m_shaderClass
protected

shader or rendering state for heightmap

Definition at line 134 of file W3DWater.h.

◆ m_skyBox

RenderObjClass* WaterRenderObjClass::m_skyBox
protected

box around level

Definition at line 175 of file W3DWater.h.

◆ m_sortLevel

Int WaterRenderObjClass::m_sortLevel
protected

sort order after main scene is rendered

Definition at line 151 of file W3DWater.h.

◆ m_tod

TimeOfDay WaterRenderObjClass::m_tod
protected

time of day setting for reflected cloud layer

Definition at line 224 of file W3DWater.h.

◆ m_trapezoidWaterPixelShader

DWORD WaterRenderObjClass::m_trapezoidWaterPixelShader
protected

handle to D3D vertex shader

Definition at line 216 of file W3DWater.h.

◆ m_uOffset

Real WaterRenderObjClass::m_uOffset
protected

current texture offset on u axis

Definition at line 144 of file W3DWater.h.

◆ m_uScrollPerMs

Real WaterRenderObjClass::m_uScrollPerMs
protected

texels per/ms scroll rate in u direction

Definition at line 146 of file W3DWater.h.

◆ m_useCloudLayer

Bool WaterRenderObjClass::m_useCloudLayer
protected

flag if clouds are on/off

Definition at line 149 of file W3DWater.h.

◆ m_vertexBufferD3D

LPDIRECT3DVERTEXBUFFER8 WaterRenderObjClass::m_vertexBufferD3D
protected

D3D vertex buffer.

Definition at line 163 of file W3DWater.h.

◆ m_vertexBufferD3DOffset

Int WaterRenderObjClass::m_vertexBufferD3DOffset
protected

location to start writing vertices

Definition at line 165 of file W3DWater.h.

◆ m_vertexMaterialClass

VertexMaterialClass* WaterRenderObjClass::m_vertexMaterialClass
protected

vertex lighting material

Definition at line 135 of file W3DWater.h.

◆ m_vOffset

Real WaterRenderObjClass::m_vOffset
protected

current texture offset on v axis

Definition at line 145 of file W3DWater.h.

◆ m_vScrollPerMs

Real WaterRenderObjClass::m_vScrollPerMs
protected

texels per/ms scroll rate in v direction

Definition at line 147 of file W3DWater.h.

◆ m_waterNoiseTexture

TextureClass* WaterRenderObjClass::m_waterNoiseTexture
protected

Definition at line 213 of file W3DWater.h.

◆ m_waterPixelShader

DWORD WaterRenderObjClass::m_waterPixelShader
protected

D3D handle to pixel shader.

Definition at line 214 of file W3DWater.h.

◆ m_waterSparklesTexture

TextureClass* WaterRenderObjClass::m_waterSparklesTexture
protected

Definition at line 217 of file W3DWater.h.

◆ m_waterTrackSystem

WaterTracksRenderSystem* WaterRenderObjClass::m_waterTrackSystem
protected

object responsible for rendering water wakes

Definition at line 176 of file W3DWater.h.

◆ m_waterType

WaterType WaterRenderObjClass::m_waterType
protected

type of water being used

Definition at line 150 of file W3DWater.h.

◆ m_whiteTexture

TextureClass* WaterRenderObjClass::m_whiteTexture
protected

a texture containing only white used for NULL pixel shader stages.

Definition at line 212 of file W3DWater.h.


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