Path Tracer
Public Member Functions | List of all members
Scene Class Reference

Stores object groups and a camera for the render. More...

#include <Scene.h>

Public Member Functions

 Scene (PerspectiveCamera camera=PerspectiveCamera(), unsigned int samplesPerPixel=8, unsigned int minBounces=5)
 Main constructor. More...
 
 Scene (const Scene &scene)
 Copy constructor. More...
 
std::vector< Object3DGroupgetObjectGroups () const
 Getter for the object groups. More...
 
std::vector< Object3DGroup > & getObjectGroupsReference ()
 Getter for a reference to the object groups. More...
 
std::vector< Object3D * > getObjects ()
 Getter for the objects. More...
 
std::vector< Object3D * > getLamps ()
 Getter for the lamps. More...
 
PerspectiveCamera getCamera () const
 Getter for the camera. More...
 
PerspectiveCameragetCameraReference ()
 Getter for a reference to the camera. More...
 
unsigned int getSamplesPerPixel () const
 Getter for the number of samples per pixel. More...
 
unsigned int getMinBounces () const
 Getter for the minimum number of bounces. More...
 
bool getRussianRoulette () const
 Getter for the russian roulette. More...
 
double getRrStopProbability () const
 Getter for the russian roulette stop probability. More...
 
bool getNextEventEstimation () const
 Getter for the next event estimation. More...
 
unsigned int getNumberThreads () const
 Getter for the number of CPU threads. More...
 
bool getKDTree () const
 Getter for the k-d tree option. More...
 
unsigned int getKDMaxObjectNumber () const
 Getter for the maximum number of objects in a k-d tree leaf. More...
 
unsigned int getKDMaxDepth () const
 Getter for the maximum depth recursion of the k-d tree. More...
 
std::string getBackupFileName () const
 Getter for the name of the file in which backups will be made. More...
 
bool getBackupParameters () const
 Getter for the option to backup the parameters. More...
 
bool getBackupObjectGroups () const
 Getter for the option to backup the object groups. More...
 
bool getBackupPicture () const
 Getter for the option to backup the picture. More...
 
double getLeastRenderTime4PictureBackup () const
 Getter for the least render time after which the picture is backed up. More...
 
void setObjectGroups (std::vector< Object3DGroup > groups)
 Setter for the object groups. More...
 
void setCamera (PerspectiveCamera camera)
 Setter for the camera. More...
 
void setSamplesPerPixel (unsigned int samplesPerPixel)
 Setter for the number of samples per pixel. More...
 
void setMinBounces (unsigned int minBounces)
 Setter for the minimum number of bounces. More...
 
void setRussianRoulette (bool russianRoulette)
 Setter for the russian roulette. More...
 
void setRussianRoulette (bool russianRoulette, double rrStopProbability)
 Setter for the russian roulette and russian roulette stop probability. More...
 
void setRrStopProbability (double rrStopProbability)
 Setter for the russian roulette stop probability. More...
 
void setNextEventEstimation (bool nextEventEstimation)
 Setter for the next event estimation. More...
 
void setNumberThreads (unsigned int numberThreads)
 Setter for the number of CPU threads. More...
 
void setKDTree (bool kdTree)
 Setter for the k-d tree. More...
 
void setKDMaxObjectNumber (unsigned int kdMaxObjectNumber)
 Setter for the maximum number of objects in a k-d tree leaf. More...
 
void setKDMaxDepth (unsigned int kdMaxDepth)
 Setter for the maximum depth recursion of the k-d tree. More...
 
void setBackupFileName (std::string backupFileName)
 Setter for the new name of the file in which backups will be made. More...
 
void setBackupParameters (bool backupParameters)
 Setter for the option to backup the parameters. More...
 
void setBackupObjectGroups (bool backupObjectGroups)
 Setter for the option to backup the object groups. More...
 
void setBackupPicture (bool backupPicture)
 Setter for the option to backup the picture. More...
 
void setLeastRenderTime4PictureBackup (double leastRenderTime4PictureBackup)
 Setter for the least render time after which the picture is backed up. More...
 
void addObjectGroup (const Object3DGroup &group)
 Adds an object group to the current ones. More...
 
void resetAndDeleteObjectGroups ()
 Deletes all object groups and their objects. More...
 
void computeObjectsAndLamps ()
 Computes all the objects. More...
 
void defaultScene ()
 Sets this scene's objects to default ones. More...
 
void saveParameters2File (std::string fileName) const
 Saves parameters to a file. More...
 
void saveObjectGroups2File (std::string fileName) const
 Saves object groups to a file. More...
 
