Table of Contents

Class Light3DManager

Namespace
LibGFX.Graphics.Lights
Assembly
LibGFX.dll

Manages 3D lights in the scene.

public class Light3DManager : ILightManager, ISerialization, IGraphicsResource
Inheritance
Light3DManager
Implements
Inherited Members

Constructors

Light3DManager()

Initializes a new instance of the Light3DManager class.

public Light3DManager()

Properties

ChunkSize

The chunk size for the lights. This is used to determine the size of each chunk in the scene.

public float ChunkSize { get; }

Property Value

float

Chunks

The dictionary of light chunks, where the key is a tuple of chunk coordinates (x, y, z).

public Dictionary<(int, int, int), Light3DChunk> Chunks { get; set; }

Property Value

Dictionary<(int, int, int), Light3DChunk>

DirectionalLight

The directional light in the scene.

public DirectionalLight3D DirectionalLight { get; set; }

Property Value

DirectionalLight3D

IsInitialized

Gets a value indicating whether the object has been initialized.

public bool IsInitialized { get; }

Property Value

bool

Methods

AddPointLight(PointLight3D)

Adds an point light to the light manager.

public void AddPointLight(PointLight3D light)

Parameters

light PointLight3D

BindLights(Viewport, IRenderDevice, Camera)

Binds the lights to the shader.

public void BindLights(Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

viewport Viewport
renderer IRenderDevice
camera Camera

ClearLights()

Removes all light sources from the current scene, including directional and chunk-based lights.

public void ClearLights()

Remarks

After calling this method, the scene will contain no active lights. Use this method to reset lighting before configuring new light sources.

ContainsLight(Light)

Determines whether the specified light is contained within this collection.

public bool ContainsLight(Light light)

Parameters

light Light

The light to locate in the collection. This can be a directional or point light.

Returns

bool

true if the specified light is present in the collection; otherwise, false.

Remarks

This method checks for both directional and point lights. For directional lights, it compares with the collection's directional light. For point lights, it searches all chunks in the collection.

CullLights(Viewport, IRenderDevice, Camera)

Culls the lights

public void CullLights(Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

viewport Viewport
renderer IRenderDevice
camera Camera

Deserialize(JObject, SerializationContext, Func<JObject, bool>)

Populates the current object with values from the specified JSON object.

public void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)

Parameters

obj JObject
serializationContext SerializationContext
callback Func<JObject, bool>

Dispose(IRenderDevice)

Disposes of the light manager and releases any resources.

public void Dispose(IRenderDevice renderDevice)

Parameters

renderDevice IRenderDevice

DisposeLights(IRenderDevice)

Releases all light resources associated with the specified render device.

public void DisposeLights(IRenderDevice renderDevice)

Parameters

renderDevice IRenderDevice

The render device whose light resources will be disposed. Cannot be null.

ForEachLight(Action<Light>)

Performs an action on each light in the scene, regardless of type.

public void ForEachLight(Action<Light> action)

Parameters

action Action<Light>

ForEachLight<T>(Action<T>)

Performs an action on each light of the specified type in the scene.

public void ForEachLight<T>(Action<T> action) where T : Light

Parameters

action Action<T>

Type Parameters

T

Exceptions

InvalidOperationException

FreeCPUResources()

Frees any CPU resources used by the light manager.

public void FreeCPUResources()

Exceptions

NotImplementedException

GetAllLights()

Gets all the lights in the scene.

public IEnumerable<PointLight3D> GetAllLights()

Returns

IEnumerable<PointLight3D>

GetLightCount<T>()

Gets the light count of the specified type.

public int GetLightCount<T>() where T : Light

Returns

int

Type Parameters

T

GetLight<T>()

Gets the light of the specified type from the light manager.

public T GetLight<T>() where T : Light

Returns

T

Type Parameters

T

Exceptions

InvalidOperationException

Init(IRenderDevice)

Initializes the light manager with the given render device.

public void Init(IRenderDevice renderDevice)

Parameters

renderDevice IRenderDevice

ResizeChunkSize(float)

Resizes the chunk size and re-adds all the lights to the new chunks.

public void ResizeChunkSize(float newSize)

Parameters

newSize float

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the current object and its associated data into a JSON representation.

public void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)

Parameters

writer JsonWriter
serializationContext SerializationContext

The context to use during serialization, which may provide settings or state required for the serialization process.

callback Action<JsonWriter>

SetLightSpaceMatrix(Matrix4)

Sets the light space matrix for the light manager, which is used to transform the light's perspective in the scene.

public void SetLightSpaceMatrix(Matrix4 lightViewMatrix)

Parameters

lightViewMatrix Matrix4