Class SpriteInstancer
- Namespace
- LibGFX.Core.GameElements
- Assembly
- LibGFX.dll
Represents a sprite instancer that can render multiple instances of a sprite using instancing.
public class SpriteInstancer : GameElement, IIdentifier, IPropertyTable, ISerialization
- Inheritance
-
SpriteInstancer
- Implements
- Inherited Members
Constructors
SpriteInstancer(IMaterial)
Initializes a new instance of the SpriteInstancer class with the specified material.
public SpriteInstancer(IMaterial material)
Parameters
materialIMaterial
SpriteInstancer(IMaterial, uint)
Initializes a new instance of the SpriteInstancer class with the specified material and number of instances.
public SpriteInstancer(IMaterial material, uint instances)
Parameters
Properties
HasTransparency
Gets a value indicating whether the image contains any transparent pixels.
public override bool HasTransparency { get; }
Property Value
InstanceContainer
The instance container that holds the instances of the sprite.
public RenderInstanceContainer InstanceContainer { get; set; }
Property Value
Material
The material used for rendering the sprite instances.
public IMaterial Material { get; set; }
Property Value
Mesh
The mesh used for rendering the sprite instances.
public Mesh Mesh { get; }
Property Value
Shader
The shader program used for rendering the sprite instances.
public RenderShader Shader { get; set; }
Property Value
Methods
AddInstance(Transform, Vector4, bool)
Adds a new instance to the sprite instancer with the specified transform and UV transform.
public int AddInstance(Transform transform, Vector4 uvTransform, bool visible = true)
Parameters
Returns
BakeInstances(uint)
Bakes the specified number of instances into the sprite instancer.
public void BakeInstances(uint instanceCount = 10)
Parameters
instanceCountuint
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
Exceptions
Dispose(BaseScene, IRenderDevice)
Disposes the sprite instancer and its resources.
public override void Dispose(BaseScene scene, IRenderDevice renderer)
Parameters
sceneBaseScenerendererIRenderDevice
Init(BaseScene, Viewport, IRenderDevice)
Initializes the sprite 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 sprite instancer using the specified scene, viewport, renderer, and camera.
public override void Render(BaseScene scene, Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
sceneBaseSceneviewportViewportrendererIRenderDevicecameraCamera