C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
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

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Описание методов

AddEntity() публичный метод

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
Результат void

AddSceneNode() публичный метод

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
Результат void

Build() публичный метод

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
Результат void

CalculateBounds() защищенный метод

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
Результат Axiom.MathLib.AxisAlignedBox

Destroy() публичный метод

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
Результат void

DetermineGeometry() защищенный метод

protected DetermineGeometry ( SubMesh sm ) : List
sm SubMesh
Результат List

Dump() публичный метод

public Dump ( ) : void
Результат void

GetRegion() защищенный метод

protected GetRegion ( Axiom.MathLib.AxisAlignedBox bounds, bool autoCreate ) : Axiom.Core.Region
bounds Axiom.MathLib.AxisAlignedBox
autoCreate bool
Результат Axiom.Core.Region

GetRegion() защищенный метод

protected GetRegion ( Vector3 point, bool autoCreate ) : Axiom.Core.Region
point Vector3
autoCreate bool
Результат Axiom.Core.Region

GetRegion() защищенный метод

protected GetRegion ( uint index ) : Axiom.Core.Region
index uint
Результат Axiom.Core.Region

GetRegion() защищенный метод

protected GetRegion ( ushort x, ushort y, ushort z, bool autoCreate ) : Axiom.Core.Region
x ushort
y ushort
z ushort
autoCreate bool
Результат Axiom.Core.Region

GetRegionBounds() защищенный метод

protected GetRegionBounds ( ushort x, ushort y, ushort z ) : Axiom.MathLib.AxisAlignedBox
x ushort
y ushort
z ushort
Результат Axiom.MathLib.AxisAlignedBox

GetRegionCenter() защищенный метод

protected GetRegionCenter ( ushort x, ushort y, ushort z ) : Vector3
x ushort
y ushort
z ushort
Результат Vector3

GetRegionIndexes() защищенный метод

protected GetRegionIndexes ( Vector3 point, ushort &x, ushort &y, ushort &z ) : void
point Vector3
x ushort
y ushort
z ushort
Результат void

GetVolumeIntersection() защищенный метод

protected GetVolumeIntersection ( Axiom.MathLib.AxisAlignedBox box, ushort x, ushort y, ushort z ) : float
box Axiom.MathLib.AxisAlignedBox
x ushort
y ushort
z ushort
Результат float

PackIndex() защищенный метод

protected PackIndex ( ushort x, ushort y, ushort z ) : uint
x ushort
y ushort
z ushort
Результат uint

Reset() публичный метод

Clears any of the entities / nodes added to this geometry and destroys anything which has already been built.
public Reset ( ) : void
Результат void

SplitGeometry() защищенный метод

protected SplitGeometry ( VertexData vd, IndexData id, Axiom.Core.SubMeshLodGeometryLink targetGeomLink ) : void
vd Axiom.Graphics.VertexData
id Axiom.Graphics.IndexData
targetGeomLink Axiom.Core.SubMeshLodGeometryLink
Результат void

StaticGeometry() публичный метод

public StaticGeometry ( SceneManager owner, string name, int logLevel ) : System
owner SceneManager
name string
logLevel int
Результат System

Описание свойств

buildCount защищенное свойство

protected int buildCount
Результат int

built защищенное свойство

protected bool built
Результат bool

castShadows защищенное свойство

protected bool castShadows
Результат bool

halfRegionDimensions защищенное свойство

protected Vector3 halfRegionDimensions
Результат Vector3

logLevel защищенное свойство

protected int logLevel
Результат int

name защищенное свойство

protected string name
Результат string

optimisedSubMeshGeometryList защищенное свойство

protected List optimisedSubMeshGeometryList
Результат List

origin защищенное свойство

protected Vector3 origin
Результат Vector3

owner защищенное свойство

protected SceneManager,Axiom.Core owner
Результат SceneManager

queuedSubMeshes защищенное свойство

protected List queuedSubMeshes
Результат List

regionDimensions защищенное свойство

protected Vector3 regionDimensions
Результат Vector3

regionHalfRange защищенное статическое свойство

protected static int regionHalfRange
Результат int

regionMap защищенное свойство

protected Dictionary regionMap
Результат Region>.Dictionary

regionMaxIndex защищенное статическое свойство

protected static int regionMaxIndex
Результат int

regionMinIndex защищенное статическое свойство

protected static int regionMinIndex
Результат int

regionRange защищенное статическое свойство

protected static int regionRange
Результат int

regionSize защищенное статическое свойство

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
Результат int

renderQueueID защищенное свойство

protected RenderQueueGroupID renderQueueID
Результат RenderQueueGroupID

renderQueueIDSet защищенное свойство

protected bool renderQueueIDSet
Результат bool

squaredUpperDistance защищенное свойство

protected float squaredUpperDistance
Результат float

subMeshGeometryLookup защищенное свойство

protected Dictionary> subMeshGeometryLookup
Результат List>.Dictionary

upperDistance защищенное свойство

protected float upperDistance
Результат float

visible защищенное свойство

protected bool visible
Результат bool