Lysa  0.0
Lysa 3D Engine
Scene Class Reference

Detailed Description

Represents a 3D scene containing lights and mesh instances.

The Scene class manages the high-level representation of a scene, including its environment, lights, and mesh instances.

+ Inheritance diagram for Scene:

Public Member Functions

 Scene (const SceneConfiguration &config={})
 
 ~Scene () override
 
void setEnvironment (const Environment &environment) const
 
bool haveInstance (const MeshInstance &meshInstance) const
 
void addInstance (MeshInstance &meshInstance, bool async=false)
 
void updateInstance (MeshInstance &meshInstance) const
 
void removeInstance (const MeshInstance &meshInstance)
 
void updateMaterialPipeline (const MeshInstance &meshInstance)
 
void addLight (const Light &light) const
 
void removeLight (const Light &light) const
 
void processDeferredOperations (uint32 frameIndex)
 
SceneFrameDataget (const uint32 frameIndex) const
 
std::optional< RayCastHitrayCast (const Ray &ray, const MeshInstance *parent=nullptr) const
 
std::set< RayCastHitrayCastAll (const Ray &ray, const MeshInstance *parent=nullptr) const
 
- Public Member Functions inherited from UniqueResource
 UniqueResource () = default
 
 UniqueResource (UniqueResource &) = delete
 
UniqueResource & operator= (UniqueResource &) = delete
 
- Public Member Functions inherited from UnmanagedResource
 UnmanagedResource ()
 
 UnmanagedResource (const Resource &other)
 
- Public Member Functions inherited from Resource
bool operator== (const Resource &other) const
 
 Resource () = default
 
 Resource (const unique_id id)
 
virtual ~Resource () = default
 

Protected Attributes

ImageManagerimageManager
 
MaterialManagermaterialManager
 
MeshManagermeshManager
 

Additional Inherited Members

- Public Attributes inherited from Resource
unique_id id {INVALID_ID}
 

Constructor & Destructor Documentation

Scene ( const SceneConfiguration config = {})

Constructs a Scene with a given configuration.

Parameters
configScene configuration settings.
~Scene ( )
override

Virtual destructor for Scene.

Member Function Documentation

void addInstance ( MeshInstance meshInstance,
bool  async = false 
)

Adds a mesh instance to the scene.

Parameters
meshInstanceThe mesh instance to add.
asyncWhether to add the instance asynchronously.
void addLight ( const Light light) const

Adds a light to the scene.

Parameters
lightThe light to add.
SceneFrameData& get ( const uint32  frameIndex) const
inline

Gets the frame-specific data for a given frame index.

Parameters
frameIndexThe index of the frame.
Returns
A reference to the SceneFrameData for the frame.
bool haveInstance ( const MeshInstance meshInstance) const

Checks if a mesh instance is present in the scene.

Parameters
meshInstanceThe mesh instance to check.
Returns
True if the instance is in the scene, false otherwise.
void processDeferredOperations ( uint32  frameIndex)

Processes deferred scene operations for a specific frame.

Parameters
frameIndexThe index of the frame to process.
std::optional<RayCastHit> rayCast ( const Ray ray,
const MeshInstance parent = nullptr 
) const

Casts a ray (without using the physics engine) through all MeshInstances in the scene and returns the closest hit. The size of direction defines the max distance.

Parameters
rayWorld-space ray origin and world-space ray direction (un-normalized; length = max distance)
parentOptional mesh to ignore
std::set<RayCastHit> rayCastAll ( const Ray ray,
const MeshInstance parent = nullptr 
) const

Casts a ray through the entire scene and collects the closest hit per MeshInstance along its length.

Parameters
rayWorld-space ray origin and world-space ray direction (un-normalized; length = max distance)
parentOptional mesh to ignore
Returns
Ordered set of RayCastHit, one per MeshInstance sorted by ascending distance.
void removeInstance ( const MeshInstance meshInstance)

Removes a mesh instance from the scene.

Parameters
meshInstanceThe mesh instance to remove.
void removeLight ( const Light light) const

Removes a light from the scene.

Parameters
lightThe light to remove.
void setEnvironment ( const Environment environment) const

Sets the environment for the scene.

Parameters
environmentThe environment settings to apply.
void updateInstance ( MeshInstance meshInstance) const

Updates an existing mesh instance.

Parameters
meshInstanceThe mesh instance to update.
void updateMaterialPipeline ( const MeshInstance meshInstance)

Moves a mesh instance from a pipeline to another

Parameters
meshInstanceThe mesh instance to move.

Member Data Documentation

ImageManager& imageManager
protected

Reference to the image manager.

MaterialManager& materialManager
protected

Reference to the material manager.

MeshManager& meshManager
protected

Reference to the mesh manager.