Class MeshInstancer
- Namespace
- LibGFX.Core.GameElements
- Assembly
- LibGFX.dll
Represents a mesh instancer that can render multiple instances of a mesh with a material.
public class MeshInstancer : GameElement, IIdentifier, IPropertyTable, ISerialization
- Inheritance
-
MeshInstancer
- Implements
- Inherited Members
Constructors
MeshInstancer(Mesh, IMaterial)
Creates a new instance of the MeshInstancer class.
public MeshInstancer(Mesh mesh, IMaterial material)
Parameters
Properties
HasTransparency
Gets a value indicating whether the image contains any transparent pixels.
public override bool HasTransparency { get; }
Property Value
InstanceContainer
The container that holds the instances of the mesh.
public RenderInstanceContainer InstanceContainer { get; set; }
Property Value
Material
The material used for rendering the mesh instances.
public IMaterial Material { get; set; }
Property Value
Mesh
The mesh to be instanced.
public Mesh Mesh { get; set; }
Property Value
Shader
The shader program used for rendering the mesh instances.
public RenderShader Shader { get; set; }
Property Value
Methods
AddInstance(Transform, bool)
Adds a new instance of the mesh to the instancer.
public int AddInstance(Transform transform, bool visible = true)
Parameters
Returns
BakeInstances(uint)
Bakes a specified number of instances into the instancer. This instances are hidden untill you set them to visible.
public void BakeInstances(uint instanceCount = 10)
Parameters
instanceCountuintThe amount of instances you want bake
Exceptions
ComputeAABB()
Computes the axis-aligned bounding box (AABB) of the game element.
public override void ComputeAABB()
CreateInstanceHandle(int)
Creates a new instance handle for the specified instance ID.
public InstanceHandle CreateInstanceHandle(int instanceId)
Parameters
instanceIdint
Returns
Dispose(BaseScene, IRenderDevice)
Disposes the mesh instancer and its resources.
public override void Dispose(BaseScene scene, IRenderDevice renderer)
Parameters
sceneBaseScenerendererIRenderDevice
FindHiddenInstances(int)
Finds hidden instances in the instancer and returns their indices.
public IEnumerable<int> FindHiddenInstances(int count)
Parameters
countint
Returns
Init(BaseScene, Viewport, IRenderDevice)
Initializes the mesh instancer with the specified scene, viewport, and renderer.
public override void Init(BaseScene scene, Viewport viewport, IRenderDevice renderer)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevice
Render(BaseScene, Viewport, IRenderDevice, Camera)
Renders the mesh instances using the specified scene, viewport, renderer, and camera.
public override void Render(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevicecameraCamera
RenderShadow(BaseScene, Viewport, IRenderDevice)
Renders the shadow of the game element
public override void RenderShadow(BaseScene scene, Viewport viewport, IRenderDevice renderer)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevice
Update(BaseScene, float)
Update the handles of the mesh instances in the instancer.
public override void Update(BaseScene scene, float dt)