Class RenderInstanceContainer
Represents a container for managing and rendering instanced meshes.
Inherited Members
Namespace: Genesis.Graphics
Assembly: Genesis.dll
Syntax
public class RenderInstanceContainer : GameElement
Constructors
RenderInstanceContainer(InstancedMesh, ShaderProgram)
Initializes a new instance of the RenderInstanceContainer class with a specified mesh and shader.
Declaration
public RenderInstanceContainer(InstancedMesh mesh, ShaderProgram shader)
Parameters
Type | Name | Description |
---|---|---|
InstancedMesh | mesh | The instanced mesh to add. |
ShaderProgram | shader | The shader program to use for rendering. |
RenderInstanceContainer(ShaderProgram)
Initializes a new instance of the RenderInstanceContainer class with a specified shader.
Declaration
public RenderInstanceContainer(ShaderProgram shader)
Parameters
Type | Name | Description |
---|---|---|
ShaderProgram | shader | The shader program to use for rendering. |
Properties
Meshes
Gets or sets the collection of instanced meshes.
Declaration
public List<InstancedMesh> Meshes { get; set; }
Property Value
Type | Description |
---|---|
List<InstancedMesh> |
Shader
Gets or sets the shader program used for rendering the instances.
Declaration
public ShaderProgram Shader { get; set; }
Property Value
Type | Description |
---|---|
ShaderProgram |
UpdateInstances
Gets or sets a value indicating whether the instances need to be updated.
Declaration
public bool UpdateInstances { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
AddInstance(Vec3, Vec3, Vec3)
Adds a new instance to the container with specified position, size, and optional rotation.
Declaration
public InstancedElement AddInstance(Vec3 position, Vec3 size, Vec3 rotation = default)
Parameters
Type | Name | Description |
---|---|---|
Vec3 | position | The position of the instance. |
Vec3 | size | The size of the instance. |
Vec3 | rotation | The rotation of the instance. Default is no rotation. |
Returns
Type | Description |
---|---|
InstancedElement | The created InstancedElement. |
GetMatrices()
Retrieves an array of transformation matrices for all instances.
Declaration
public float[] GetMatrices()
Returns
Type | Description |
---|---|
float[] | An array of transformation matrices as floats. |
Init(Game, IRenderDevice)
Initializes the container with the specified game and render device.
Declaration
public override void Init(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |
Overrides
OnDestroy(Game)
Cleans up resources associated with the container when it is destroyed.
Declaration
public override void OnDestroy(Game game)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
Overrides
OnRender(Game, IRenderDevice)
Renders the container using the specified game and render device.
Declaration
public override void OnRender(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |
Overrides
OnUpdate(Game, IRenderDevice)
Updates the instances in the container if UpdateInstances is set to true.
Declaration
public override void OnUpdate(Game game, IRenderDevice renderDevice)
Parameters
Type | Name | Description |
---|---|---|
Game | game | The game instance. |
IRenderDevice | renderDevice | The render device used for rendering. |
Overrides
UpdateInstanceMatrix(int, float[])
Updates the transformation matrix for a specific instance.
Declaration
public void UpdateInstanceMatrix(int instanceId, float[] data)
Parameters
Type | Name | Description |
---|---|---|
int | instanceId | The ID of the instance to update. |
float[] | data | The new transformation matrix data. |