Table of Contents

Class PointLight3DHandle

Namespace
LibGFX.Core.GameElements
Assembly
LibGFX.dll

Represents a handle for a 3D point light within a game scene, providing management and synchronization of the light's position with its associated transform.

public class PointLight3DHandle : GameElement, IIdentifier, IPropertyTable, ISerialization
Inheritance
PointLight3DHandle
Implements
Inherited Members

Remarks

Use this class to control a point light's placement and lifecycle in a 3D environment. The light's position is automatically updated when the transform changes. Dispose of the handle when the light is no longer needed to release resources and detach event handlers.

Constructors

PointLight3DHandle()

Initializes a new instance of the PointLight3DHandle class.

public PointLight3DHandle()

PointLight3DHandle(string, Vector3, Vector4, float, float)

Initializes a new instance of the PointLight3DHandle class with the specified name, position, color, range, and intensity.

public PointLight3DHandle(string name, Vector3 position, Vector4 color, float range = 10, float intesity = 1)

Parameters

name string

The unique name used to identify the point light instance.

position Vector3

The position of the point light in 3D space.

color Vector4

The color of the point light, including its alpha component.

range float

The effective range of the point light, in world units. Must be greater than zero.

intesity float

The intensity of the point light. Must be a non-negative value.

Remarks

If no transform is assigned, a new Transform is created and initialized with the specified position. The transform's Changed event is automatically subscribed to for internal updates. This class adds the point light to the scene and manages its lifecycle, including disposal of resources

Properties

HasTransparency

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

public override bool HasTransparency { get; }

Property Value

bool

LightSource

Gets or sets the point light source used for 3D scene illumination.

public PointLight3D LightSource { get; set; }

Property Value

PointLight3D

Remarks

Changing this property affects how objects in the scene are lit and how shadows are rendered. The light source position and intensity determine the appearance of lighting effects.

Methods

ComputeAABB()

Calculates and updates the axis-aligned bounding box (AABB) for the current light source based on its position and range.

public override void ComputeAABB()

Remarks

This method sets the AABB property to encompass the area affected by the light source. Call this method after modifying the light source's position or range to ensure the bounding box remains accurate.

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

Deserializes the object from a JSON representation, restoring its state including the associated light source.

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

Parameters

obj JObject
serializationContext SerializationContext
callback Func<JObject, bool>

Exceptions

InvalidOperationException

Dispose(BaseScene, IRenderDevice)

Releases resources used by the object and detaches event handlers associated with the specified scene and render device.

public override void Dispose(BaseScene scene, IRenderDevice renderer)

Parameters

scene BaseScene

The scene context for which resources should be released.

renderer IRenderDevice

The render device associated with the scene that is used for resource management.

Init(BaseScene, Viewport, IRenderDevice)

Initializes the game element

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

Parameters

scene BaseScene
viewport Viewport
renderer IRenderDevice

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the current object to a JSON representation, including type and light source information.

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

Parameters

writer JsonWriter
serializationContext SerializationContext

The context that provides settings and state for the serialization process.

callback Action<JsonWriter>