TerrainBlock

Engine/source/terrain/terrData.h

More...

Public User Defined

Accessors and mutators for TerrainMaterialUndoAction.

Protected Types

enum
_Anonymous_ {
  TransformMask = Parent::NextFreeMask
  FileMask = Parent::NextFreeMask << 1
  SizeMask = Parent::NextFreeMask << 2
  MaterialMask = Parent::NextFreeMask << 3
  HeightMapChangeMask = Parent::NextFreeMask << 4
  MiscMask = Parent::NextFreeMask << 5
  NextFreeMask = Parent::NextFreeMask << 6
}

Public Types

enum
_Anonymous_ {
  LightmapUpdate = BIT(0)
  HeightmapUpdate = BIT(1)
  LayersUpdate = BIT(2)
  EmptyUpdate = BIT(3)
}
enum
BaseTexFormat {
  NONE 
  DDS 
  PNG 
}

Private Types

Parent 

Public Friends

Protected Attributes

The shared base material which is used to render cells that are outside the detail map range.

The shader used to generate the base texture map.

The base texture.

The desired size for the base texture.

bool

Allows the terrain to cast shadows onto itself and other objects.

The TerrainFile CRC sent from the server.

The cells used in the last render pass when doing debug rendering.

A dummy material only used for shadow material generation.

The terrain data file.

The lightmap dimensions in pixels.

The lightmap texture.

The maximum detail distance found in the material list.

The shared primitive buffer used in rendering.

bool

True if the zoning needs to be recalculated for the terrain.

Protected Static Attributes

bool

Set to enable debug rendering of the terrain.

A global detail scale used to tweak the material detail distances.

A global LOD scale used to tweak the default terrain screen error value.

Public Static Attributes

Public Static Functions

Protected Static Functions

bool
_setBaseTexFormat(void * obj, const char * index, const char * data)
bool
_setBaseTexSize(void * obj, const char * index, const char * data)
bool
_setLightMapSize(void * obj, const char * index, const char * data)
bool
_setSquareSize(void * obj, const char * index, const char * data)
bool
_setTerrainAsset(void * obj, const char * index, const char * data)
bool
_setTerrainFile(void * obj, const char * index, const char * data)

Public Functions

addMaterial(const String & name, U32 insertAt)

Adds a new material as the top layer or inserts it at the specified index.

buildConvex(const Box3F & box, Convex * convex)

Builds a convex hull for this object.

bool
buildPolyList(PolyListContext context, AbstractPolyList * polyList, const Box3F & box, const SphereF & sphere)

Builds a list of polygons which intersect 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
castRayBlock(const Point3F & pStart, const Point3F & pEnd, const Point2I & blockPos, U32 level, F32 invDeltaX, F32 invDeltaY, F32 startT, F32 endT, RayInfo * info, bool collideEmpty)
bool
castRayI(const Point3F & start, const Point3F & end, RayInfo * info, bool emptyCollide)

Fills the lightmap with white.

bool
collideBox(const Point3F & start, const Point3F & end, RayInfo * info)

Deletes all the materials on the terrain.

Retuns the dimensions of the terrain in samples.

bool
getHeight(const Point2F & pos, F32 * height)

This returns true and the terrain z height for a 2d position in the terrains object space.

Retuns the dimensions of the light map.

const char *
getMinMaxHeight(F32 * minHeight, F32 * maxHeight)
bool
getNormal(const Point2F & pos, Point3F * normal, bool normalize, bool skipEmpty)

This returns true and the terrain normal for a 2d position in the terrains object space.

bool
getNormalAndHeight(const Point2F & pos, Point3F * normal, F32 * height, bool normalize)

This returns true and the terrain normal and z height for a 2d position in the terrains object space.

bool
getNormalHeightMaterial(const Point2F & pos, Point3F * normal, F32 * height, StringTableEntry & matName)

This returns true and the terrain normal, z height, and material name for a 2d position in the terrains object space.

bool
getSmoothNormal(const Point2F & pos, Point3F * normal, bool normalize, bool skipEmpty)

This returns true and the smoothed terrain normal.

Returns the dimensions of the terrain in world space.

bool
import(const GBitmap & heightMap, F32 heightScale, F32 metersPerPixel, const Vector< U8 > & layerMap, const Vector< String > & materials, bool flipYAxis)

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

bool

Called when the object is added to the sim.

Called when the editor is deactivated.

Called when the editor is activated.

Called when the object is removed from the sim.

packUpdate(NetConnection * conn, U32 mask, BitStream * stream)

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

postLight(Vector< TerrainBlock * > & terrBlocks)

Called when the SceneManager is ready for the registration of render instances.

Removes the material at the index.

bool
save(const char * filename)
bool
bool
setFile(const FileName & terrFileName)
setHeight(const Point2I & pos, F32 height)
setLightMap(GBitmap * newLightMap)

Sets the scale for the object.

