torque Torque Game Engine Documentation
TGE Version 1.5.2

TerrainBlock Class Reference

#include <terrData.h>

Inheritance diagram for TerrainBlock:

Inheritance graph
[legend]

Public Types

enum  {
  BlockSize = 256,
  BlockShift = 8,
  LightmapSize = 512,
  LightmapShift = 9,
  ChunkSquareWidth = 64,
  ChunkSize = 4,
  ChunkDownShift = 2,
  ChunkShift = BlockShift - ChunkDownShift,
  BlockSquareWidth = 256,
  SquareMaxPoints = 1024,
  BlockMask = 255,
  GridMapSize = 0x15555,
  FlagMapWidth = 128,
  FlagMapMask = 127,
  MaxMipLevel = 6,
  NumBaseTextures = 16,
  MaterialGroups = 8,
  MaxEmptyRunPairs = 100
}
enum  UpdateMaskBits {
  InitMask = 1,
  VisibilityMask = 2,
  EmptyMask = 4
}

Public Member Functions

void triggerLightmapReload ()
void processTextureEvent (const U32 eventCode)
 TerrainBlock ()
 ~TerrainBlock ()
void buildChunkDeviance (S32 x, S32 y)
void buildGridMap ()
U32 getCRC ()
Resource< TerrainFilegetFile ()
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void refreshMaterialLists ()
void onEditorEnable ()
 Called when the editor is activated.
void onEditorDisable ()
 Called when the editor is deactivated.
void rebuildEmptyFlags ()
bool unpackEmptySquares ()
void packEmptySquares ()
TextureHandle getDetailTextureHandle ()
TextureHandle getBumpTextureHandle ()
TextureHandle getInvertedBumpTextureHandle ()
MaterialgetMaterial (U32 x, U32 y)
GridSquarefindSquare (U32 level, Point2I pos)
GridSquarefindSquare (U32 level, S32 x, S32 y)
GridChunkfindChunk (Point2I pos)
void setHeight (const Point2I &pos, float height)
void updateGrid (Point2I min, Point2I max)
void updateGridMaterials (Point2I min, Point2I max)
U16 getHeight (U32 x, U32 y)
U16getHeightAddress (U32 x, U32 y)
void setBaseMaterial (U32 x, U32 y, U8 matGroup)
S32 getTerrainMapIndex (Point3F &pt)
U8getMaterialAlphaMap (U32 matIndex)
U8getBaseMaterialAddress (U32 x, U32 y)
U8 getBaseMaterial (U32 x, U32 y)
U16getFlagMapPtr (S32 x, S32 y)
void getMaterialAlpha (Point2I pos, U8 alphas[MaterialGroups])
void setMaterialAlpha (Point2I pos, const U8 alphas[MaterialGroups])
bool getHeight (const Point2F &pos, F32 *height)
bool getNormal (const Point2F &pos, Point3F *normal, bool normalize=true)
bool getNormalAndHeight (const Point2F &pos, Point3F *normal, F32 *height, bool normalize=true)
bool collideBox (const Point3F &start, const Point3F &end, RayInfo *info)
S32 getMaterialAlphaIndex (const char *materialName)
void setFile (Resource< TerrainFile > file)
bool save (const char *filename)
void relight (const ColorF &lightColor, const ColorF &ambient, const Point3F &lightDir)
S32 getSquareSize ()
void buildConvex (const Box3F &box, Convex *convex)
 Builds a convex hull for this object.
bool buildPolyList (AbstractPolyList *polyList, const Box3F &box, const SphereF &sphere)
 Builds a list of polygons which intersect a bounding volume.
BSPNodebuildCollisionBSP (BSPTree *tree, const Box3F &box, const SphereF &sphere)
 Builds a collision tree of all the polygons which collide with a bounding volume.
bool castRay (const Point3F &start, const Point3F &end, RayInfo *info)
 Casts a ray and obtain collision information, returns true if RayInfo is modified.
