Click or drag to resize
DigitalRuneTerrainRenderer Class
Renders TerrainNodes.
Inheritance Hierarchy

Namespace: DigitalRune.Graphics.Rendering
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class TerrainRenderer : SceneNodeRenderer

The TerrainRenderer type exposes the following members.

Constructors
  NameDescription
Public methodTerrainRenderer
Initializes a new instance of the TerrainRenderer class.
Top
Methods
  NameDescription
Public methodCanRender
Determines whether this renderer can handle the specified scene node.
(Overrides SceneNodeRendererCanRender(SceneNode, RenderContext).)
Public methodClearMeshes
Clears the internally stored TerrainRendererMeshes.
Public methodDispose
Releases all resources used by an instance of the SceneNodeRenderer class.
(Inherited from SceneNodeRenderer.)
Protected methodDispose(Boolean)
Releases the unmanaged resources used by an instance of the SceneNodeRenderer class and optionally releases the managed resources.
(Overrides SceneNodeRendererDispose(Boolean).)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRender(SceneNode, RenderContext)
Renders the specified scene node.
(Inherited from SceneNodeRenderer.)
Public methodRender(IListSceneNode, RenderContext)
Renders the specified scene nodes.
(Inherited from SceneNodeRenderer.)
Public methodRender(IListSceneNode, RenderContext, RenderOrder)
Renders the specified scene nodes.
(Overrides SceneNodeRendererRender(IListSceneNode, RenderContext, RenderOrder).)
Public methodSetMesh
Adds a new TerrainRendererMesh.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyDrawWireFrame
Gets or sets a value indicating whether the wire frame of the terrain should be rendered for debugging.
Public propertyIsDisposed
Gets a value indicating whether this instance has been disposed of.
(Inherited from SceneNodeRenderer.)
Public propertyOrder
Gets the draw order of this scene node renderer.
(Inherited from SceneNodeRenderer.)
Top
Remarks

The TerrainRenderer renders TerrainNode using the Material of the node. The default material uses clipmaps (BaseClipmap and DetailClipmap). The clipmaps are created by the TerrainClipmapRenderer - not by the TerrainRenderer!

Each terrain node is rendered using an internal static geo-clipmap mesh. The mesh is represented by the class TerrainRendererMesh. An instance of TerrainRendererMesh is created automatically when needed and cached internally. However, the creation of the mesh can take up to several seconds. Therefore it is recommended to build the mesh offline and store the instance as a file using Save(Stream). At runtime, the pre-built mesh can be loaded using Load(GraphicsDevice, Stream) and passed to the TerrainRenderer using SetMesh(TerrainRendererMesh).

The mesh needs to match the BaseClipmap of the TerrainNode. The properties NumberOfLevels and CellsPerLevel determine the size of the mesh. The terrain renderer automatically creates and caches one internal mesh for each configuration it encounters.

Wire frame rendering:
DrawWireFrame can be set to render the wire frame of the terrain for debugging. This works only if the material of the terrain node provides a render pass "WireFrame".

Render Target and Viewport:
This renderer renders into the current render target and viewport of the graphics device.

Disposing:
The internally stored TerrainRendererMesh instances are disposed when the TerrainRenderer is disposed!

See Also