AlphaFramework API  1.0.3
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Public Attributes | Properties | List of all members
AlphaFramework.World.Terrains.Terrain< TTemplate > Class Template Reference

This class contains a height-map-based Terrain including texturing and pathfinding data. More...

Inheritance diagram for AlphaFramework.World.Terrains.Terrain< TTemplate >:
AlphaFramework.World.Terrains.ITerrain

Public Member Functions

 Terrain (TerrainSize size)
 Creates a new terrain. It is completely flat and has only one texture initially. More...
 
DoubleVector3 ToEngineCoords (Vector2 coordinates)
 Converts a position in world coordinates to the engine entity space coordinate system. More...
 
void MarkUntraversableSlopes (bool[,] obstructionMap, int maxTraversableSlope)
 Marks untraversable slopes in a pathfinding "obstruction map".
Parameters
obstructionMapThe existing pathfinding "obstruction map" to mark the untraversable slopes in.
maxTraversableSlopeThe maximum slope to considers traversable.

 
byte GetTerrainIndex (Vector2 coordinates)
 Determines the TTemplate effective at specific coordinates. More...
 
 Terrain ()
 Base-constructor for XML serialization. Do not call manually! More...
 
void LoadHeightMap (Stream stream)
 Loads data for ITerrain.HeightMap from a stream.
Parameters
streamThe stream to read the height-map from.
Exceptions
IOExceptionThe height-map size is incorrect.

 
void LoadHeightMap (string path)
 Loads data for ITerrain.HeightMap from a file.
Parameters
pathThe path of the PNG file to load the height-map from.
Exceptions
IOExceptionThe texture-map size is incorrect.

 
void LoadOcclusionIntervalMap (Stream stream)
 Loads data for ITerrain.OcclusionIntervalMap from a stream.
Parameters
streamThe stream to read the occlusion interval map from.
Exceptions
IOExceptionThe occlusion interval map size is incorrect.

 
void LoadOcclusionIntervalMap (string path)
 Loads data for ITerrain.OcclusionIntervalMap from a file.
Parameters
pathThe path of the PNG file to load the occlusion interval map from.
Exceptions
IOExceptionThe texture-map size is incorrect.

 
void LoadTextureMap (Stream stream)
 Loads data for ITerrain.TextureMap from a stream.
Parameters
streamThe stream to read the texture-map from.
Exceptions
IOExceptionThe texture-map size is incorrect.

 
void LoadTextureMap (string path)
 Loads data for ITerrain.TextureMap from a file.
Parameters
pathThe path of the PNG file to load the texture-map from.
Exceptions
IOExceptionThe texture-map size is incorrect.

 

Public Attributes

Vector2 Center => new Vector2(_size.X * _size.StretchH / 2f, _size.Y * _size.StretchH / 2f)
 
readonly TTemplate[] Templates = new TTemplate[16]
 The TTemplate s available for usage in this ITerrain. More...
 
bool DataLoaded => _heightMap != null && _textureMap != null
 

Properties

TerrainSize Size [get, set]
 
ByteGrid HeightMap [get, set]
 
ByteVector4Grid OcclusionIntervalMap [get, set]
 
bool OcclusionIntervalMapOutdated [get, set]
 
NibbleGrid TextureMap [get, set]
 
string[] TemplateNames [get, set]
 Used for XML serialization. More...
 
- Properties inherited from AlphaFramework.World.Terrains.ITerrain
TerrainSize Size [get, set]
 The size of the terrain. More...
 
Vector2 Center [get]
 The world coordinates of the center of the terrain. More...
 
ByteGrid HeightMap [get, set]
 Direct access to the internal height-map array. Handle with care; clone when necessary! More...
 
ByteVector4Grid OcclusionIntervalMap [get, set]
 Direct access to the internal occlusion interval map array. Handle with care; clone when necessary! More...
 
bool OcclusionIntervalMapOutdated [get, set]
 Indicates that the data stored in OcclusionIntervalMap is outdated and should be recalculated using OcclusionIntervalMapGenerator. More...
 
NibbleGrid TextureMap [get, set]
 Direct access to the internal height-map array. Handle with care; clone when necessary! More...
 
bool DataLoaded [get]
 Was the minimum necessary data for the terrain (HeightMap and TextureMap) loaded already? More...
 

Detailed Description

This class contains a height-map-based Terrain including texturing and pathfinding data.

The positive X-axis points towards east (the direction from which light sources in the sky rise), the negative X-axis points towards west (the direction in which light sources in the sky set), the positive Y-axis points towards north and the negative Y-axis points towards south.

Template Parameters
TTemplateThe specific type of Template{T} to use for storing information about terrain types.
Type Constraints
TTemplate :Template<TTemplate> 

Constructor & Destructor Documentation

AlphaFramework.World.Terrains.Terrain< TTemplate >.Terrain ( TerrainSize  size)
inline

Creates a new terrain. It is completely flat and has only one texture initially.

Parameters
sizeThe size of the terrain to create.
AlphaFramework.World.Terrains.Terrain< TTemplate >.Terrain ( )
inline

Base-constructor for XML serialization. Do not call manually!

Member Function Documentation

byte AlphaFramework.World.Terrains.Terrain< TTemplate >.GetTerrainIndex ( Vector2  coordinates)
inline

Determines the TTemplate effective at specific coordinates.

Parameters
coordinatesThe world coordinates to check.
DoubleVector3 AlphaFramework.World.Terrains.Terrain< TTemplate >.ToEngineCoords ( Vector2  coordinates)
inline

Converts a position in world coordinates to the engine entity space coordinate system.

Parameters
coordinatesThe coordinates of the point in engine world space to get information for.

Member Data Documentation

readonly TTemplate [] AlphaFramework.World.Terrains.Terrain< TTemplate >.Templates = new TTemplate[16]

The TTemplate s available for usage in this ITerrain.

Property Documentation

string [] AlphaFramework.World.Terrains.Terrain< TTemplate >.TemplateNames
getset

Used for XML serialization.

See Also
Templates

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