Phongo Clap RT  1.0
Simple Raytracing Renderer
Shape.h
Go to the documentation of this file.
1 #ifndef _SHAPE_H_
2 #define _SHAPE_H_
3 
7 
8 #include <ngl/Vec3.h>
9 #include <ngl/Colour.h>
10 #include "Material.h"
11 #include "Ray.h"
12 
13 
14 namespace geo {
15 //----------------------------------------------------------------------------------------------------------------------
20 //----------------------------------------------------------------------------------------------------------------------
21 class Shape
22 {
23 public:
24  //--------------------------------------------------------------------------------------------------------------------
26  //--------------------------------------------------------------------------------------------------------------------
27  Shape() {}
28  //--------------------------------------------------------------------------------------------------------------------
30  //--------------------------------------------------------------------------------------------------------------------
31  ~Shape() {delete m_material;}
32  //--------------------------------------------------------------------------------------------------------------------
35  //--------------------------------------------------------------------------------------------------------------------
36  virtual ngl::Colour getColour() = 0;
37  //--------------------------------------------------------------------------------------------------------------------
40  //--------------------------------------------------------------------------------------------------------------------
41  virtual ngl::Colour getColour(ngl::Vec3 &_isect) = 0;
42  //--------------------------------------------------------------------------------------------------------------------
45  //--------------------------------------------------------------------------------------------------------------------
46  virtual float getIntersection(geo::Ray& _ray) = 0;
47  //--------------------------------------------------------------------------------------------------------------------
50  //--------------------------------------------------------------------------------------------------------------------
51  virtual ngl::Vec3 getNormalAt(ngl::Vec3 _p) = 0;
52  //--------------------------------------------------------------------------------------------------------------------
58  //--------------------------------------------------------------------------------------------------------------------
59  void hasRefraction(float _ior, float _transparency, float _diffuse_intensity)
60  {
61  m_material->setRefraction(_ior,_transparency, _diffuse_intensity);
62  }
63  //--------------------------------------------------------------------------------------------------------------------
67  //--------------------------------------------------------------------------------------------------------------------
68  void hasReflection(float _refl_intensity, float _diffuse_intensity)
69  {
70  m_material->setReflection(_refl_intensity, _diffuse_intensity);
71  }
72  //--------------------------------------------------------------------------------------------------------------------
76  //--------------------------------------------------------------------------------------------------------------------
78  //--------------------------------------------------------------------------------------------------------------------
81  //--------------------------------------------------------------------------------------------------------------------
82  char getType() {return m_type;}
83 
84 protected:
85  //--------------------------------------------------------------------------------------------------------------------
87  //--------------------------------------------------------------------------------------------------------------------
88  char m_type;
89  //--------------------------------------------------------------------------------------------------------------------
91  //--------------------------------------------------------------------------------------------------------------------
92  ngl::Colour m_colour;
93  //--------------------------------------------------------------------------------------------------------------------
95  //--------------------------------------------------------------------------------------------------------------------
97 };
98 }
99 
100 #endif
Material * m_material
Material attached to the Shape object.
Definition: Shape.h:96
This will be used to return the colour when queried from the Shape derived classes.
virtual ngl::Colour getColour()=0
Returs colour of a Shape object.
virtual ngl::Vec3 getNormalAt(ngl::Vec3 _p)=0
Returns the normal at a given point.
Shape()
Default constructor.
Definition: Shape.h:27
Definition: Ray.h:17
ngl::Colour m_colour
Colour of the shape.
Definition: Shape.h:92
~Shape()
Frees any memory grabbed from the heap.
Definition: Shape.h:31
virtual float getIntersection(geo::Ray &_ray)=0
Passing a ray it will calculate the intersection in the derived class, this is purely abstract method...
void hasRefraction(float _ior, float _transparency, float _diffuse_intensity)
Sets parameters related to refraction, this will be given to the Material class.
Definition: Shape.h:59
void hasReflection(float _refl_intensity, float _diffuse_intensity)
Sets reflection attributes.
Definition: Shape.h:68
void setReflection(float _refl_intensity, float _diffuse_intensity)
Sets the reflection parameters.
Definition: Material.cpp:37
Semi abstract class with virtual methods that holds all the calls for getting intersections, getting normals, also for specifying the properties of the material that will be hold by the Material member of this class.
Definition: Shape.h:21
void setRefraction(float _ior, float _transparency, float _diffuse_intensity)
Sets the refraction settings.
Definition: Material.cpp:44
char m_type
Type of geometric object it is.
Definition: Shape.h:88
This class handles the implementation of ray: an object with an origin and a direction.
Definition: Plane.cpp:9
char getType()
Derived classes will be Spheres or Planes, I will store the type of geometry in this attribute...
Definition: Shape.h:82
Material * getMaterial()
Returns the material attached to a shape object. This is useful for querying or changing private inte...
Definition: Shape.h:77