bool

Sets the Object -> World transform.

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

updateGrid(const Point2I & minPt, const Point2I & maxPt, bool updateClient)
updateMaterial(U32 index, const String & name)

Updates the material at the index.

Detailed Description

Public User Defined

getMaterials()

Accessors and mutators for TerrainMaterialUndoAction.

getLayerMap()

setMaterials(const Vector< TerrainMaterial * > & materials)

setLayerMap(const Vector< U8 > & layers)

Protected Types

@202

Enumerator

TransformMask = Parent::NextFreeMask
FileMask = Parent::NextFreeMask << 1
SizeMask = Parent::NextFreeMask << 2
MaterialMask = Parent::NextFreeMask << 3
HeightMapChangeMask = Parent::NextFreeMask << 4
MiscMask = Parent::NextFreeMask << 5
NextFreeMask = Parent::NextFreeMask << 6

Public Types

@203

Enumerator

LightmapUpdate = BIT(0)
HeightmapUpdate = BIT(1)
LayersUpdate = BIT(2)
EmptyUpdate = BIT(3)
BaseTexFormat

Enumerator

NONE
DDS
PNG

Private Types

typedef SceneObject Parent 

Public Friends

Protected Attributes

GFXShaderConstHandle * mBaseLayerSizeConst 
TerrainCellMaterial * mBaseMaterial 

The shared base material which is used to render cells that are outside the detail map range.

GFXShaderRef mBaseShader 

The shader used to generate the base texture map.

GFXShaderConstBufferRef mBaseShaderConsts 
GFXStateBlockRef mBaseShaderSB 
GFXTextureTargetRef mBaseTarget 
GFXTexHandle mBaseTex 

The base texture.

BaseTexFormat mBaseTexFormat 
GFXShaderConstHandle * mBaseTexIdConst 
GFXShaderConstHandle * mBaseTexScaleConst 
U32 mBaseTexSize 

The desired size for the base texture.

Vector< GFXTexHandle > mBaseTextures 
Box3F mBounds 
bool mCastShadows 

Allows the terrain to cast shadows onto itself and other objects.

TerrCell * mCell 
U32 mCRC 

The TerrainFile CRC sent from the server.

Vector< TerrCell * > mDebugCells 

The cells used in the last render pass when doing debug rendering.

BaseMatInstance * mDefaultMatInst 

A dummy material only used for shadow material generation.

bool mDetailsDirty 
GFXTextureArrayHandle mDetailTextureArray 
Resource< TerrainFile > mFile 

The terrain data file.

bool mIgnoreZodiacs 
GFXTexHandle mLayerTex 
bool mLayerTexDirty 
GBitmap * mLightMap 
U32 mLightMapSize 

The lightmap dimensions in pixels.

GFXTexHandle mLightMapTex 

The lightmap texture.

GFXTextureArrayHandle mMacroTextureArray 
F32 mMaxDetailDistance 

The maximum detail distance found in the material list.

GFXTextureArrayHandle mNormalTextureArray 
GFXTextureArrayHandle mOrmTextureArray 
PhysicsBody * mPhysicsRep 
GFXPrimitiveBufferHandle mPrimBuffer 

The shared primitive buffer used in rendering.

U32 mScreenError 
F32 mSquareSize 
AssetPtr< TerrainAsset > mTerrainAsset 
StringTableEntry mTerrainAssetId 
FileName mTerrFileName 
bool mUpdateBasetex 
bool mZoningDirty 

True if the zoning needs to be recalculated for the terrain.

U16 * zode_primBuffer 

Protected Static Attributes

bool smDebugRender 

Set to enable debug rendering of the terrain.

It is exposed to the console via $terrain::debugRender.

F32 smDetailScale 

A global detail scale used to tweak the material detail distances.

F32 smLODScale 

A global LOD scale used to tweak the default terrain screen error value.

Public Static Attributes

Signal< void(U32, TerrainBlock *, const Point2I &,const Point2I &)> smUpdateSignal 

Public Static Functions

formatToExtension(BaseTexFormat format)

initPersistFields()

Protected Functions

_getBaseTexCacheFileName()

_initBaseShader()

_onFlushMaterials()

Used to release terrain materials when the material manager flushes them.

_onTextureEvent(GFXTexCallbackCode code)

The callback used to get texture events.

_onZoningChanged(SceneZoneSpaceManager * zoneManager)

_rebuildQuadtree()

_renderBlock(SceneRenderState * state)

_renderDebug(ObjectRenderInst * ri, SceneRenderState * state, BaseMatInstance * overrideMat)

_updateBaseTexture(bool writeToCache)

_updateBounds()

_updateLayerTexture()

_updateMaterials()

_updatePhysics()

_updateZoning()

deleteZodiacPrimitiveBuffer()

Protected Static Functions

_setBaseTexFormat(void * obj, const char * index, const char * data)

_setBaseTexSize(void * obj, const char * index, const char * data)

_setLightMapSize(void * obj, const char * index, const char * data)

_setSquareSize(void * obj, const char * index, const char * data)

_setTerrainAsset(void * obj, const char * index, const char * data)

_setTerrainFile(void * obj, const char * index, const char * data)

Public Functions

TerrainBlock()

~TerrainBlock()

addMaterial(const String & name, U32 insertAt)

Adds a new material as the top layer or inserts it at the specified index.

buildConvex(const Box3F & box, Convex * convex)

Reimplemented from: SceneObject

buildPolyList(PolyListContext context, AbstractPolyList * polyList, const Box3F & box, const SphereF & sphere)

Reimplemented from: SceneObject

castRay(const Point3F & start, const Point3F & end, RayInfo * info)

Reimplemented from: SceneObject

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

castRayI(const Point3F & start, const Point3F & end, RayInfo * info, bool emptyCollide)

clearLightMap()

Fills the lightmap with white.

collideBox(const Point3F & start, const Point3F & end, RayInfo * info)

Reimplemented from: SceneObject

DECLARE_CONOBJECT(TerrainBlock )

deleteAllMaterials()

Deletes all the materials on the terrain.

getBlockSize()

Retuns the dimensions of the terrain in samples.

getCRC()

getDetailTextureArray()

getFile()

getGridPos(const Point3F & worldPos)

getHeight(const Point2F & pos, F32 * height)

This returns true and the terrain z height for a 2d position in the terrains object space.

If the terrain at that point is within an empty block or the 2d position is outside of the terrain area then it returns false.

getHeight(const Point2I & pos)

getLightMap()

getLightMap()

getLightMapSize()

Retuns the dimensions of the light map.

getLightMapTex()

getMacroTextureArray()

getMaterial(U32 index)

getMaterialCount()

getMaterialName(U32 index)

getMinMaxHeight(F32 * minHeight, F32 * maxHeight)

getNormal(const Point2F & pos, Point3F * normal, bool normalize, bool skipEmpty)

This returns true and the terrain normal for a 2d position in the terrains object space.

If the terrain at that point is within an empty block or the 2d position is outside of the terrain area then it returns false.

getNormalAndHeight(const Point2F & pos, Point3F * normal, F32 * height, bool normalize)

This returns true and the terrain normal and z height for a 2d position in the terrains object space.

If the terrain at that point is within an empty block or the 2d position is outside of the terrain area then it returns false.

getNormalHeightMaterial(const Point2F & pos, Point3F * normal, F32 * height, StringTableEntry & matName)

This returns true and the terrain normal, z height, and material name for a 2d position in the terrains object space.

If the terrain at that point is within an empty block or the 2d position is outside of the terrain area then it returns false.

getNormalTextureArray()

getOrmTextureArray()

getScreenError()

getSmoothNormal(const Point2F & pos, Point3F * normal, bool normalize, bool skipEmpty)

This returns true and the smoothed terrain normal.

If the terrain at that point is within an empty block or the 2d position is outside of the terrain area then it returns false.

getSquareSize()

getTerrainFile()

getUtilizedAssets(Vector< StringTableEntry > * usedAssetsList)

Reimplemented from: SceneObject

getWorldBlockSize()

Returns the dimensions of the terrain in world space.

getZodiacPrimitiveBuffer()

import(const GBitmap & heightMap, F32 heightScale, F32 metersPerPixel, const Vector< U8 > & layerMap, const Vector< String > & materials, bool flipYAxis)

inspectPostApply()

Reimplemented from: SceneObject

onAdd()

Reimplemented from: SceneObject

onEditorDisable()

Reimplemented from: SimObject

onEditorEnable()

Reimplemented from: SimObject

onRemove()

Reimplemented from: SceneObject

packUpdate(NetConnection * conn, U32 mask, BitStream * stream)

Reimplemented from: SceneObject

postLight(Vector< TerrainBlock * > & terrBlocks)

prepRenderImage(SceneRenderState * state)

Reimplemented from: SceneObject

removeMaterial(U32 index)

Removes the material at the index.

save(const char * filename)

saveAsset()

setFile(const FileName & terrFileName)

setFile(const Resource< TerrainFile > & file)

setHeight(const Point2I & pos, F32 height)

setLightMap(GBitmap * newLightMap)

setMaterialsDirty()

setScale(const VectorF & scale)

Reimplemented from: SceneObject

setTerrainAsset(const StringTableEntry terrainAssetId)

setTransform(const MatrixF & mat)

Reimplemented from: SceneObject

unpackUpdate(NetConnection * conn, BitStream * stream)

Reimplemented from: SceneObject

updateGrid(const Point2I & minPt, const Point2I & maxPt, bool updateClient)

updateGridMaterials(const Point2I & minPt, const Point2I & maxPt)

updateMaterial(U32 index, const String & name)

Updates the material at the index.