Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Scene Class Reference

Represents a 3D environment composed of objects, a background and additional environment lighting informations, along with serialization support. More...

#include <Scene.hpp>

Public Types

enum class  Background { COLOR , IMAGE , SKYBOX , ATMOSPHERE }
 The background mode to use for a scene. More...
 

Public Member Functions

 Scene (const std::string &name)
 
bool init (Storage options)
 
void update (double fullTime, double frameTime)
 
std::vector< KeyValuesencode () const
 
const BoundingBoxboundingBox () const
 
const Cameraviewpoint () const
 
void setViewpoint (const Camera &cam)
 
bool animated () const
 
bool transparent () const
 
 Scene (const Scene &)=delete
 
Sceneoperator= (const Scene &)=delete
 
 Scene (Scene &&)=delete
 
Sceneoperator= (Scene &&)=delete
 

Public Attributes

std::vector< Objectobjects
 The objects in the scene.
 
std::vector< Materialmaterials
 The materials in the scene.
 
std::vector< std::shared_ptr< Light > > lights
 Lights present in the scene.
 
Background backgroundMode = Background::COLOR
 The background mode (see enum).
 
std::unique_ptr< Objectbackground
 Background object, containing the geometry to use.
 
std::vector< LightProbeprobes
 Reflection probes.
 

Private Member Functions

bool loadObject (const KeyValues &params, Storage options)
 
bool loadMaterial (const KeyValues &params, Storage options)
 
bool loadLight (const KeyValues &params, Storage options)
 
bool loadCamera (const KeyValues &params, Storage options)
 
bool loadBackground (const KeyValues &params, Storage options)
 
bool loadProbe (const KeyValues &params, Storage options)
 
bool loadScene (const KeyValues &params, Storage options)
 
void computeBoundingBoxes (BoundingBox &globalBox, BoundingBox &casterBox)
 

Private Attributes

Material _backgroundMaterial
 Background material, containing the optional textures to use.
 
Camera _camera
 The initial viewpoint on the scene.
 
BoundingBox _bbox
 The scene bounding box.
 
glm::mat4 _sceneModel = glm::mat4(1.0f)
 The scene global transformation.
 
std::string _name
 The scene file name.
 
bool _loaded = false
 Has the scene already been loaded from disk.
 
bool _animated = false
 Is the scene using animations.
 
bool _transparent = false
 Is the scene containing transparent objects.
 

Detailed Description

Represents a 3D environment composed of objects, a background and additional environment lighting informations, along with serialization support.

Member Enumeration Documentation

◆ Background

enum class Scene::Background
strong

The background mode to use for a scene.

Enumerator
COLOR 

Use a unique color as background.

IMAGE 

Use a 2D texture image as background (will be stretched).

SKYBOX 

Use a skybox/cubemap as background.

ATMOSPHERE 

Use a realtime atmospheric scattering simulation.

Constructor & Destructor Documentation

◆ Scene() [1/3]

Scene::Scene ( const std::string &  name)
explicit

Constructor from a scene description file.

Parameters
namethe name of the scene description file

◆ Scene() [2/3]

Scene::Scene ( const Scene )
delete

Copy constructor.

◆ Scene() [3/3]

Scene::Scene ( Scene &&  )
delete

Move constructor.

Member Function Documentation

◆ animated()

bool Scene::animated ( ) const
inline
Returns
true if the scene contains animations

◆ boundingBox()

const BoundingBox & Scene::boundingBox ( ) const
inline

Get the scene bounding box.

Returns
the bounding box

◆ computeBoundingBoxes()

void Scene::computeBoundingBoxes ( BoundingBox globalBox,
BoundingBox casterBox 
)
private

Compute the bounding box of the scene, including and excluding objects that do not cast shadows.

Parameters
globalBoxthe bounding box encompassing all objects in the scene
casterBoxthe bounding box encompassing shadow casting objects only

◆ encode()

std::vector< KeyValues > Scene::encode ( ) const

Convert a scene to a Codable-compliant list of key-values tuples. Can be used for serialization.

Returns
a list of tuples

◆ init()

bool Scene::init ( Storage  options)

Performs initialization against the graphics API, loading data.

Parameters
optionsdata loading and storage options.
Returns
the initialization success

◆ loadBackground()

bool Scene::loadBackground ( const KeyValues params,
Storage  options 
)
private

Load the scene background informations from its serialized representation.

Parameters
paramsthe background parameters
optionsdata loading and storage options
Returns
the loading status

◆ loadCamera()

bool Scene::loadCamera ( const KeyValues params,
Storage  options 
)
private

Load the scene camera informations from its serialized representation.

Parameters
paramsthe camera parameters
optionsdata loading and storage options (unused)
Returns
the loading status

◆ loadLight()

bool Scene::loadLight ( const KeyValues params,
Storage  options 
)
private

Load a point light in the scene from its serialized representation.

Parameters
paramsthe point light parameters
optionsdata loading and storage options (unused)
Returns
the loading status

◆ loadMaterial()

bool Scene::loadMaterial ( const KeyValues params,
Storage  options 
)
private

Load a material in the scene from its serialized representation.

Parameters
paramsthe material parameters
optionsdata loading and storage options
Returns
the loading status

◆ loadObject()

bool Scene::loadObject ( const KeyValues params,
Storage  options 
)
private

Load an object in the scene from its serialized representation.

Parameters
paramsthe object parameters
optionsdata loading and storage options
Returns
the loading status

◆ loadProbe()

bool Scene::loadProbe ( const KeyValues params,
Storage  options 
)
private

Load the scene environment informations from its serialized representation.

Parameters
paramsthe probe parameters
optionsdata loading and storage options
Returns
the loading status

◆ loadScene()

bool Scene::loadScene ( const KeyValues params,
Storage  options 
)
private

Load the scene informations from its serialized representation.

Parameters
paramsthe scene parameters
optionsdata loading and storage options
Returns
the loading status

◆ operator=() [1/2]

Scene & Scene::operator= ( const Scene )
delete

Copy assignment.

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Scene & Scene::operator= ( Scene &&  )
delete

Move assignment.

Returns
a reference to the object assigned to

◆ setViewpoint()

void Scene::setViewpoint ( const Camera cam)
inline

Set the initial viewpoint on the scene.

Parameters
camthe new camera

◆ transparent()

bool Scene::transparent ( ) const
inline
Returns
true if the scene contains transparent objects

◆ update()

void Scene::update ( double  fullTime,
double  frameTime 
)

Update the animations in the scene.

Parameters
fullTimethe time elapsed since the beginning of the render loop
frameTimethe duration of the last frame

◆ viewpoint()

const Camera & Scene::viewpoint ( ) const
inline

Get the initial viewpoint on the scene.

Returns
the viewpoint camera

The documentation for this class was generated from the following files: