INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
rt::Scene Struct Reference

#include <Scene.h>

Public Member Functions

 Scene ()
 Default constructor. Nothing to do.
 
 ~Scene ()
 Destructor. Frees objects.
 
void init (Viewer &viewer)
 This function calls the init method of each of its objects.
 
void draw (Viewer &viewer)
 This function calls the draw method of each of its objects.
 
void light (Viewer &viewer)
 This function calls the light method of each of its lights.
 
void addObject (GraphicalObject *anObject)
 Adds a new object to the scene.
 
void addLight (Light *aLight)
 Adds a new light to the scene.
 
Real rayIntersection (const Ray &ray, GraphicalObject *&object, Point3 &p)
 

Public Attributes

std::vector< Light * > myLights
 The list of lights modelled as a vector.
 
std::vector< GraphicalObject * > myObjects
 The list of objects modelled as a vector.
 

Detailed Description

Models a scene, i.e. a collection of lights and graphical objects (could be a tree, but we keep a list for now for the sake of simplicity).

Note
Once the scene receives a new object, it owns the object and is thus responsible for its deallocation.

Definition at line 26 of file Scene.h.

Constructor & Destructor Documentation

◆ Scene()

rt::Scene::Scene ( )
inline

Default constructor. Nothing to do.

Definition at line 33 of file Scene.h.

33{}

◆ ~Scene()

rt::Scene::~Scene ( )
inline

Destructor. Frees objects.

Definition at line 36 of file Scene.h.

37 {
38 for ( Light* light : myLights )
39 delete light;
40 for ( GraphicalObject* obj : myObjects )
41 delete obj;
42 // The vector is automatically deleted.
43 }
std::vector< GraphicalObject * > myObjects
The list of objects modelled as a vector.
Definition Scene.h:30
std::vector< Light * > myLights
The list of lights modelled as a vector.
Definition Scene.h:28
void light(Viewer &viewer)
This function calls the light method of each of its lights.
Definition Scene.h:62

Member Function Documentation

◆ addLight()

void rt::Scene::addLight ( Light aLight)
inline

Adds a new light to the scene.

Definition at line 75 of file Scene.h.

76 {
77 myLights.push_back( aLight );
78 }

◆ addObject()

void rt::Scene::addObject ( GraphicalObject anObject)
inline

Adds a new object to the scene.

Definition at line 69 of file Scene.h.

70 {
71 myObjects.push_back( anObject );
72 }

◆ draw()

void rt::Scene::draw ( Viewer viewer)
inline

This function calls the draw method of each of its objects.

Definition at line 54 of file Scene.h.

55 {
56 for ( GraphicalObject* obj : myObjects )
57 obj->draw( viewer );
58 for ( Light* light : myLights )
59 light->draw( viewer );
60 }
void draw(Viewer &viewer)
This function calls the draw method of each of its objects.
Definition Scene.h:54

◆ init()

void rt::Scene::init ( Viewer viewer)
inline

This function calls the init method of each of its objects.

Definition at line 46 of file Scene.h.

47 {
48 for ( GraphicalObject* obj : myObjects )
49 obj->init( viewer );
50 for ( Light* light : myLights )
51 light->init( viewer );
52 }
void init(Viewer &viewer)
This function calls the init method of each of its objects.
Definition Scene.h:46

◆ light()

void rt::Scene::light ( Viewer viewer)
inline

This function calls the light method of each of its lights.

Definition at line 62 of file Scene.h.

63 {
64 for ( Light* light : myLights )
65 light->light( viewer );
66 }

◆ rayIntersection()

Real rt::Scene::rayIntersection ( const Ray ray,
GraphicalObject *&  object,
Point3 p 
)
inline
Parameters
[in]raythe ray that is traveling in the scene
[out]objecteither a null pointer (0) if no object is intersected by the ray or a pointer to the closest object intersected by the given ray.
[out]pif object is not null, then it is the point of intersection between the ray and this object.
Returns
a non-positive value if there was an intersection, positive otherwise (e.g. could be like the distance to the closest object to the ray).

Definition at line 93 of file Scene.h.

96 {
97 object = 0;
98 return 1.0f;
99 }

Member Data Documentation

◆ myLights

std::vector< Light* > rt::Scene::myLights

The list of lights modelled as a vector.

Definition at line 28 of file Scene.h.

◆ myObjects

std::vector< GraphicalObject* > rt::Scene::myObjects

The list of objects modelled as a vector.

Definition at line 30 of file Scene.h.


The documentation for this struct was generated from the following file: