C# Class Axiom.Core.StaticGeometry

Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
Modern graphics cards (GPUs) prefer to receive geometry in large batches. It is orders of magnitude faster to render 10 batches of 10,000 triangles than it is to render 10,000 batches of 10 triangles, even though both result in the same number of on-screen triangles.
Therefore it is important when you are rendering a lot of geometry to batch things up into as few rendering calls as possible. This class allows you to build a batched object from a series of entities in order to benefit from this behaviour. Batching has implications of it's own though:
  • Batched geometry cannot be subdivided; that means that the whole group will be displayed, or none of it will. This obivously has culling issues.
  • A single world transform must apply to the entire batch. Therefore once you have batched things, you can't move them around relative to each other. That's why this class is most useful when dealing with static geometry (hence the name). In addition, geometry is effectively duplicated, so if you add 3 entities based on the same mesh in different positions, they will use 3 times the geometry space than the movable version (which re-uses the same geometry). So you trade memory and flexibility of movement for pure speed when using this class.
  • A single material must apply for each batch. In fact this class allows you to use multiple materials, but you should be aware that internally this means that there is one batch per material. Therefore you won't gain as much benefit from the batching if you use many different materials; try to keep the number down.

In order to retain some sort of culling, this class will batch up meshes in localised regions. The size and shape of these blocks is controlled by the SceneManager which contructs this object, since it makes sense to batch things up in the most appropriate way given the existing partitioning of the scene.
The LOD settings of both the Mesh and the Materials used in constructing this static geometry will be respected. This means that if you use meshes/materials which have LOD, batches in the distance will have a lower polygon count or material detail to those in the foreground. Since each mesh might have different LOD distances, during build the furthest distance at each LOD level from all meshes in that region is used. This means all the LOD levels change at the same time, but at the furthest distance of any of them (so quality is not degraded). Be aware that using Mesh LOD in this class will further increase the memory required. Only generated LOD is supported for meshes.
There are 2 ways you can add geometry to this class; you can add Entity objects directly with predetermined positions, scales and orientations, or you can add an entire SceneNode and it's subtree, including all the objects attached to it. Once you've added everthing you need to, you have to call build() the fix the geometry in place.
This class is not a replacement for world geometry (see SceneManager.WorldGeometry). The single most efficient way to render large amounts of static geometry is to use a SceneManager which is specialised for dealing with that particular world structure. However, this class does provide you with a good 'halfway house' between generalised movable geometry (Entity) which works with all SceneManagers but isn't efficient when using very large numbers, and highly specialised world geometry which is extremely fast but not generic and typically requires custom world editors.
You should not construct instances of this class directly; instead, call SceneManager.CreateStaticGeometry, which gives the SceneManager the option of providing you with a specialised version of this class if it wishes, and also handles the memory management for you like other classes.
Afficher le fichier Open project: WolfgangSt/axiom Class Usage Examples

Protected Properties

Свойство Type Description
buildCount int
built bool
castShadows bool
halfRegionDimensions Vector3
logLevel int
name string
optimisedSubMeshGeometryList List
origin Vector3
owner SceneManager
queuedSubMeshes List
regionDimensions Vector3
regionHalfRange int
regionMap Region>.Dictionary
regionMaxIndex int
regionMinIndex int
regionRange int
regionSize int
renderQueueID RenderQueueGroupID
renderQueueIDSet bool
squaredUpperDistance float
subMeshGeometryLookup List>.Dictionary
upperDistance float
visible bool

Méthodes publiques

Méthode Description
AddEntity ( Entity ent, Vector3 position, Axiom.MathLib.Quaternion orientation, Vector3 scale ) : void

Adds an Entity to the static geometry.

This method takes an existing Entity and adds its details to the list of elements to include when building. Note that the Entity itself is not copied or referenced in this method; an Entity is passed simply so that you can change the materials of attached SubEntity objects if you want. You can add the same Entity instance multiple times with different material settings completely safely, and destroy the Entity before destroying this StaticGeometry if you like. The Entity passed in is simply used as a definition. Note: Must be called before 'build'.

AddSceneNode ( SceneNode node ) : void

Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry.

This method performs just like addEntity, except it adds all the entities attached to an entire sub-tree to the geometry. The position / orientation / scale parameters are taken from the node structure instead of being specified manually.

Build ( ) : void

Build the geometry.