bool importFBXFile (const char *filePath, Material *material, std::string name)
 Imports a fbx file as triangles. More...
 
Picturerender ()
 Start the render of the picture. More...
 
void displayParametersPage (bool displayIndexes=true) const
 Prints the parameters page. More...
 
void displayObjectsPage () const
 Prints the objects page. More...
 

Detailed Description

Stores object groups and a camera for the render.

Constructor & Destructor Documentation

◆ Scene() [1/2]

Scene::Scene ( PerspectiveCamera  camera = PerspectiveCamera(),
unsigned int  samplesPerPixel = 8,
unsigned int  minBounces = 5 
)

Main constructor.

Parameters
cameraThe camera that will be used for the render.
samplesPerPixelThe number of ray casted per pixel. Increasing it will give a higher quality, but at a cost of a linearly increasing time.
minBouncesThe minimum number of bounces that each ray will do before beginning to use the russian roulette algorithm.

◆ Scene() [2/2]

Scene::Scene ( const Scene scene)

Copy constructor.

Parameters
sceneThe scene that will be copied.

Member Function Documentation

◆ addObjectGroup()

void Scene::addObjectGroup ( const Object3DGroup group)

Adds an object group to the current ones.

Parameters
groupThe object group that will be added.

◆ computeObjectsAndLamps()

void Scene::computeObjectsAndLamps ( )

Computes all the objects.

Also stores a vector of all objects having an emitance strictly greater than 1, to go faster with the next event estimation algorithm.

◆ defaultScene()

void Scene::defaultScene ( )

Sets this scene's objects to default ones.

The look is similar to the Cornell box.

See also
initInterface()

◆ displayObjectsPage()

void Scene::displayObjectsPage ( ) const

Prints the objects page.

This is one of the main pages.

See also
Scene::displayParametersPage()

◆ displayParametersPage()

void Scene::displayParametersPage ( bool  displayIndexes = true) const

Prints the parameters page.

This is one of the main pages.

Parameters
displayIndexesIf true it will print the indexes before each parameter. This is useful if for the user to be able to change them, but you can remove them if you only want the information (during the render, for example).
See also
Scene::displayObjectsPage()

◆ getBackupFileName()

std::string Scene::getBackupFileName ( ) const

Getter for the name of the file in which backups will be made.

Every backup will be done with the same file name, but using a different file extension.

Returns
The name of the file in which backups will be made.

◆ getBackupObjectGroups()

bool Scene::getBackupObjectGroups ( ) const

Getter for the option to backup the object groups.

Returns
Whether the object groups will be backed up before the render.

◆ getBackupParameters()

bool Scene::getBackupParameters ( ) const

Getter for the option to backup the parameters.

Returns
Whether the parameters will be backed up before the render.

◆ getBackupPicture()

bool Scene::getBackupPicture ( ) const

Getter for the option to backup the picture.

Returns
Whether the picture will be backed up after the render.
See also
Scene::getLeastRenderTime4PictureBackup()

◆ getCamera()

PerspectiveCamera Scene::getCamera ( ) const

Getter for the camera.

Returns
This scene's camera.

◆ getCameraReference()

PerspectiveCamera & Scene::getCameraReference ( )

Getter for a reference to the camera.

Returns
A reference to this scene's camera.

◆ getKDMaxDepth()

unsigned int Scene::getKDMaxDepth ( ) const

Getter for the maximum depth recursion of the k-d tree.

One of the two recursion stop conditions, along with Scene::getKDMaxObjectNumber(). If one of them is fulfilled, the k-d tree recursive creation stops. See my TM's report for further information on this data structure.

Returns
The maximum number of recursive steps of the k-d tree.
See also
Scene::getKDTree(), Scene::getKDMaxObjectNumber()

◆ getKDMaxObjectNumber()

unsigned int Scene::getKDMaxObjectNumber ( ) const

Getter for the maximum number of objects in a k-d tree leaf.

One of the two recursion stop conditions, along with Scene::getKDMaxDepth(). If one of them is fulfilled, the k-d tree recursive creation stops. See my TM's report for further information on this data structure.

Returns
The maximum number of objects in a k-d tree leaf.
See also
Scene::getKDTree(), Scene::getKDMaxDepth()

◆ getKDTree()

bool Scene::getKDTree ( ) const

Getter for the k-d tree option.

See my TM's report for further information on this data structure.

Returns
Whether a k-d tree will be used during the render.
See also
Scene::getKDMaxObjectNumber(), Scene::getKDMaxDepth()

◆ getLamps()

std::vector< Object3D * > Scene::getLamps ( )

Getter for the lamps.

