Class Terrain
- Namespace
- OmegaEngine.Graphics.Renderables
- Assembly
- OmegaEngine.dll
Displays a multi-textured terrain
public class Terrain : Model, IDisposable, IPositionable
- Inheritance
-
objectTerrain
- Implements
- Inherited Members
Constructors
Terrain(Mesh, XMaterial, bool)
Internal helper constructor
protected Terrain(Mesh sourceMesh, XMaterial material, bool lighting)
Parameters
sourceMeshMeshThe finished terrain mesh in SlimDX.Direct3D9.Pool.SystemMemory. Disposed once its content has been copied and published.
materialXMaterialThe material to use for rendering the terrain
lightingboolUse/support lighting when rendering this terrain?
Remarks
Unlike other Models the terrain keeps no system memory copy of its mesh; it is by far the largest mesh in a scene. It is published without SlimDX.Direct3D9.MeshFlags.WriteOnly instead, so ModifyColor(Point, Color[,]) and ModifyHeight(Point, byte[,]) keep working.
Properties
Lighting
Use/support lighting when rendering this terrain?
public bool Lighting { get; }
Property Value
PreCheckBounding
Controls whether intersection tests first check the bounding bodies to filter out broad misses.
protected override bool PreCheckBounding { get; }
Property Value
Remarks
Turn this off for bodies whose bounding bodies nearly every ray hits anyway.
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
engineEngineThe Engine to create the terrain in
sizeSizeThe size of the terrain
stretchHfloatA factor by which all horizontal distances are multiplied
stretchVfloatA factor by which all vertical distances are multiplied
heightMapByteGridThe height values of the terrain in a 2D array. Grid size = Terrain size
textureMapNibbleGridThe texture values of the terrain in a 2D array. Grid size = Terrain size / 3
texturesstring[]An array with a maximum of 16 texture names associated to
textureMapocclusionIntervalMapByteVector4GridThe angles at which the global light source occlusion begins and ends. Grid size = Terrain size; may be
nullfor no shadowinglightingboolShall this mesh be prepared for lighting? (calculate normal vectors, make shaders support lighting, ...)
blockSizeintHow 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
IntersectsGeometry(Ray, out float)
Determine whether the geometry of this PositionableRenderable is intersected by a ray in entity space.
protected override bool IntersectsGeometry(Ray ray, out float distance)
Parameters
rayRayA ray in entity space (the space BoundingSphere and BoundingBox live in, even before applying PreTransform) along which to check for intersections. Its direction is not normalized, so that distances keep the scale of the original ray.
distancefloatReturns the distance along the
rayat which the intersection took place.
Returns
- bool
trueif this PositionableRenderable was intersected by theray.
Remarks
Only called if the ray passes the bounding bodies, unless PreCheckBounding is off.
ModifyColor(Point, Color[,])
Modifies the color of a part of the terrain.
public void ModifyColor(Point start, Color[,] partialColorMap)
Parameters
startPointThe top-left index of the area to modify.
partialColorMapColor[,]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
startPointThe top-left index of the area to modify.
partialHeightMapbyte[,]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.