bool castRayI (const Point3F &start, const Point3F &end, RayInfo *info, bool emptyCollide)
bool castRayBlock (const Point3F &pStart, const Point3F &pEnd, const Point2I &blockPos, U32 level, F32 invDeltaX, F32 invDeltaY, F32 startT, F32 endT, RayInfo *info, bool)
bool buildMaterialMap ()
void buildMipMap ()
void setBaseMaterials (S32 argc, const char *argv[])
bool initMMXBlender ()
 DECLARE_CONOBJECT (TerrainBlock)
void inspectPostApply ()
 Called after any property of the object is changed in the world editor.
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream)
 Instructs this object to pack its state for transfer over the network.
void unpackUpdate (NetConnection *conn, BitStream *stream)
 Instructs this object to read state data previously packed with packUpdate.

Static Public Member Functions

static void flushCache ()
static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Data Fields

BlendermBlender
TextureHandle baseTextures [NumBaseTextures]
TextureHandle mBaseMaterials [MaterialGroups]
TextureHandle mAlphaMaterials [MaterialGroups]
GBitmaplightMap
GBitmapwhiteMap
TextureHandle lightMapTexture
StringTableEntrymMaterialFileName
 Array from the file.
TextureHandle mDynLightTexture
U8mBaseMaterialMap
MaterialmaterialMap
U16heightMap
U16flagMap
StringTableEntry mDetailTextureName
TextureHandle mDetailTextureHandle
StringTableEntry mBumpTextureName
TextureHandle mBumpTextureHandle
TextureHandle mInvertedBumpTextureHandle
F32 mBumpScale
F32 mBumpOffset
U32 mZeroBumpScale
StringTableEntry mTerrFileName
Vector< S32mEmptySquareRuns
U32 mTextureCallbackKey
S32 mMPMIndex [TerrainBlock::MaterialGroups]
S32 mVertexBuffer
bool mTile
 If true, we tile infinitely.

Protected Member Functions

void setTransform (const MatrixF &mat)
 Sets the Object -> World transform.
bool prepRenderImage (SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState=false)
 Called when the SceneGraph is ready for the registration of RenderImages.
void renderObject (SceneState *state, SceneRenderImage *image)
 Called when the object is supposed to render itself.

Private Types

typedef SceneObject Parent

Private Member Functions

BSPNodebuildSquareTree (S32 y, S32 x)
BSPNodebuildXTree (S32 y, S32 xStart, S32 xEnd)

Private Attributes

Resource< TerrainFilemFile
GridSquaregridMap [BlockShift+1]
GridChunkmChunkMap
U32 mCRC
S32 squareSize
BSPTreemTree
S32 mHeightMin
S32 mHeightMax
bool mCollideEmpty

Data Structures

struct  Material

Member Typedef Documentation

typedef SceneObject TerrainBlock::Parent [private]

Reimplemented from SceneObject.


Member Enumeration Documentation

anonymous enum

Enumerator:
BlockSize 
BlockShift 
LightmapSize 
LightmapShift 
ChunkSquareWidth 
ChunkSize 
ChunkDownShift 
ChunkShift 
BlockSquareWidth 
SquareMaxPoints 
BlockMask 
GridMapSize 
FlagMapWidth  Flags that map is for 2x2 squares.
FlagMapMask 
MaxMipLevel 
NumBaseTextures 
MaterialGroups 
MaxEmptyRunPairs 

Enumerator:
InitMask 
VisibilityMask 
EmptyMask 


Constructor & Destructor Documentation

TerrainBlock::TerrainBlock (  ) 

TerrainBlock::~TerrainBlock (  ) 


Member Function Documentation

void TerrainBlock::triggerLightmapReload (  )  [inline]

void TerrainBlock::processTextureEvent ( const U32  eventCode  ) 

void TerrainBlock::buildChunkDeviance ( S32  x,
S32  y 
)

void TerrainBlock::buildGridMap (  ) 

U32 TerrainBlock::getCRC (  )  [inline]

Resource<TerrainFile> TerrainBlock::getFile (  )  [inline]

bool TerrainBlock::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SceneObject.

void TerrainBlock::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SceneObject.

void TerrainBlock::refreshMaterialLists (  ) 

void TerrainBlock::onEditorEnable (  )  [virtual]

Called when the editor is activated.

Reimplemented from SimObject.

