OmegaEngine API  1.0.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | List of all members
OmegaEngine.Graphics.Renderables.Terrain Class Reference

Displays a multi-textured terrain More...

Inheritance diagram for OmegaEngine.Graphics.Renderables.Terrain:
OmegaEngine.Graphics.Renderables.Model OmegaEngine.Graphics.Renderables.PositionableRenderable OmegaEngine.Graphics.Renderables.Renderable OmegaEngine.IPositionableOffset OmegaEngine.EngineElement OmegaEngine.IResetable OmegaEngine.IPositionable

Public Member Functions

void ModifyColor (Point start, Color[,] partialColorMap)
 Modifies the color of a part of the terrain. More...
 
void ModifyHeight (Point start, byte[,] partialHeightMap)
 Modifies the height of a part of the terrain. More...
 
- Public Member Functions inherited from OmegaEngine.Graphics.Renderables.Model
void SetTexture (ITextureProvider texture)
 Sets the first diffuse texture of the first material. More...
 
 Model (XMesh mesh)
 Creates a new model based upon a XMesh, using its internal material data if available. More...
 
 Model (XMesh mesh, params XMaterial[] materials)
 Creates a new model based upon a XMesh, using an external texture and a plain white material. More...
 
 Model (Mesh mesh, params XMaterial[] materials)
 Creates a new model based upon a custom mesh. More...
 
override bool Intersects (Ray ray, out float distance)
 Determine whether this PositionableRenderable is intersected by a ray.
 
- Public Member Functions inherited from OmegaEngine.Graphics.Renderables.PositionableRenderable
void SetScale (float factor)
 Scales this PositionableRenderable symmetrically More...
 
bool IsVisible (Camera camera)
 Checks whether this object is visible at the moment (includes Frustum Culling and other filtering criteria). More...
 
bool Intersects (Ray ray, out DoubleVector3 position)
 Determine whether this PositionableRenderable is intersected by a ray. More...
 
- Public Member Functions inherited from OmegaEngine.Graphics.Renderables.Renderable
override string ToString ()
 
- Public Member Functions inherited from OmegaEngine.EngineElement
void Dispose ()
 

Static Public Member Functions

static Terrain Create (Engine engine, Size size, float stretchH, float stretchV, ByteGrid heightMap, NibbleGrid textureMap, string[] textures, ByteVector4Grid occlusionIntervalMap, bool lighting, int blockSize)
 Creates a new terrain from a height-map and a texture-map More...
 
- Static Public Member Functions inherited from OmegaEngine.Graphics.Renderables.Model
static Model Quad (Engine engine, ITextureProvider texture=null, float width=5, float height=5)
 Creates a model of a textured 2D quad. More...
 
static Model Box (Engine engine, ITextureProvider texture=null, float width=5, float height=5, float depth=5)
 Creates a model of a textured box. More...
 
static Model Sphere (Engine engine, ITextureProvider texture=null, float radius=10, int slices=20, int stacks=20)
 Creates a model of a textured sphere with spherical mapping. More...
 
static Model Cylinder (Engine engine, ITextureProvider texture, float radiusBottom, float radiusTop, float length, int slices, int stacks)
 Creates a model of a textured sphere with spherical mapping. More...
 
static Model Cylinder (Engine engine, ITextureProvider texture=null, float radiusBottom=1, float radiusTop=1, float length=10)
 Creates a model of a textured cylinder with spherical mapping. More...
 
static Model Disc (Engine engine, ITextureProvider texture, float radiusInner, float radiusOuter, float height, int segments)
 Creates a model of a textured round disc with a hole in the middle. More...
 
static Model Disc (Engine engine, ITextureProvider texture=null, float radiusInner=5, float radiusOuter=7, float height=1)
 Creates a model of a textured round disc with a hole in the middle. More...
 

Protected Member Functions

override void RecalcWorldTransform ()
 Called to generate/update transformation matrices and related values
 
 Terrain (Mesh mesh, XMaterial material, bool lighting)
 Internal helper constructor More...
 
override bool IntersectsBounding (Ray ray)
 Determine whether PositionableRenderable.WorldBoundingBox and PositionableRenderable.WorldBoundingSphere (if defined) are intersected by a ray.
 
virtual Vector3 GetFacePosition (int faceIndex, float u, float v)
 
- Protected Member Functions inherited from OmegaEngine.Graphics.Renderables.Model
void RenderSubset (int i, Camera camera, LightSource[] lights)
 
override void OnDispose ()
 Hook that is called when the object needs to dispose its internal resources.
 
