Phongo Clap RT  1.0
Simple Raytracing Renderer
Renderer.h
Go to the documentation of this file.
1 #ifndef _RENDERER_H_
2 #define _RENDERER_H_
3 
10 
11 #include "Film.h"
12 #include "Camera.h"
13 #include "Scene.h"
14 #include <vector>
15 #include <string>
16 #include <ngl/Vec3.h>
17 
18 //----------------------------------------------------------------------------------------------------------------------
22 //----------------------------------------------------------------------------------------------------------------------
23 class Renderer
24 {
25 public:
26  //--------------------------------------------------------------------------------------------------------------------
28  //--------------------------------------------------------------------------------------------------------------------
29  Renderer();
30  //--------------------------------------------------------------------------------------------------------------------
32  //--------------------------------------------------------------------------------------------------------------------
33  ~Renderer();
34  //--------------------------------------------------------------------------------------------------------------------
40  //--------------------------------------------------------------------------------------------------------------------
41  static inline void loadBar(int x, int n, int r, int w);
42  //--------------------------------------------------------------------------------------------------------------------
50  //--------------------------------------------------------------------------------------------------------------------
51  void bind(Scene *_scence, Film *_film, Camera *_camera, int _max_depth, int _anti_aliasing, std::string _image_name);
52  //--------------------------------------------------------------------------------------------------------------------
54  //--------------------------------------------------------------------------------------------------------------------
55  void render();
56  //--------------------------------------------------------------------------------------------------------------------
60  //--------------------------------------------------------------------------------------------------------------------
61  int getIndexClosest(std::vector<double> _intersections);
62  //--------------------------------------------------------------------------------------------------------------------
70  //--------------------------------------------------------------------------------------------------------------------
71  bool raycast(ngl::Vec3 _from, int _avoid);
72  //--------------------------------------------------------------------------------------------------------------------
82  //--------------------------------------------------------------------------------------------------------------------
83  ngl::Colour trace(ngl::Vec3 _from, ngl::Vec3 _direction, int _depth);
84 
85 private:
86  //--------------------------------------------------------------------------------------------------------------------
88  //--------------------------------------------------------------------------------------------------------------------
89  std::string m_image_name;
90  //--------------------------------------------------------------------------------------------------------------------
92  //--------------------------------------------------------------------------------------------------------------------
94  //--------------------------------------------------------------------------------------------------------------------
96  //--------------------------------------------------------------------------------------------------------------------
98  //--------------------------------------------------------------------------------------------------------------------
100  //--------------------------------------------------------------------------------------------------------------------
102  //--------------------------------------------------------------------------------------------------------------------
104  //--------------------------------------------------------------------------------------------------------------------
105  ngl::Vec3 m_bg_colour;
106  //--------------------------------------------------------------------------------------------------------------------
108  //--------------------------------------------------------------------------------------------------------------------
109  int m_width;
110  //--------------------------------------------------------------------------------------------------------------------
112  //--------------------------------------------------------------------------------------------------------------------
113  int m_height;
114  //--------------------------------------------------------------------------------------------------------------------
116  //--------------------------------------------------------------------------------------------------------------------
118  //--------------------------------------------------------------------------------------------------------------------
120  //--------------------------------------------------------------------------------------------------------------------
122 };
123 
124 #endif // Renderer.h
void render()
Will trigger the class and start doing all the calculations.
Definition: Renderer.cpp:322
Camera * m_camera
Associated camera.
Definition: Renderer.h:101
Film * m_film
Associated film.
Definition: Renderer.h:93
int m_anti_aliasing
Antialiasing amount.
Definition: Renderer.h:117
Core of my program, central unit that manages all the other classes almost.
Definition: Renderer.h:23
Implements camera functionability, no transformations, just explicit definition.
All the operations regarding to file output and file input belong to this class. It abstracts the ide...
int m_height
Height of the image.
Definition: Renderer.h:113
This hold all the objects and lights that the parser interpred and later pushed into the scene...
~Renderer()
Destructor, frees any possible memory from the heap.
Definition: Renderer.cpp:47
Renderer()
Constructor for the renderer class.
Definition: Renderer.cpp:45
static void loadBar(int x, int n, int r, int w)
Implements a loading bar. This algorithm is taken from another person.
Definition: Renderer.cpp:21
int m_width
Width of the image.
Definition: Renderer.h:109
int m_max_depth
Maximum number of ray stack frames.
Definition: Renderer.h:121
ngl::Vec3 m_bg_colour
default background colour.
Definition: Renderer.h:105
Scene * m_scene
Associated scene.
Definition: Renderer.h:97
int getIndexClosest(std::vector< double > _intersections)
Given an intersections vector will return the closest to the camera, the one that it will read colour...
Definition: Renderer.cpp:72
void bind(Scene *_scence, Film *_film, Camera *_camera, int _max_depth, int _anti_aliasing, std::string _image_name)
Grabs all the information and places it into the private interface.
Definition: Renderer.cpp:59
std::string m_image_name
Name of the filename that will be written.
Definition: Renderer.h:89
ngl::Colour trace(ngl::Vec3 _from, ngl::Vec3 _direction, int _depth)
Probably the most important algorithm of this class. This method is recursive. It will fire a ray fro...
Definition: Renderer.cpp:142
bool raycast(ngl::Vec3 _from, int _avoid)
Will fire rays from a position, then iterate over the lights, and if any object is inbetweet will ret...
Definition: Renderer.cpp:107
Holds all the operations regarding to input/output of colour information.
Definition: Film.h:29
Hold all the objects and lights of the scene.
Definition: Scene.h:20
Holds camera functions which will be accessed by the Render class.
Definition: Camera.h:17