void TerrainBlock::onEditorDisable (  )  [virtual]

Called when the editor is deactivated.

Reimplemented from SimObject.

void TerrainBlock::rebuildEmptyFlags (  ) 

bool TerrainBlock::unpackEmptySquares (  ) 

void TerrainBlock::packEmptySquares (  ) 

TextureHandle TerrainBlock::getDetailTextureHandle (  )  [inline]

TextureHandle TerrainBlock::getBumpTextureHandle (  ) 

TextureHandle TerrainBlock::getInvertedBumpTextureHandle (  ) 

TerrainBlock::Material * TerrainBlock::getMaterial ( U32  x,
U32  y 
) [inline]

GridSquare * TerrainBlock::findSquare ( U32  level,
Point2I  pos 
) [inline]

GridSquare * TerrainBlock::findSquare ( U32  level,
S32  x,
S32  y 
) [inline]

GridChunk * TerrainBlock::findChunk ( Point2I  pos  )  [inline]

void TerrainBlock::setHeight ( const Point2I pos,
float  height 
)

void TerrainBlock::updateGrid ( Point2I  min,
Point2I  max 
)

void TerrainBlock::updateGridMaterials ( Point2I  min,
Point2I  max 
)

U16 TerrainBlock::getHeight ( U32  x,
U32  y 
) [inline]

U16* TerrainBlock::getHeightAddress ( U32  x,
U32  y 
) [inline]

void TerrainBlock::setBaseMaterial ( U32  x,
U32  y,
U8  matGroup 
)

S32 TerrainBlock::getTerrainMapIndex ( Point3F pt  ) 

U8 * TerrainBlock::getMaterialAlphaMap ( U32  matIndex  )  [inline]

U8 * TerrainBlock::getBaseMaterialAddress ( U32  x,
U32  y 
) [inline]

U8 TerrainBlock::getBaseMaterial ( U32  x,
U32  y 
) [inline]

U16 * TerrainBlock::getFlagMapPtr ( S32  x,
S32  y 
) [inline]

void TerrainBlock::getMaterialAlpha ( Point2I  pos,
U8  alphas[MaterialGroups] 
)

void TerrainBlock::setMaterialAlpha ( Point2I  pos,
const U8  alphas[MaterialGroups] 
)

bool TerrainBlock::getHeight ( const Point2F pos,
F32 height 
)

bool TerrainBlock::getNormal ( const Point2F pos,
Point3F normal,
bool  normalize = true 
)

bool TerrainBlock::getNormalAndHeight ( const Point2F pos,
Point3F normal,
F32 height,
bool  normalize = true 
)

bool TerrainBlock::collideBox ( const Point3F start,
const Point3F end,
RayInfo info 
) [inline, virtual]

Reimplemented from SceneObject.

S32 TerrainBlock::getMaterialAlphaIndex ( const char *  materialName  ) 

void TerrainBlock::setFile ( Resource< TerrainFile file  ) 

bool TerrainBlock::save ( const char *  filename  ) 

static void TerrainBlock::flushCache (  )  [static]

void TerrainBlock::relight ( const ColorF lightColor,
const ColorF ambient,
const Point3F lightDir 
)

S32 TerrainBlock::getSquareSize (  )  [inline]

void TerrainBlock::setTransform ( const MatrixF mat  )  [protected, virtual]

Sets the Object -> World transform.

Parameters:
mat New transform matrix

Reimplemented from SceneObject.

bool TerrainBlock::prepRenderImage ( SceneState state,
const U32  stateKey,
const U32  startZone,
const bool  modifyBaseZoneState = false 
) [protected, virtual]

Called when the SceneGraph is ready for the registration of RenderImages.

See also:
SceneState
Parameters:
state SceneState
stateKey State key of the current SceneState
startZone Base zone index
modifyBaseZoneState If true, the object needs to modify the zone state.

Reimplemented from SceneObject.

void TerrainBlock::renderObject ( SceneState state,
SceneRenderImage image 
) [protected, virtual]

Called when the object is supposed to render itself.

Parameters:
state Current rendering state.
See also:
SceneState
Parameters:
image Image associated with this object to render.
See also:
SceneRenderImage