- Protected Member Functions inherited from OmegaEngine.Graphics.Renderables.PositionableRenderable
void RenderHelper (Action render, XMaterial material, Camera camera, params LightSource[] lights)
 Provides an automatic rendering framework that handles things like setting textures, materials, lighting and shaders. More...
 
override void OnEngineSet ()
 Hook that is calld when Engine is set for the first time.
 
- Protected Member Functions inherited from OmegaEngine.Graphics.Renderables.Renderable
virtual void OnPreRender ()
 
void PrepareRender ()
 Should be called before rendering anything - usually called by base constructor More...
 
- Protected Member Functions inherited from OmegaEngine.EngineElement
void RegisterChild (EngineElement element, bool autoDispose=true)
 Registers a child EngineElement for automatic Engine setting and Dispose calling. More...
 
void UnregisterChild (EngineElement element)
 Unregisters a child EngineElement (opposite of RegisterChild). More...
 

Properties

bool Lighting [get]
 Use/support lighting when rendering this terrain? More...
 
Size Size [get]
 The size of the terrain in game units More...
 
float StretchH [get]
 A factor by which the terrain is horizontally stretched More...
 
float StretchV [get]
 A factor by which the terrain is vertically stretched More...
 
- Properties inherited from OmegaEngine.Graphics.Renderables.Model
int NumberSubsets [get, protected set]
 The numbers of subsets in this model More...
 
- Properties inherited from OmegaEngine.Graphics.Renderables.PositionableRenderable
bool Pickable = true [get, set]
 Shall this PositionableRenderable be pickable with the mouse? More...
 
ViewType RenderIn [get, set]
 In what kind of Views shall this body be rendered? More...
 
SurfaceEffect SurfaceEffect [get, set]
 What kinds of surface effects (e.g. lighting) to apply to this PositionableRenderable More...
 
SurfaceShader SurfaceShader [get, set]
 The SurfaceShader to apply to the surface of this PositionableRenderable More...
 
BillboardMode Billboard [get, set]
 How this PositionableRenderable shall be rotated towards the camera More...
 
Matrix PreTransform [get, set]
 A transformation matrix that is to be applied before the normal world transform occurs - useful for correcting off-center meshes More...
 
Vector3 Scale [get, set]
 Scaling to be performed before rendering More...
 
Quaternion Rotation [get, set]
 The body's rotation quaternion More...
 
DoubleVector3 Position [get, set]
 The body's position in world space More...
 
BoundingSphere? BoundingSphere [get, protected set]
 A sphere that completely encompasses the body (in entity space, even before apply PreTransform). More...
 
BoundingSphereWorldBoundingSphere [get]
 A sphere that completely encompasses the body (in world space, used for culling tests). More...
 
bool DrawBoundingSphere [get, set]
 Shall the bounding sphere used to cull this object be drawn/visualized? (used for debugging) More...
 
BoundingBox? BoundingBox [get, protected set]
 A axis-aligned box that completely encompasses the body (in entity space, even before apply PreTransform). More...
 
BoundingBoxWorldBoundingBox [get]
 An axis-aligned box that completely encompasses the body (in world space, used for culling tests). More...
 
bool DrawBoundingBox [get, set]
 Shall the bounding box used to cull this object be drawn/visualized? (used for debugging) More...
 
- Properties inherited from OmegaEngine.Graphics.Renderables.Renderable
int RenderCount [get]
 How many times has this entity been rendered in this frame? More...
 
string Name [get, set]
 Text value to make it easier to identify a particular render entity More...
 
bool Visible = true [get, set]
 Shall the entity be rendered? More...
 
bool Wireframe [get, set]
 Shall this entity be drawn in wireframe-mode? (used for debugging) More...
 
float VisibilityDistance [get, set]
 The maximum distance from which the entity is visible - 0 for infinite More...
 
int Alpha [get, set]
 The level of transparency from 0 (solid) to 255 (invisible), OmegaEngine.EngineState.AlphaChannel, OmegaEngine.EngineState.BinaryAlphaChannel or OmegaEngine.EngineState.AdditivBlending More...
 
- Properties inherited from OmegaEngine.EngineElement
Engine Engine [get, set]
 The Engine instance used by this object. Must be set before using the object. May not be changed once it has been set! More...
 
bool IsDisposed [get]
 Indicates whether this object has been disposed and can therefore no longer be used. More...
 
- Properties inherited from OmegaEngine.IPositionableOffset
DoubleVector3 Offset [get, set]
 A value to be subtracted from IPositionable.Position in order gain IPositionableOffset.EffectivePosition More...
 
Vector3 EffectivePosition [get]
 The sum of IPositionable.Position and IPositionableOffset.EffectivePosition More...
 
