C# Class Axiom.Components.Terrain.TerrainMaterialGenerator

Class that provides functionality to generate materials for use with a terrain.
Terrains are composed of one or more layers of texture information, and require that a material is generated to render them. There are various approaches to rendering the terrain, which may vary due to:
  • Hardware support (static)
  • Texture instances assigned to a particular terrain (dynamic in an editor)
  • User selection (e.g. changing to a cheaper option in order to increase performance, or in order to test how the material might look on other hardware (dynamic)
Subclasses of this class are responsible for responding to these factors and to generate a terrain material. @par In order to cope with both hardware support and user selection, the generator must expose a number of named 'profiles'. These profiles should function on a known range of hardware, and be graded by quality. At runtime, the user should be able to select the profile they wish to use (provided hardware support is available).
Inheritance: IDisposable
Show file Open project: WolfgangSt/axiom Class Usage Examples

Protected Properties

Property Type Description
mActiveProfile Profile
mChangeCounter int
mCompositeMapCam Axiom.Core.Camera
mCompositeMapLight Axiom.Core.Light
mCompositeMapPlane ManualObject
mCompositeMapRTT Axiom.Core.Texture
mCompositeMapSM Axiom.Core.SceneManager
mDebugLevel uint
mLayerDecl TerrainLayerDeclaration
mProfiles List

Public Methods

Method Description
CanGenerateUsingDeclaration ( TerrainLayerDeclaration decl ) : bool

Whether this generator can generate a material for a given declaration. By default this only returns true if the declaration is equal to the standard one returned from getLayerDeclaration, but if a subclass wants to be flexible to generate materials for other declarations too, it can specify here.

Dispose ( ) : void
Generate ( Axiom.Components.Terrain.Terrain terrain ) : Material

Generate a material for the given terrain using the active profile.

GenerateForCompositeMap ( Axiom.Components.Terrain.Terrain terrain ) : Material

Generate a material for the given composite map of the terrain using the active profile.

GetMaxLayers ( Axiom.Components.Terrain.Terrain terrain ) : byte

Get the maximum number of layers supported with the given terrain.

MarkChanged ( ) : void

Internal method - indicates that a change has been made that would require material regeneration

RenderCompositeMap ( int size, Rectangle rect, Material mat, Axiom.Core.Texture destCompositeMap ) : void

Helper method to render a composite map.

RequestOption ( Axiom.Components.Terrain.Terrain terrain ) : void

Triggers the generator to request the options that it needs.

SetActiveProfile ( string name ) : void

Set the active profile by name.

UpdateCompositeMap ( Axiom.Components.Terrain.Terrain terrain, Rectangle rect ) : void

Update the composite map for a terrain. The composite map for a terrain must match what the terrain should look like at distance. This method will only be called in the render thread so the generator is free to render into a texture to support this, so long as the results are blitted into the Terrain's own composite map afterwards.

UpdateParams ( Material mat, Axiom.Components.Terrain.Terrain terrain ) : void

Update parameters for the given terrain using the active profile.

UpdateParamsForCompositeMap ( Material mat, Axiom.Components.Terrain.Terrain terrain ) : void

Update parameters for the given terrain using the active profile.

Method Details

CanGenerateUsingDeclaration() public method

Whether this generator can generate a material for a given declaration. By default this only returns true if the declaration is equal to the standard one returned from getLayerDeclaration, but if a subclass wants to be flexible to generate materials for other declarations too, it can specify here.
public CanGenerateUsingDeclaration ( TerrainLayerDeclaration decl ) : bool
decl TerrainLayerDeclaration
return bool

Dispose() public method

public Dispose ( ) : void
return void

Generate() public method

Generate a material for the given terrain using the active profile.
public Generate ( Axiom.Components.Terrain.Terrain terrain ) : Material
terrain Axiom.Components.Terrain.Terrain
return Axiom.Graphics.Material

GenerateForCompositeMap() public method

Generate a material for the given composite map of the terrain using the active profile.
public GenerateForCompositeMap ( Axiom.Components.Terrain.Terrain terrain ) : Material
terrain Axiom.Components.Terrain.Terrain
return Axiom.Graphics.Material

GetMaxLayers() public method

Get the maximum number of layers supported with the given terrain.
public GetMaxLayers ( Axiom.Components.Terrain.Terrain terrain ) : byte
terrain Axiom.Components.Terrain.Terrain
return byte

MarkChanged() public method

Internal method - indicates that a change has been made that would require material regeneration
public MarkChanged ( ) : void
return void

RenderCompositeMap() public method

Helper method to render a composite map.
public RenderCompositeMap ( int size, Rectangle rect, Material mat, Axiom.Core.Texture destCompositeMap ) : void
size int The requested composite map size
rect Axiom.Core.Rectangle The region of the composite map to update, in image space
mat Axiom.Graphics.Material The material to use to render the map
destCompositeMap Axiom.Core.Texture
return void

RequestOption() public method

Triggers the generator to request the options that it needs.
public RequestOption ( Axiom.Components.Terrain.Terrain terrain ) : void
terrain Axiom.Components.Terrain.Terrain
return void

SetActiveProfile() public method

Set the active profile by name.
public SetActiveProfile ( string name ) : void
name string name of the profile
return void

UpdateCompositeMap() public method

Update the composite map for a terrain. The composite map for a terrain must match what the terrain should look like at distance. This method will only be called in the render thread so the generator is free to render into a texture to support this, so long as the results are blitted into the Terrain's own composite map afterwards.
public UpdateCompositeMap ( Axiom.Components.Terrain.Terrain terrain, Rectangle rect ) : void
terrain Axiom.Components.Terrain.Terrain
rect Axiom.Core.Rectangle
return void

UpdateParams() public method

Update parameters for the given terrain using the active profile.
public UpdateParams ( Material mat, Axiom.Components.Terrain.Terrain terrain ) : void
mat Axiom.Graphics.Material
terrain Axiom.Components.Terrain.Terrain
return void

UpdateParamsForCompositeMap() public method

Update parameters for the given terrain using the active profile.
public UpdateParamsForCompositeMap ( Material mat, Axiom.Components.Terrain.Terrain terrain ) : void
mat Axiom.Graphics.Material
terrain Axiom.Components.Terrain.Terrain
return void

Property Details

mActiveProfile protected property

the currently active profile
protected Profile mActiveProfile
return Profile

mChangeCounter protected property

protected int mChangeCounter
return int

mCompositeMapCam protected property

protected Camera,Axiom.Core mCompositeMapCam
return Axiom.Core.Camera

mCompositeMapLight protected property

protected Light,Axiom.Core mCompositeMapLight
return Axiom.Core.Light

mCompositeMapPlane protected property

protected ManualObject mCompositeMapPlane
return ManualObject

mCompositeMapRTT protected property

deliberately holding this by raw pointer to avoid shutdown issues
protected Texture,Axiom.Core mCompositeMapRTT
return Axiom.Core.Texture

mCompositeMapSM protected property

protected SceneManager,Axiom.Core mCompositeMapSM
return Axiom.Core.SceneManager

mDebugLevel protected property

protected uint mDebugLevel
return uint

mLayerDecl protected property

protected TerrainLayerDeclaration,Axiom.Components.Terrain mLayerDecl
return TerrainLayerDeclaration

mProfiles protected property

List of profiles - NB should be ordered in descending complexity
protected List mProfiles
return List