Class Terrain
- Namespace
- OmegaEngine.Graphics.Renderables
- Assembly
- OmegaEngine.dll
Displays a multi-textured terrain
public class Terrain : Model, IDisposable, IPositionable
- Inheritance
-
Terrain
- Implements
- Inherited Members
- Extension Methods
Constructors
Terrain(Mesh, XMaterial, bool)
Internal helper constructor
protected Terrain(Mesh mesh, XMaterial material, bool lighting)
Parameters
mesh
MeshThe mesh use for rendering
material
XMaterialThe material to use for rendering the terrain
lighting
boolUse/support lighting when rendering this terrain?
Properties
Lighting
Use/support lighting when rendering this terrain?
public bool Lighting { get; }
Property Value
Size
The size of the terrain in game units
public Size Size { get; }
Property Value
StretchH
A factor by which the terrain is horizontally stretched
public float StretchH { get; }
Property Value
StretchV
A factor by which the terrain is vertically stretched
public float StretchV { get; }
Property Value
Methods
Create(Engine, Size, float, float, ByteGrid, NibbleGrid, string[], ByteVector4Grid?, bool, int)
Creates a new terrain from a height-map and a texture-map
public static Terrain Create(Engine engine, Size size, float stretchH, float stretchV, ByteGrid heightMap, NibbleGrid textureMap, string[] textures, ByteVector4Grid? occlusionIntervalMap, bool lighting, int blockSize)
Parameters
engine
EngineThe Engine to create the terrain in
size
SizeThe size of the terrain
stretchH
floatA factor by which all horizontal distances are multiplied
stretchV
floatA factor by which all vertical distances are multiplied
heightMap
ByteGridThe height values of the terrain in a 2D array. Grid size = Terrain size
textureMap
NibbleGridThe texture values of the terrain in a 2D array. Grid size = Terrain size / 3
textures
string[]An array with a maximum of 16 texture names associated to
textureMap
occlusionIntervalMap
ByteVector4GridThe angles at which the global light source occlusion begins and ends. Grid size = Terrain size; may be
null
for no shadowinglighting
boolShall this mesh be prepared for lighting? (calculate normal vectors, make shaders support lighting, ...)
blockSize
intHow many points in X and Y direction shall one block for culling be?
Returns
- Terrain
The newly created terrain
Exceptions
- FileNotFoundException
One of the specified texture files could not be found.
- IOException
There was an error reading one of the texture files.
- UnauthorizedAccessException
Read access to one of the texture files is not permitted.
- InvalidDataException
One of the texture files does not contain a valid texture.
GetFacePosition(int, float, float)
protected virtual Vector3 GetFacePosition(int faceIndex, float u, float v)
Parameters
Returns
- Vector3
IntersectsBounding(Ray)
Determine whether WorldBoundingBox and WorldBoundingSphere (if defined) are intersected by a ray.
protected override bool IntersectsBounding(Ray ray)
Parameters
ray
RayA ray in world space along which to check for intersections.
Returns
- bool
true
if the bounding bodies were undefined or intersected by theray
.
ModifyColor(Point, Color[,])
Modifies the color of a part of the terrain.
public void ModifyColor(Point start, Color[,] partialColorMap)
Parameters
start
PointThe top-left index of the area to modify.
partialColorMap
Color[,]A 2D array containing the new color values - array size specifies size of the area to modify.
Remarks
Cannot be called when Lighting is false
, because coloring uses the lighting subsystem.
ModifyHeight(Point, byte[,])
Modifies the height of a part of the terrain.
public void ModifyHeight(Point start, byte[,] partialHeightMap)
Parameters
start
PointThe top-left index of the area to modify.
partialHeightMap
byte[,]A 2D array containing the new height values; array size specifies size of the area to modify.
Remarks
Cannot be called when Lighting is true
, because normals are not updated.
Invalidates all internal SlimDX.BoundingBoxes.
RecalcWorldTransform()
Called to generate/update transformation matrices and related values
protected override void RecalcWorldTransform()