- Properties inherited from OmegaEngine.IPositionable
DoubleVector3 Position [get, set]
 The object's position More...
 

Additional Inherited Members

- Public Attributes inherited from OmegaEngine.Graphics.Renderables.Model
readonly XMaterial [] Materials
 An array of materials used to render this mesh More...
 
int VertexCount => Mesh.VertexCount
 The numbers of vertexes in this model More...
 
- Public Attributes inherited from OmegaEngine.Graphics.Renderables.PositionableRenderable
ICollection< ViewRequiredViews => _requiredViews
 A list of Views that must be rendered before this PositionableRenderable can be rendered More...
 
- Public Attributes inherited from OmegaEngine.EngineElement
bool IsEngineSet => _engine != null
 true if the Engine has been set. More...
 
- Protected Attributes inherited from OmegaEngine.Graphics.Renderables.Model
readonly Mesh Mesh
 The mesh object to use for rendering; never null. More...
 
- Protected Attributes inherited from OmegaEngine.Graphics.Renderables.PositionableRenderable
bool WorldTransformDirty = true
 Does the world transform need to be recalculated? More...
 
- Events inherited from OmegaEngine.Graphics.Renderables.Renderable
Action PreRender
 Occurs once per frame before rendering the entity. Will not be executed if the entity is excluded by a culling test. More...
 

Detailed Description

Displays a multi-textured terrain

Constructor & Destructor Documentation

◆ Terrain()

OmegaEngine.Graphics.Renderables.Terrain.Terrain ( Mesh  mesh,
XMaterial  material,
bool  lighting 
)
inlineprotected

Internal helper constructor

Parameters
meshThe mesh use for rendering
materialThe material to use for rendering the terrain
lightingUse/support lighting when rendering this terrain?

Member Function Documentation

◆ Create()

static Terrain OmegaEngine.Graphics.Renderables.Terrain.Create ( Engine  engine,
Size  size,
float  stretchH,
float  stretchV,
ByteGrid  heightMap,
NibbleGrid  textureMap,
string []  textures,
ByteVector4Grid  occlusionIntervalMap,
bool  lighting,
int  blockSize 
)
inlinestatic

Creates a new terrain from a height-map and a texture-map

Parameters
engineThe Engine to create the terrain in
sizeThe size of the terrain
stretchHA factor by which all horizontal distances are multiplied
stretchVA factor by which all vertical distances are multiplied
heightMapThe height values of the terrain in a 2D array. Grid size = Terrain size
occlusionIntervalMapThe angles at which the global light source occlusion begins and ends. Grid size = Terrain size; may be null for no shadowing
textureMapThe texture values of the terrain in a 2D array. Grid size = Terrain size / 3
texturesAn array with a maximum of 16 texture names associated to textureMap
lightingShall this mesh be prepared for lighting? (calculate normal vectors, make shaders support lighting, ...)
blockSizeHow many points in X and Y direction shall one block for culling be?
Returns
The newly created terrain
Exceptions
FileNotFoundExceptionOn of the specified texture files could not be found.
IOExceptionThere was an error reading one of the texture files.
UnauthorizedAccessExceptionRead access to one of the texture files is not permitted.
InvalidDataExceptionOne of the texture files does not contain a valid texture.

◆ ModifyColor()

void OmegaEngine.Graphics.Renderables.Terrain.ModifyColor ( Point  start,
Color  partialColorMap[,] 
)
inline

Modifies the color of a part of the terrain.

Parameters
startThe top-left index of the area to modify.
partialColorMapA 2D array containing the new color values - array size specifies size of the area to modify.

Cannot be called when Lighting is false, because coloring uses the lighting subsystem.

◆ ModifyHeight()

void OmegaEngine.Graphics.Renderables.Terrain.ModifyHeight ( Point  start,
byte  partialHeightMap[,] 
)
inline

Modifies the height of a part of the terrain.

Parameters
startThe top-left index of the area to modify.
partialHeightMapA 2D array containing the new height values; array size specifies size of the area to modify.

Cannot be called when Lighting is true, because normals are not updated. Invalidates all internal BoundingBoxes.

Property Documentation

◆ Lighting

bool OmegaEngine.Graphics.Renderables.Terrain.Lighting
get

Use/support lighting when rendering this terrain?

◆ Size

Size OmegaEngine.Graphics.Renderables.Terrain.Size
get

The size of the terrain in game units

◆ StretchH

float OmegaEngine.Graphics.Renderables.Terrain.StretchH
get

A factor by which the terrain is horizontally stretched

◆ StretchV

float OmegaEngine.Graphics.Renderables.Terrain.StretchV
get

A factor by which the terrain is vertically stretched


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