Calls computeObjectsAndLamps().

Returns
This scene's objects that have an emittance strictly greater than 0.
See also
Scene::getObjects()

◆ getLeastRenderTime4PictureBackup()

double Scene::getLeastRenderTime4PictureBackup ( ) const

Getter for the least render time after which the picture is backed up.

If this value is set to 0.0, the picture will always be backed up after the render.

Returns
The least render time after which the picture is backed up.
See also
Scene::getBackupPicture()

◆ getMinBounces()

unsigned int Scene::getMinBounces ( ) const

Getter for the minimum number of bounces.

Returns
The minimum number of bounces that will be used during the render.
See also
Scene::Scene()

◆ getNextEventEstimation()

bool Scene::getNextEventEstimation ( ) const

Getter for the next event estimation.

See my TM's report for further information on this algorithm.

Returns
Whether the next event estimation algorithm will be used during the render.

◆ getNumberThreads()

unsigned int Scene::getNumberThreads ( ) const

Getter for the number of CPU threads.

Returns
The number of threads that will be used on the CPU during the render.

◆ getObjectGroups()

std::vector< Object3DGroup > Scene::getObjectGroups ( ) const

Getter for the object groups.

Returns
This scene's object groups.

◆ getObjectGroupsReference()

std::vector< Object3DGroup > & Scene::getObjectGroupsReference ( )

Getter for a reference to the object groups.

Returns
A reference to this scene's object groups.

◆ getObjects()

std::vector< Object3D * > Scene::getObjects ( )

Getter for the objects.

Calls computeObjectsAndLamps().

Returns
This scene's objects.
See also
split()

◆ getRrStopProbability()

double Scene::getRrStopProbability ( ) const

Getter for the russian roulette stop probability.

Russian roulette stop probability that will be used during the render.

Returns
The russian roulette stop probability.
See also
Scene::Scene(), Scene::getRussianRoulette()

◆ getRussianRoulette()

bool Scene::getRussianRoulette ( ) const

Getter for the russian roulette.

See my TM's report for further information on this algorithm.

Returns
Whether the russian roulette path termination algorithm will be used during the render.
See also
Scene::getRrStopProbability()

◆ getSamplesPerPixel()

unsigned int Scene::getSamplesPerPixel ( ) const

Getter for the number of samples per pixel.

Returns
The number of samples per pixel that will be used during the render.
See also
Scene::Scene()

◆ importFBXFile()

bool Scene::importFBXFile ( const char *  filePath,
Material material,
std::string  name 
)

Imports a fbx file as triangles.

Uses the FBX SDK library.

Parameters
filePathThe path to the fbx file.
materialThe material that will be used for all the triangles which will be imported.
nameThe name of the object group in which all triangles will be stored.
Returns
True if the importation was successful, false else.
See also
importTrianglesFromFbxNode()

◆ render()

Picture * Scene::render ( )

Start the render of the picture.

This uses the path tracing algorithm (I guess this information was not useful, as it is in the title) and some optimisations such as next event estimation and russian roulette path termination.

Returns
A pointer to the rendered picture.

◆ resetAndDeleteObjectGroups()

void Scene::resetAndDeleteObjectGroups ( )

Deletes all object groups and their objects.

See also
Object3DGroup::resetAndDeleteObjects()

◆ saveObjectGroups2File()

void Scene::saveObjectGroups2File ( std::string  fileName) const

Saves object groups to a file.

Parameters
fileNameThe name of the file to which the object groups will be saved. It is recommended that this file extension ends with OBJECTS_SAVE_EXTENSION.
See also
formatFileName(), OBJECTS_SAVE_EXTENSION

◆ saveParameters2File()

void Scene::saveParameters2File ( std::string  fileName) const

Saves parameters to a file.

Parameters
fileNameThe name of the file to which the prameters will be saved. It is recommended that this file extension ends with PARAMETERS_SAVE_EXTENSION.
See also
formatFileName(), PARAMETERS_SAVE_EXTENSION

◆ setBackupFileName()

void Scene::setBackupFileName ( std::string  backupFileName)

Setter for the new name of the file in which backups will be made.

Every backup will be done with the same file name, but using a different file extension.

Parameters
backupFileNameThe name of the file in which backups will be made.

◆ setBackupObjectGroups()

void Scene::setBackupObjectGroups ( bool  backupObjectGroups)

Setter for the option to backup the object groups.

Parameters
backupObjectGroupsWhether the object groups will be backed up before the render.

◆ setBackupParameters()

void Scene::setBackupParameters ( bool  backupParameters)

Setter for the option to backup the parameters.

