Table of Contents

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 Mesh

The mesh use for rendering

material XMaterial

The material to use for rendering the terrain

lighting bool

Use/support lighting when rendering this terrain?

Properties

Lighting

Use/support lighting when rendering this terrain?

public bool Lighting { get; }

Property Value

bool

Size

The size of the terrain in game units

public Size Size { get; }

Property Value

Size

StretchH

A factor by which the terrain is horizontally stretched

public float StretchH { get; }

Property Value

float

StretchV

A factor by which the terrain is vertically stretched

public float StretchV { get; }

Property Value

float

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 Engine

The Engine to create the terrain in

size Size

The size of the terrain

stretchH float

A factor by which all horizontal distances are multiplied

stretchV float

A factor by which all vertical distances are multiplied

heightMap ByteGrid

The height values of the terrain in a 2D array. Grid size = Terrain size

textureMap NibbleGrid

The 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 ByteVector4Grid

The angles at which the global light source occlusion begins and ends. Grid size = Terrain size; may be null for no shadowing

lighting bool

Shall this mesh be prepared for lighting? (calculate normal vectors, make shaders support lighting, ...)

blockSize int

How 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

faceIndex int
u float
v float

Returns

Vector3

IntersectsBounding(Ray)

Determine whether WorldBoundingBox and WorldBoundingSphere (if defined) are intersected by a ray.

protected override bool IntersectsBounding(Ray ray)

Parameters

ray Ray

A ray in world space along which to check for intersections.

Returns

bool

true if the bounding bodies were undefined or intersected by the ray.

ModifyColor(Point, Color[,])

Modifies the color of a part of the terrain.

public void ModifyColor(Point start, Color[,] partialColorMap)

Parameters

start Point

The 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 Point

The 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()