Table of Contents

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

mesh Mesh
material IMaterial

Properties

HasTransparency

Gets a value indicating whether the image contains any transparent pixels.

public override bool HasTransparency { get; }

Property Value

bool

InstanceContainer

The container that holds the instances of the mesh.

public RenderInstanceContainer InstanceContainer { get; set; }

Property Value

RenderInstanceContainer

Material

The material used for rendering the mesh instances.

public IMaterial Material { get; set; }

Property Value

IMaterial

Mesh

The mesh to be instanced.

public Mesh Mesh { get; set; }

Property Value

Mesh

Shader

The shader program used for rendering the mesh instances.

public RenderShader Shader { get; set; }

Property Value

RenderShader

Methods

AddInstance(Transform, bool)

Adds a new instance of the mesh to the instancer.

public int AddInstance(Transform transform, bool visible = true)

Parameters

transform Transform
visible bool

Returns

int

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

instanceCount uint

The amount of instances you want bake

Exceptions

ArgumentOutOfRangeException

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

instanceId int

Returns

InstanceHandle

Dispose(BaseScene, IRenderDevice)

Disposes the mesh instancer and its resources.

public override void Dispose(BaseScene scene, IRenderDevice renderer)

Parameters

scene BaseScene
renderer IRenderDevice

FindHiddenInstances(int)

Finds hidden instances in the instancer and returns their indices.

public IEnumerable<int> FindHiddenInstances(int count)

Parameters

count int

Returns

IEnumerable<int>

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

scene BaseScene
viewport Viewport
renderer IRenderDevice

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

scene BaseScene
viewport Viewport
renderer IRenderDevice
camera Camera

RenderShadow(BaseScene, Viewport, IRenderDevice)

Renders the shadow of the game element

public override void RenderShadow(BaseScene scene, Viewport viewport, IRenderDevice renderer)

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice

Update(BaseScene, float)

Update the handles of the mesh instances in the instancer.

public override void Update(BaseScene scene, float dt)

Parameters

scene BaseScene
dt float