Based on all the entities which have been added, and the batching options which have been set, this method constructs the batched geometry structures required. The batches are added to the scene and will be rendered unless you specifically hide them.

Destroy ( ) : void

Destroys all the built geometry state (reverse of build).

You can call build() again after this and it will pick up all the same entities / nodes you queued last time.

Dump ( ) : void
Reset ( ) : void

Clears any of the entities / nodes added to this geometry and destroys anything which has already been built.

StaticGeometry ( SceneManager owner, string name, int logLevel ) : System

Méthodes protégées

Méthode Description
CalculateBounds ( VertexData vertexData, Vector3 position, Axiom.MathLib.Quaternion orientation, Vector3 scale ) : Axiom.MathLib.AxisAlignedBox
DetermineGeometry ( SubMesh sm ) : List
GetRegion ( Axiom.MathLib.AxisAlignedBox bounds, bool autoCreate ) : Axiom.Core.Region
GetRegion ( Vector3 point, bool autoCreate ) : Axiom.Core.Region
GetRegion ( uint index ) : Axiom.Core.Region
GetRegion ( ushort x, ushort y, ushort z, bool autoCreate ) : Axiom.Core.Region
GetRegionBounds ( ushort x, ushort y, ushort z ) : Axiom.MathLib.AxisAlignedBox
GetRegionCenter ( ushort x, ushort y, ushort z ) : Vector3
GetRegionIndexes ( Vector3 point, ushort &x, ushort &y, ushort &z ) : void
GetVolumeIntersection ( Axiom.MathLib.AxisAlignedBox box, ushort x, ushort y, ushort z ) : float
PackIndex ( ushort x, ushort y, ushort z ) : uint
SplitGeometry ( VertexData vd, IndexData id, Axiom.Core.SubMeshLodGeometryLink targetGeomLink ) : void

Method Details

AddEntity() public méthode

Adds an Entity to the static geometry.
This method takes an existing Entity and adds its details to the list of elements to include when building. Note that the Entity itself is not copied or referenced in this method; an Entity is passed simply so that you can change the materials of attached SubEntity objects if you want. You can add the same Entity instance multiple times with different material settings completely safely, and destroy the Entity before destroying this StaticGeometry if you like. The Entity passed in is simply used as a definition. Note: Must be called before 'build'.
public AddEntity ( Entity ent, Vector3 position, Axiom.MathLib.Quaternion orientation, Vector3 scale ) : void
ent Entity The Entity to use as a definition (the Mesh and Materials
position Vector3 The world position at which to add this Entity
orientation Axiom.MathLib.Quaternion The world orientation at which to add this Entity
scale Vector3 The scale at which to add this entity
Résultat void

AddSceneNode() public méthode

Adds all the Entity objects attached to a SceneNode and all it's children to the static geometry.
This method performs just like addEntity, except it adds all the entities attached to an entire sub-tree to the geometry. The position / orientation / scale parameters are taken from the node structure instead of being specified manually.
public AddSceneNode ( SceneNode node ) : void
node SceneNode Pointer to the node to use to provide a set of Entity templates
Résultat void

Build() public méthode

Build the geometry.
Based on all the entities which have been added, and the batching options which have been set, this method constructs the batched geometry structures required. The batches are added to the scene and will be rendered unless you specifically hide them.
public Build ( ) : void
Résultat void

CalculateBounds() protected méthode

protected CalculateBounds ( VertexData vertexData, Vector3 position, Axiom.MathLib.Quaternion orientation, Vector3 scale ) : Axiom.MathLib.AxisAlignedBox
vertexData Axiom.Graphics.VertexData
position Vector3
orientation Axiom.MathLib.Quaternion
scale Vector3
Résultat Axiom.MathLib.AxisAlignedBox

Destroy() public méthode

Destroys all the built geometry state (reverse of build).
You can call build() again after this and it will pick up all the same entities / nodes you queued last time.
public Destroy ( ) : void
Résultat void

DetermineGeometry() protected méthode

protected DetermineGeometry ( SubMesh sm ) : List
sm SubMesh
Résultat List

Dump() public méthode

public Dump ( ) : void
Résultat void

GetRegion() protected méthode

protected GetRegion ( Axiom.MathLib.AxisAlignedBox bounds, bool autoCreate ) : Axiom.Core.Region
bounds Axiom.MathLib.AxisAlignedBox
autoCreate bool
Résultat Axiom.Core.Region

GetRegion() protected méthode

protected GetRegion ( Vector3 point, bool autoCreate ) : Axiom.Core.Region
point Vector3
autoCreate bool
Résultat Axiom.Core.Region

GetRegion() protected méthode

protected GetRegion ( uint index ) : Axiom.Core.Region
index uint
Résultat Axiom.Core.Region

GetRegion() protected méthode

protected GetRegion ( ushort x, ushort y, ushort z, bool autoCreate ) : Axiom.Core.Region
x ushort
y ushort
z ushort
autoCreate bool
Résultat Axiom.Core.Region

GetRegionBounds() protected méthode

protected GetRegionBounds ( ushort x, ushort y, ushort z ) : Axiom.MathLib.AxisAlignedBox
x ushort
y ushort
z ushort
Résultat Axiom.MathLib.AxisAlignedBox

GetRegionCenter() protected méthode

protected GetRegionCenter ( ushort x, ushort y, ushort z ) : Vector3
x ushort
y ushort
z ushort
Résultat Vector3

GetRegionIndexes() protected méthode

protected GetRegionIndexes ( Vector3 point, ushort &x, ushort &y, ushort &z ) : void
point Vector3
x ushort
y ushort
z ushort
Résultat void

GetVolumeIntersection() protected méthode

protected GetVolumeIntersection ( Axiom.MathLib.AxisAlignedBox box, ushort x, ushort y, ushort z ) : float
box Axiom.MathLib.AxisAlignedBox
x ushort
y ushort
z ushort
Résultat float

PackIndex() protected méthode

protected PackIndex ( ushort x, ushort y, ushort z ) : uint
x ushort
y ushort
z ushort
Résultat uint

Reset() public méthode

Clears any of the entities / nodes added to this geometry and destroys anything which has already been built.
public Reset ( ) : void
Résultat void

SplitGeometry() protected méthode

protected SplitGeometry ( VertexData vd, IndexData id, Axiom.Core.SubMeshLodGeometryLink targetGeomLink ) : void
vd Axiom.Graphics.VertexData
id Axiom.Graphics.IndexData
targetGeomLink Axiom.Core.SubMeshLodGeometryLink
Résultat void

StaticGeometry() public méthode

public StaticGeometry ( SceneManager owner, string name, int logLevel ) : System
owner SceneManager
name string
logLevel int
Résultat System

Property Details

buildCount protected_oe property

protected int buildCount
Résultat int

built protected_oe property

protected bool built
Résultat bool

castShadows protected_oe property

protected bool castShadows
Résultat bool

halfRegionDimensions protected_oe property

protected Vector3 halfRegionDimensions
Résultat Vector3

logLevel protected_oe property

protected int logLevel
Résultat int

name protected_oe property

protected string name
Résultat string

optimisedSubMeshGeometryList protected_oe property

protected List optimisedSubMeshGeometryList
Résultat List

origin protected_oe property

protected Vector3 origin
Résultat Vector3

owner protected_oe property

protected SceneManager,Axiom.Core owner
Résultat SceneManager

queuedSubMeshes protected_oe property

protected List queuedSubMeshes
Résultat List

regionDimensions protected_oe property

protected Vector3 regionDimensions
Résultat Vector3

regionHalfRange protected_oe static_oe property

protected static int regionHalfRange
Résultat int

regionMap protected_oe property

protected Dictionary regionMap
Résultat Region>.Dictionary

regionMaxIndex protected_oe static_oe property

protected static int regionMaxIndex
Résultat int

regionMinIndex protected_oe static_oe property

protected static int regionMinIndex
Résultat int

regionRange protected_oe static_oe property

protected static int regionRange
Résultat int

regionSize protected_oe static_oe property

This is the size of each dimension of a region; it can be set via a public property. By default, set to 100 meters
protected static int regionSize
Résultat int

renderQueueID protected_oe property

protected RenderQueueGroupID renderQueueID
Résultat RenderQueueGroupID

renderQueueIDSet protected_oe property

protected bool renderQueueIDSet
Résultat bool

squaredUpperDistance protected_oe property

protected float squaredUpperDistance
Résultat float

subMeshGeometryLookup protected_oe property

protected Dictionary> subMeshGeometryLookup
Résultat List>.Dictionary

upperDistance protected_oe property

protected float upperDistance
Résultat float

visible protected_oe property

protected bool visible
Résultat bool