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

#include <W3DTreeBuffer.h>

Inherits Snapshot.

Public Member Functions

 W3DTreeBuffer (void)
 
 ~W3DTreeBuffer (void)
 
void addTree (DrawableID id, Coord3D location, Real scale, Real angle, Real randomScaleAmount, const W3DTreeDrawModuleData *data)
 Add a tree at location. Name is the w3d model name.
 
void unitMoved (Object *unit)
 Notify that an object moved, so check for collisions.
 
Int addTreeType (const W3DTreeDrawModuleData *data)
 Add a type of tree. Name is the w3d model name.
 
Bool updateTreePosition (DrawableID id, Coord3D location, Real angle)
 Updates a tree's location.
 
void pushAsideTree (DrawableID id, const Coord3D *pusherPos, const Coord3D *pusherDirection, ObjectID pusherID)
 
void removeTree (DrawableID id)
 Remove a tree.
 
void removeTreesForConstruction (const Coord3D *pos, const GeometryInfo &geom, Real angle)
 Remove trees that would be under a building.
 
void setTextureLOD (Int lod)
 
void clearAllTrees (void)
 Empties the tree buffer.
 
void setBounds (const Region2D &bounds)
 Empties the tree buffer.
 
void drawTrees (CameraClass *camera, RefRenderObjListIterator *pDynamicLightsIterator)
 Draws the trees. Uses camera for culling.
 
void doFullUpdate (void)
 
void setIsTerrain (void)
 
Bool needToDraw (void)
 Terrain calls this to tell trees to draw.
 
Int getNumTiles (void)
 
TileDatagetSourceTile (Int ndx)
 
void allocateTreeBuffers (void)
 Allocates the buffers.
 
void freeTreeBuffers (void)
 Frees the index and vertex buffers.
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Protected Member Functions

virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
void updateSway (const BreezeInfo &info)
 Updates the sway offsets.
 
void loadTreesInVertexAndIndexBuffers (RefRenderObjListIterator *pDynamicLightsIterator)
 Fills the index and vertex buffers for drawing.
 
void updateVertexBuffer (void)
 Fills the index and vertex buffers for drawing.
 
void cull (const CameraClass *camera)
 Culls the trees.
 
UnsignedInt doLighting (const Vector3 *normal, const GlobalData::TerrainLighting *objectLighting, const Vector3 *emissive, UnsignedInt vertexDiffuse, Real scale) const
 
void updateTexture (void)
 
Int getPartitionBucket (const Coord3D &pos) const
 
void updateTopplingTree (TTree *tree)
 < Keep track of rotational fall distance, bounce and/or stop when needed.
 
void applyTopplingForce (TTree *tree, const Coord3D *toppleDirection, Real toppleSpeed, UnsignedInt options)
 < Start the toppling process by giving a force vector
 

Detailed Description

Definition at line 148 of file W3DTreeBuffer.h.

Constructor & Destructor Documentation

◆ W3DTreeBuffer()

W3DTreeBuffer::W3DTreeBuffer ( void )

Constructor. Sets m_initialized to true if it finds the w3d models it needs for the trees.

Definition at line 1106 of file W3DTreeBuffer.cpp.

◆ ~W3DTreeBuffer()

W3DTreeBuffer::~W3DTreeBuffer ( void )

Destructor. Releases w3d assets.

Definition at line 1086 of file W3DTreeBuffer.cpp.

Member Function Documentation

◆ addTree()

void W3DTreeBuffer::addTree ( DrawableID id,
Coord3D location,
Real scale,
Real angle,
Real randomScaleAmount,
const W3DTreeDrawModuleData * data )

Add a tree at location. Name is the w3d model name.

Adds a tree. Name is the W3D model name, supported models are ALPINE, DECIDUOUS and SHRUB.

Definition at line 1405 of file W3DTreeBuffer.cpp.

◆ addTreeType()

Int W3DTreeBuffer::addTreeType ( const W3DTreeDrawModuleData * data)

Add a type of tree. Name is the w3d model name.

Adds a type of tree (model & texture).

Definition at line 1346 of file W3DTreeBuffer.cpp.

◆ allocateTreeBuffers()

void W3DTreeBuffer::allocateTreeBuffers ( void )

Allocates the buffers.

Allocates the index and vertex buffers.

Definition at line 1236 of file W3DTreeBuffer.cpp.

◆ applyTopplingForce()

void W3DTreeBuffer::applyTopplingForce ( TTree * tree,
const Coord3D * toppleDirection,
Real toppleSpeed,
UnsignedInt options )
protected

< Start the toppling process by giving a force vector

Definition at line 1826 of file W3DTreeBuffer.cpp.

◆ clearAllTrees()

void W3DTreeBuffer::clearAllTrees ( void )

Empties the tree buffer.

Removes all trees.

Definition at line 1278 of file W3DTreeBuffer.cpp.

◆ crc()

void W3DTreeBuffer::crc ( Xfer * xfer)
protectedvirtual

CRC

Implements Snapshot.

Definition at line 1942 of file W3DTreeBuffer.cpp.

◆ cull()

void W3DTreeBuffer::cull ( const CameraClass * camera)
protected

Culls the trees.

Culls the trees, marking the visible flag. If a tree becomes visible, it sets it's sortKey

Definition at line 301 of file W3DTreeBuffer.cpp.

◆ doFullUpdate()

void W3DTreeBuffer::doFullUpdate ( void )
inline

Called when the view changes, and sort key needs to be recalculated. Normally sortKey gets calculated when a tree becomes visible.

Definition at line 204 of file W3DTreeBuffer.h.

◆ doLighting()

UnsignedInt W3DTreeBuffer::doLighting ( const Vector3 * normal,
const GlobalData::TerrainLighting * objectLighting,
const Vector3 * emissive,
UnsignedInt vertDiffuse,
Real scale ) const
protected

Calculates the diffuse lighting as affected by dynamic lighting.

Definition at line 640 of file W3DTreeBuffer.cpp.

◆ drawTrees()

void W3DTreeBuffer::drawTrees ( CameraClass * camera,
RefRenderObjListIterator * pDynamicLightsIterator )

Draws the trees. Uses camera for culling.

Draws the trees. Uses camera to cull.

Definition at line 1545 of file W3DTreeBuffer.cpp.

◆ freeTreeBuffers()

void W3DTreeBuffer::freeTreeBuffers ( void )

Frees the index and vertex buffers.

Frees the index and vertex buffers.

Definition at line 1135 of file W3DTreeBuffer.cpp.

◆ getNumTiles()

Int W3DTreeBuffer::getNumTiles ( void )
inline

Definition at line 208 of file W3DTreeBuffer.h.

◆ getPartitionBucket()

Int W3DTreeBuffer::getPartitionBucket ( const Coord3D & pos) const
protected

Returns the bucket index into m_areaPartition for a given location.

Definition at line 337 of file W3DTreeBuffer.cpp.

◆ getSourceTile()

TileData * W3DTreeBuffer::getSourceTile ( Int ndx)
inline

Definition at line 209 of file W3DTreeBuffer.h.

◆ loadPostProcess()

void W3DTreeBuffer::loadPostProcess ( void )
protectedvirtual

Load post process

Implements Snapshot.

Definition at line 2041 of file W3DTreeBuffer.cpp.

◆ loadTreesInVertexAndIndexBuffers()

void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers ( RefRenderObjListIterator * pDynamicLightsIterator)
protected

Fills the index and vertex buffers for drawing.

Loads the trees into the vertex buffer for drawing.

Definition at line 698 of file W3DTreeBuffer.cpp.

◆ needToDraw()

Bool W3DTreeBuffer::needToDraw ( void )
inline

Terrain calls this to tell trees to draw.

Definition at line 206 of file W3DTreeBuffer.h.

◆ pushAsideTree()

void W3DTreeBuffer::pushAsideTree ( DrawableID id,
const Coord3D * pusherPos,
const Coord3D * pusherDirection,
ObjectID pusherID )

Push sideways tree or grass.

Definition at line 1504 of file W3DTreeBuffer.cpp.

◆ removeTree()

void W3DTreeBuffer::removeTree ( DrawableID id)

Remove a tree.

Removes a tree.

Definition at line 1301 of file W3DTreeBuffer.cpp.

◆ removeTreesForConstruction()

void W3DTreeBuffer::removeTreesForConstruction ( const Coord3D * pos,
const GeometryInfo & geom,
Real angle )

Remove trees that would be under a building.

Removes any trees that would be under a building.

Definition at line 1321 of file W3DTreeBuffer.cpp.

◆ setBounds()

void W3DTreeBuffer::setBounds ( const Region2D & bounds)
inline

Empties the tree buffer.

Definition at line 199 of file W3DTreeBuffer.h.

◆ setIsTerrain()

void W3DTreeBuffer::setIsTerrain ( void )
inline

Definition at line 205 of file W3DTreeBuffer.h.

◆ setTextureLOD()

void W3DTreeBuffer::setTextureLOD ( Int lod)

used to adjust maximum mip level sent to hardware.

Adjust the resolution of tree texture uploaded to the video card. The system memory version always remains at full resolution. Someone should probably optimize this at some point since it wastes a lot of system memory on low-end systems. -MW

Definition at line 629 of file W3DTreeBuffer.cpp.

◆ unitMoved()

void W3DTreeBuffer::unitMoved ( Object * unit)

Notify that an object moved, so check for collisions.

Check to see if a unit collided with a tree/grass/bush.

Definition at line 1157 of file W3DTreeBuffer.cpp.

◆ updateSway()

void W3DTreeBuffer::updateSway ( const BreezeInfo & info)
protected

Updates the sway offsets.

Culls the trees, marking the visible flag. If a tree becomes visible, it sets it's sortKey

Definition at line 357 of file W3DTreeBuffer.cpp.

◆ updateTexture()

void W3DTreeBuffer::updateTexture ( void )
protected

Creates a new texture.

Definition at line 443 of file W3DTreeBuffer.cpp.

◆ updateTopplingTree()

void W3DTreeBuffer::updateTopplingTree ( TTree * tree)
protected

< Keep track of rotational fall distance, bounce and/or stop when needed.

Definition at line 1864 of file W3DTreeBuffer.cpp.

◆ updateTreePosition()

Bool W3DTreeBuffer::updateTreePosition ( DrawableID id,
Coord3D location,
Real angle )

Updates a tree's location.

Updates a tree's position

Definition at line 1479 of file W3DTreeBuffer.cpp.

◆ updateVertexBuffer()

void W3DTreeBuffer::updateVertexBuffer ( void )
protected

Fills the index and vertex buffers for drawing.

Updates the push aside offset in vertex buffer.

Definition at line 993 of file W3DTreeBuffer.cpp.

◆ xfer()

void W3DTreeBuffer::xfer ( Xfer * xfer)
protectedvirtual

Xfer Version Info: 1: Initial version

< Scale at location.

< Sine of the rotation angle at location.

< Cosine of the rotation angle at location.

< Drawable this tree corresponds to.

< Velocity in degrees per frame (or is it radians per frame?)

< Acceleration angularVelocity is increasing

< Z-less direction we are toppling

< Stage this module is in.

< How much have I rotated so I know when to bounce.

< topple options

< Toppled trees sink into the terrain & disappear, how many frames left.

Implements Snapshot.

Definition at line 1952 of file W3DTreeBuffer.cpp.


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