Class Skybox
- Namespace
- LibGFX.Graphics.Enviroment
- Assembly
- LibGFX.dll
Represents a skybox environment that renders a surrounding cubemap in a 3D scene.
public class Skybox : IEnviroment, IGraphicsResource, ISerialization
- Inheritance
-
Skybox
- Implements
- Inherited Members
Remarks
A skybox is typically used to simulate distant backgrounds such as skies or space by rendering a textured cube around the camera. The Skybox class manages the cubemap texture and its transformation, and provides methods to initialize, render, and dispose of the skybox resources. The skybox automatically follows the camera's position to maintain the illusion of an infinitely distant environment.
Constructors
Skybox(Cubemap)
Initializes a new instance of the Skybox class using the specified cubemap texture.
public Skybox(Cubemap cubemap)
Parameters
cubemapCubemapThe cubemap texture to use for rendering the skybox. Cannot be null.
Properties
Cubemap
Gets or sets the cubemap texture used for rendering or environment mapping.
public Cubemap Cubemap { get; set; }
Property Value
IsInitialized
Gets a value indicating whether the object has been initialized.
public bool IsInitialized { get; }
Property Value
Transform
Gets or sets the transformation applied to the object, including position, rotation, and scale.
public Transform Transform { get; set; }
Property Value
Methods
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)
Releases all resources used by the cubemap using the specified render device.
public void Dispose(IRenderDevice renderer)
Parameters
rendererIRenderDeviceThe render device to use when disposing of the cubemap resources. Cannot be null.
FreeCPUResources()
Releases any CPU resources that are currently allocated by the component.
public void FreeCPUResources()
Remarks
Call this method when the component no longer needs to perform CPU-intensive operations to allow the system to reclaim resources. After calling this method, the component may not be able to perform certain operations until resources are reallocated.
Init(IRenderDevice)
Initializes the cubemap resources using the specified render device.
public void Init(IRenderDevice renderer)
Parameters
rendererIRenderDeviceThe render device to use for initializing cubemap resources. Cannot be null.
Render(IRenderDevice, Camera, Viewport)
Renders the environment cubemap using the specified renderer, camera, and viewport.
public void Render(IRenderDevice renderer, Camera camera, Viewport viewport)
Parameters
rendererIRenderDeviceThe rendering device used to draw the cubemap. Must not be null.
cameraCameraThe camera that defines the viewpoint and position for rendering. Must not be null.
viewportViewportThe viewport that specifies the area of the render target to draw to.
Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)
Serializes the current object to a JSON representation using the specified serialization context.
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>