Class Light3DManager
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
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
IsInitialized
Gets a value indicating whether the object has been initialized.
public bool IsInitialized { get; }
Property Value
Methods
AddPointLight(PointLight3D)
Adds an point light to the light manager.
public void AddPointLight(PointLight3D light)
Parameters
lightPointLight3D
BindLights(Viewport, IRenderDevice, Camera)
Binds the lights to the shader.
public void BindLights(Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
viewportViewportrendererIRenderDevicecameraCamera
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
lightLightThe 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
viewportViewportrendererIRenderDevicecameraCamera
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
objJObjectserializationContextSerializationContextcallbackFunc<JObject, bool>
Dispose(IRenderDevice)
Disposes of the light manager and releases any resources.
public void Dispose(IRenderDevice renderDevice)
Parameters
renderDeviceIRenderDevice
DisposeLights(IRenderDevice)
Releases all light resources associated with the specified render device.
public void DisposeLights(IRenderDevice renderDevice)
Parameters
renderDeviceIRenderDeviceThe 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
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
actionAction<T>
Type Parameters
T
Exceptions
FreeCPUResources()
Frees any CPU resources used by the light manager.
public void FreeCPUResources()
Exceptions
GetAllLights()
Gets all the lights in the scene.
public IEnumerable<PointLight3D> GetAllLights()
Returns
GetLightCount<T>()
Gets the light count of the specified type.
public int GetLightCount<T>() where T : Light
Returns
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
Init(IRenderDevice)
Initializes the light manager with the given render device.
public void Init(IRenderDevice renderDevice)
Parameters
renderDeviceIRenderDevice
ResizeChunkSize(float)
Resizes the chunk size and re-adds all the lights to the new chunks.
public void ResizeChunkSize(float newSize)
Parameters
newSizefloat
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
writerJsonWriterserializationContextSerializationContextThe context to use during serialization, which may provide settings or state required for the serialization process.
callbackAction<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
lightViewMatrixMatrix4