Reimplemented from SceneObject.

void TerrainBlock::buildConvex ( const Box3F box,
Convex convex 
) [virtual]

Builds a convex hull for this object.

Think of a convex hull as a low-res mesh which covers, as tightly as possible, the object mesh, and is used as a collision mesh.

Parameters:
box 
convex Convex mesh generated (out)

Reimplemented from SceneObject.

bool TerrainBlock::buildPolyList ( AbstractPolyList polyList,
const Box3F box,
const SphereF sphere 
) [virtual]

Builds a list of polygons which intersect a bounding volume.

This will use either the sphere or the box, not both, the SceneObject implimentation ignores sphere.

See also:
AbstractPolyList
Parameters:
polyList Poly list build (out)
box Box bounding volume
sphere Sphere bounding volume

Reimplemented from SceneObject.

BSPNode* TerrainBlock::buildCollisionBSP ( BSPTree tree,
const Box3F box,
const SphereF sphere 
) [virtual]

Builds a collision tree of all the polygons which collide with a bounding volume.

Note:
Not implemented in SceneObject.
See also:
TerrainBlock::buildCollisionBSP
Parameters:
tree BSP tree built (out)
box Box bounding volume
sphere Sphere bounding volume

Reimplemented from SceneObject.

bool TerrainBlock::castRay ( const Point3F start,
const Point3F end,
RayInfo info 
) [virtual]

Casts a ray and obtain collision information, returns true if RayInfo is modified.

Parameters:
start Start point of ray
end End point of ray
info Collision information obtained (out)

Reimplemented from SceneObject.

bool TerrainBlock::castRayI ( const Point3F start,
const Point3F end,
RayInfo info,
bool  emptyCollide 
)

bool TerrainBlock::castRayBlock ( const Point3F pStart,
const Point3F pEnd,
const Point2I blockPos,
U32  level,
F32  invDeltaX,
F32  invDeltaY,
F32  startT,
F32  endT,
RayInfo info,
bool   
)

BSPNode* TerrainBlock::buildSquareTree ( S32  y,
S32  x 
) [private]

BSPNode* TerrainBlock::buildXTree ( S32  y,
S32  xStart,
S32  xEnd 
) [private]

bool TerrainBlock::buildMaterialMap (  ) 

void TerrainBlock::buildMipMap (  ) 

void TerrainBlock::setBaseMaterials ( S32  argc,
const char *  argv[] 
)

bool TerrainBlock::initMMXBlender (  ) 

TerrainBlock::DECLARE_CONOBJECT ( TerrainBlock   ) 

static void TerrainBlock::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDepricatedField(), addGroup(), endGroup()

Reimplemented from SceneObject.

void TerrainBlock::inspectPostApply (  )  [virtual]

Called after any property of the object is changed in the world editor.

See also:
inspectPreApply

Reimplemented from SceneObject.

U32 TerrainBlock::packUpdate ( NetConnection conn,
U32  mask,
BitStream stream 
) [virtual]

Instructs this object to pack its state for transfer over the network.

Parameters:
conn Net connection being used
mask Mask indicating fields to transmit.
stream Bitstream to pack data to
Returns:
Any bits which were not dealt with. The value is stored by the networking system. Don't set bits you weren't passed.

Reimplemented from NetObject.

void TerrainBlock::unpackUpdate ( NetConnection conn,
BitStream stream 
) [virtual]

Instructs this object to read state data previously packed with packUpdate.

Parameters:
conn Net connection being used
stream stream to read from

Reimplemented from NetObject.


Field Documentation

TextureHandle TerrainBlock::baseTextures[NumBaseTextures]

TextureHandle TerrainBlock::mBaseMaterials[MaterialGroups]

TextureHandle TerrainBlock::mAlphaMaterials[MaterialGroups]

S32 TerrainBlock::mMPMIndex[TerrainBlock::MaterialGroups]

If true, we tile infinitely.

GridSquare* TerrainBlock::gridMap[BlockShift+1] [private]




All Rights Reserved GarageGames.com, Inc. 1999-2005
Auto-magically Generated with Doxygen