Class Scene3D
Represents a 3D scene for rendering 3D objects and lights.
public class Scene3D : BaseScene, IIdentifier, ISerialization
- Inheritance
-
Scene3D
- Implements
- Inherited Members
Constructors
Scene3D()
Creates a new 3D scene
public Scene3D()
Properties
DirectionalLight
Sets the directional light for the scene
public DirectionalLight3D DirectionalLight { get; set; }
Property Value
Elements
Gets or sets the collection of game elements contained in this instance.
public List<GameElement> Elements { get; set; }
Property Value
Enviroment
The enviroment texture of the scene
public IEnviroment Enviroment { get; set; }
Property Value
LightManager
The light manager for the 3D scene
public override ILightManager LightManager { get; }
Property Value
PerformShadowPass
Determines if the scene should perform a shadow pass
public bool PerformShadowPass { get; set; }
Property Value
RenderEnviromentTexture
Determines if the enviroment texture should be rendered
public bool RenderEnviromentTexture { get; set; }
Property Value
RenderTarget
Gets the render target associated with this scene instance.
public override IRenderTarget RenderTarget { get; }
Property Value
Samples
The number of samples for the scene rendering
public uint Samples { get; set; }
Property Value
Methods
AddEnqueEntry(IEnqueEntry)
Adds an enque entry to the scene which gets processed during the enque phase
public override void AddEnqueEntry(IEnqueEntry entry)
Parameters
entryIEnqueEntry
Exceptions
AddGameElement(GameElement)
Adds a game element to the scene
public override void AddGameElement(GameElement element)
Parameters
elementGameElement
Exceptions
AddLight<T>(T)
Adds a light to the scene. Supports point and directional lights.
public override void AddLight<T>(T light) where T : Light
Parameters
lightTThe light instance to add to the scene. Must be a supported light type.
Type Parameters
TThe type of the light to add. Must be either PointLight3D or DirectionalLight3D.
Remarks
Only PointLight3D and DirectionalLight3D types are supported. Attempting to add other light types will result in a NotSupportedException.
Exceptions
- NotSupportedException
Thrown if the specified light type is not supported by the scene.
ClearElements()
Clrears all elements from the scene
public override void ClearElements()
CreateDefaultScene()
Creates a new 3D scene with a default configuration, including a directional light source.
public static Scene3D CreateDefaultScene()
Returns
Deserialize(JObject, SerializationContext, Func<JObject, bool>)
Deserializes the scene from JSON
public override void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)
Parameters
objJObjectserializationContextSerializationContextcallbackFunc<JObject, bool>
Exceptions
DisposeScene(IRenderDevice)
Disposes the scene and all its layers
public override void DisposeScene(IRenderDevice renderer)
Parameters
rendererIRenderDevice
EnqueElements()
Processes the enque entries and adds the elements to the scene. Clears the enque entries after processing.
public override void EnqueElements()
Exceptions
FindElement<T>(string)
Finds a game element by its name
public override T? FindElement<T>(string name) where T : GameElement
Parameters
namestring
Returns
- T
Type Parameters
T
FindElementsWithBehavior<T>()
Finds all game elements with the specified behavior
public override ICollection<GameElement> FindElementsWithBehavior<T>() where T : IGameBehavior
Returns
Type Parameters
T
FindElementsWithTag(string)
Finds all game elements with the specified tag
public override ICollection<GameElement> FindElementsWithTag(string tag)
Parameters
tagstring
Returns
ForEachElement(Action<GameElement>)
For each game element in the scene, perform the specified action
public override void ForEachElement(Action<GameElement> action)
Parameters
actionAction<GameElement>
FreeScene(IRenderDevice)
Frees the scene from the game elements
public override void FreeScene(IRenderDevice renderer)
Parameters
rendererIRenderDevice
GetAllElements()
Gets all game elements in the scene
public override IEnumerable<GameElement> GetAllElements()
Returns
GetElementByID(string)
Gets a game element by its unique identifier (UUID)
public override GameElement? GetElementByID(string uuid)
Parameters
uuidstring
Returns
GetElements<T>()
Gets all game elements of the specified type
public override ICollection<GameElement> GetElements<T>() where T : GameElement
Returns
Type Parameters
T
GetLight<T>()
Retrieves the scene's directional light if the specified type is supported.
public override T GetLight<T>() where T : Light
Returns
- T
The directional light instance cast to the specified type
T.
Type Parameters
TThe type of light to retrieve. Only DirectionalLight3D is supported.
Remarks
This method only supports retrieval of the directional light. Attempting to request other light types will result in an exception.
Exceptions
- NotSupportedException
Thrown if
Tis not DirectionalLight3D.
Init(Viewport, IRenderDevice)
Initializes the scene and all its layers
public override void Init(Viewport viewport, IRenderDevice renderer)
Parameters
viewportViewportrendererIRenderDevice
InitializeElements(Viewport, IRenderDevice)
Initializes the scene elements
public override void InitializeElements(Viewport viewport, IRenderDevice renderer)
Parameters
viewportViewportrendererIRenderDevice
RemoveElement(GameElement)
Removes a game element from the scene
public override void RemoveElement(GameElement element)
Parameters
elementGameElement
Exceptions
RemoveLight<T>(T)
Removes a directional light from the scene if it is currently present.
public override void RemoveLight<T>(T light) where T : Light
Parameters
lightTThe light instance to remove from the scene. Must be a DirectionalLight3D that is part of the scene.
Type Parameters
TThe type of light to remove. Must be a DirectionalLight3D.
Remarks
Only directional lights are supported for removal. Attempting to remove other light types will result in a NotSupportedException.
Exceptions
- InvalidOperationException
Thrown if the specified directional light is not part of the scene.
- NotSupportedException
Thrown if the specified light type is not supported by Scene3D.
Render(Viewport, IRenderDevice, Camera)
Renders the scene and all its layers
public override void Render(Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
viewportViewportrendererIRenderDevicecameraCamera
RenderShadowMaps(Viewport, IRenderDevice, Camera)
Renders the shadow maps for the scene
public override void RenderShadowMaps(Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
viewportViewportrendererIRenderDevicecameraCamera
Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)
Serializes the scene to JSON
public override void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)
Parameters
writerJsonWriterserializationContextSerializationContextcallbackAction<JsonWriter>
Update(float)
Updates the scene and all its layers
public override void Update(float dt)
Parameters
dtfloat
UpdatePhysics(float)
Updates the physics of the scene
public override void UpdatePhysics(float dt)
Parameters
dtfloat
Events
AfterLightCulling
Called after light culling has been performed
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> AfterLightCulling
Event Type
AfterRenderTargetCreation
Called after the render target for the scene has been created
public override event Action<BaseScene, Viewport, IRenderDevice> AfterRenderTargetCreation
Event Type
OnDispose
Called when the scene gets disposed
public override event Action<BaseScene, IRenderDevice> OnDispose
Event Type
OnDisposeEnd
Called after the scene has been disposed
public override event Action<BaseScene, IRenderDevice> OnDisposeEnd
Event Type
OnDisposeStart
Called before the scene is disposed
public override event Action<BaseScene, IRenderDevice> OnDisposeStart
Event Type
OnInitEnd
Called when the scene has been initialized
public override event Action<BaseScene, Viewport, IRenderDevice> OnInitEnd
Event Type
OnInitStart
Called when the scene is initializing
public override event Action<BaseScene, Viewport, IRenderDevice> OnInitStart
Event Type
OnPhysicsUpdateEnd
Called when the physics update ends
public override event Action<BaseScene, float> OnPhysicsUpdateEnd
Event Type
OnPhysicsUpdateStart
Called when the physics update starts
public override event Action<BaseScene, float> OnPhysicsUpdateStart
Event Type
OnRenderEnd
Called at the end of the render process
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderEnd
Event Type
OnRenderPassBegin
Called before the game elements get rendered
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderPassBegin
Event Type
OnRenderPassEnd
Called when all game elements have been rendered before the render target blitting
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderPassEnd
Event Type
OnRenderStart
Called immediately on the start of the render process
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderStart
Event Type
OnShadowPassEnd
Called when the shadow pass ends
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassEnd
Event Type
OnShadowPassStart
Called when the shadow pass starts
public override event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassStart
Event Type
OnUpdateEnd
Called when the scene has been updated
public override event Action<BaseScene, float> OnUpdateEnd
Event Type
OnUpdateStart
Called when the scene is updating
public override event Action<BaseScene, float> OnUpdateStart