Parameters
backupParametersWhether the parameters will be backed up before the render.

◆ setBackupPicture()

void Scene::setBackupPicture ( bool  backupPicture)

Setter for the option to backup the picture.

Parameters
backupPictureWhether the picture will be backed up after the render.
See also
Scene::setLeastRenderTime4PictureBackup()

◆ setCamera()

void Scene::setCamera ( PerspectiveCamera  camera)

Setter for the camera.

Parameters
cameraThe new camera that will be used during the render.

◆ setKDMaxDepth()

void Scene::setKDMaxDepth ( unsigned int  kdMaxDepth)

Setter for the maximum depth recursion of the k-d tree.

One of the two recursion stop conditions, along with Scene::setKDMaxObjectNumber(). If one of them is fulfilled, the k-d tree recursive creation stops. See my TM's report for further information on this data structure.

Parameters
kdMaxDepthThe new maximum number of recursive steps of the k-d tree.
See also
Scene::setKDTree(bool kdTree), Scene::setKDMaxObjectNumber(unsigned int kdMaxObjectNumber)

◆ setKDMaxObjectNumber()

void Scene::setKDMaxObjectNumber ( unsigned int  kdMaxObjectNumber)

Setter for the maximum number of objects in a k-d tree leaf.

One of the two recursion stop conditions, along with Scene::setKDMaxDepth(). If one of them is fulfilled, the k-d tree recursive creation stops. See my TM's report for further information on this data structure.

Parameters
kdMaxObjectNumberThe new maximum number of objects in a k-d tree leaf.
See also
Scene::setKDTree(bool kdTree), Scene::setKDMaxDepth(unsigned int kdMaxDepth)

◆ setKDTree()

void Scene::setKDTree ( bool  kdTree)

Setter for the k-d tree.

See my TM's report for further information on this data structure.

Parameters
kdTreeWhether a k-d tree will be used during the render.
See also
Scene::setKDMaxObjectNumber(unsigned int kdMaxObjectNumber), Scene::setKDMaxDepth(unsigned int kdMaxDepth)

◆ setLeastRenderTime4PictureBackup()

void Scene::setLeastRenderTime4PictureBackup ( double  leastRenderTime4PictureBackup)

Setter for the least render time after which the picture is backed up.

If this value is set to 0.0, the picture will always be backed up after the render.

Parameters
leastRenderTime4PictureBackupThe new least render time after which the picture is backed up.
See also
Scene::setBackupPicture()

◆ setMinBounces()

void Scene::setMinBounces ( unsigned int  minBounces)

Setter for the minimum number of bounces.

Parameters
minBouncesThe new minimum number of bounces that will be used during the render.
See also
Scene::Scene()

◆ setNextEventEstimation()

void Scene::setNextEventEstimation ( bool  nextEventEstimation)

Setter for the next event estimation.

See my TM's report for further information on this algorithm.

Parameters
nextEventEstimationWhether the next event estimation algorithm will be used during the render.

◆ setNumberThreads()

void Scene::setNumberThreads ( unsigned int  numberThreads)

Setter for the number of CPU threads.

Parameters
numberThreadsThe new number of threads that will be used on the CPU during the render.

◆ setObjectGroups()

void Scene::setObjectGroups ( std::vector< Object3DGroup groups)

Setter for the object groups.

Parameters
groupsThe new object groups of this scene.

◆ setRrStopProbability()

void Scene::setRrStopProbability ( double  rrStopProbability)

Setter for the russian roulette stop probability.

See my TM's report for further information on this algorithm.

Parameters
rrStopProbabilityThe new russian roulette stop probability that will be used during the render.
See also
Scene::Scene().

◆ setRussianRoulette() [1/2]

void Scene::setRussianRoulette ( bool  russianRoulette)

Setter for the russian roulette.

See my TM's report for further information on this algorithm.

Parameters
russianRouletteWhether the russian roulette path termination algorithm will be used during the render.

◆ setRussianRoulette() [2/2]

void Scene::setRussianRoulette ( bool  russianRoulette,
double  rrStopProbability 
)

Setter for the russian roulette and russian roulette stop probability.

See my TM's report for further information on this algorithm.

Parameters
russianRouletteWhether the russian roulette path termination algorithm will be used during the render.
rrStopProbabilityThe new russian roulette stop probability that will be used during the render.
See also
Scene::Scene().

◆ setSamplesPerPixel()

void Scene::setSamplesPerPixel ( unsigned int  samplesPerPixel)

Setter for the number of samples per pixel.

Parameters
samplesPerPixelThe new number of samples per pixel that will be used during the render.
See also
Scene::Scene()

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