Phongo Clap RT  1.0
Simple Raytracing Renderer
Public Member Functions | Public Attributes | List of all members
Material Class Reference

#include <Material.h>

Collaboration diagram for Material:
Collaboration graph

Public Member Functions

 Material ()
 Material constructor. More...
 
 Material (ngl::Colour _c)
 Material constructor passing a colour, this will not be a checker material. More...
 
 Material (ngl::Colour _c1, ngl::Colour _c2)
 Material constructor passing two colours will enable the checker shading. More...
 
bool isReflective ()
 Returns whether the material is reflective or not. More...
 
bool isRefractive ()
 Returns whether the material is reflective or not. More...
 
void setHardness (float _highlight_size)
 Sets the specular modulator for the specular contribution in the Phong shader. More...
 
void setReflection (float _refl_intensity, float _diffuse_intensity)
 Sets the reflection parameters. More...
 
void setRefraction (float _ior, float _transparency, float _diffuse_intensity)
 Sets the refraction settings. More...
 
float getReflIntensity ()
 Returns amount of reflection. More...
 
float getIOR ()
 Returns index of refraction. More...
 
float getTransparency ()
 Returns transparency. More...
 
float getDiffuseIntensity ()
 Returns amount of diffuse contribution. More...
 
ngl::Colour objColour ()
 Returns the object colour. More...
 
ngl::Colour objColour (ngl::Vec3 &_isect)
 However I implemented this overloaded function that grabs an intersection, this is used for the checker materials, normally used on planes. Don't set up a checker on a Sphere. More...
 

Public Attributes

bool m_isReflective = false
 Tells whether the object is reflective. More...
 
bool m_isRefractive = false
 Specifies whether object is transparent. More...
 
float m_diffuse_intensity
 Diffuse intensity, self-explanatory. More...
 
float m_refl_intensity
 Amount of reflection. More...
 
float m_ior
 Index of refraction. More...
 
float m_transparency
 Amount of refraction, in other words 'transparency'. More...
 
float m_spec_hardness = 40
 This will drive the spreadness of the specular highlights. More...
 
ngl::Colour m_colour1
 Colour of the object. More...
 
ngl::Colour m_colour2
 For checker materials we will have colour1 and colour2, for plain ones just colour1. More...
 
bool m_isChecker
 Specifies whether it is checker or not. More...
 

Detailed Description

Definition at line 12 of file Material.h.

Constructor & Destructor Documentation

Material::Material ( )

Material constructor.

Definition at line 7 of file Material.cpp.

7 {}
Material::Material ( ngl::Colour  _c)

Material constructor passing a colour, this will not be a checker material.

Parameters
[in]Colourof the object.

Definition at line 9 of file Material.cpp.

References m_colour1, and m_isChecker.

10 {
11  m_colour1 = _c;
12  m_isChecker = false;
13 }
ngl::Colour m_colour1
Colour of the object.
Definition: Material.h:121
bool m_isChecker
Specifies whether it is checker or not.
Definition: Material.h:129
Material::Material ( ngl::Colour  _c1,
ngl::Colour  _c2 
)

Material constructor passing two colours will enable the checker shading.

Parameters
[in]_cColours to be applied to checkerboard.

Definition at line 15 of file Material.cpp.

References m_colour1, m_colour2, and m_isChecker.

16 {
17  m_colour1 = _c1;
18  m_colour2 = _c2;
19  m_isChecker = true;
20 }
ngl::Colour m_colour1
Colour of the object.
Definition: Material.h:121
ngl::Colour m_colour2
For checker materials we will have colour1 and colour2, for plain ones just colour1.
Definition: Material.h:125
bool m_isChecker
Specifies whether it is checker or not.
Definition: Material.h:129

Member Function Documentation

float Material::getDiffuseIntensity ( )

Returns amount of diffuse contribution.

Returns
Amount of diffuse.

Definition at line 67 of file Material.cpp.

References m_diffuse_intensity.

68 {
69  return m_diffuse_intensity;
70 }
float m_diffuse_intensity
Diffuse intensity, self-explanatory.
Definition: Material.h:100
float Material::getIOR ( )

Returns index of refraction.

Returns
Index of refraction.

Definition at line 57 of file Material.cpp.

References m_ior.

58 {
59  return m_ior;
60 }
float m_ior
Index of refraction.
Definition: Material.h:108
float Material::getReflIntensity ( )

Returns amount of reflection.

Returns
Amout of reflection.

Definition at line 52 of file Material.cpp.

References m_refl_intensity.

53 {
54  return m_refl_intensity;
55 }
float m_refl_intensity
Amount of reflection.
Definition: Material.h:104
float Material::getTransparency ( )

Returns transparency.

Returns
Transparency.

Definition at line 62 of file Material.cpp.

References m_transparency.

63 {
64  return m_transparency;
65 }
float m_transparency
Amount of refraction, in other words 'transparency'.
Definition: Material.h:112
bool Material::isReflective ( )

Returns whether the material is reflective or not.

Definition at line 22 of file Material.cpp.

References m_isReflective.

23 {
24  return m_isReflective;
25 }
bool m_isReflective
Tells whether the object is reflective.
Definition: Material.h:92
bool Material::isRefractive ( )

Returns whether the material is reflective or not.

Definition at line 27 of file Material.cpp.

References m_isRefractive.

28 {
29  return m_isRefractive;
30 }
bool m_isRefractive
Specifies whether object is transparent.
Definition: Material.h:96
ngl::Colour Material::objColour ( )

Returns the object colour.

Returns
Colour of the object.

Definition at line 72 of file Material.cpp.

References m_colour1.

73 {
74  return m_colour1;
75 }
ngl::Colour m_colour1
Colour of the object.
Definition: Material.h:121

Here is the caller graph for this function:

ngl::Colour Material::objColour ( ngl::Vec3 &  _isect)

However I implemented this overloaded function that grabs an intersection, this is used for the checker materials, normally used on planes. Don't set up a checker on a Sphere.

Parameters
[in]_isectThe world position of an intersection.

Definition at line 77 of file Material.cpp.

References m_colour1, m_colour2, and m_isChecker.

78 {
79  /* This will floor the z and x position of a plane and for each integer value modulus operation will be performed
80  * after that, depending on whether the remainder is 0 or 1 we apply one colour or another.*/
81 
82  if(m_isChecker)
83  {
84  int index_x = (int)(floor(_isect.m_x)) % 2;
85  int index_z = (int)(floor(_isect.m_z)) % 2;
86 
87  if (((bool)index_x && (bool)index_z) || ((bool)index_x == 0 && (bool)index_z == 0))
88  {
89  return m_colour1;
90  }
91  else
92  {
93  return m_colour2;
94  }
95  }
96  else
97  {
98  return m_colour1;
99  }
100 }
ngl::Colour m_colour1
Colour of the object.
Definition: Material.h:121
ngl::Colour m_colour2
For checker materials we will have colour1 and colour2, for plain ones just colour1.
Definition: Material.h:125
bool m_isChecker
Specifies whether it is checker or not.
Definition: Material.h:129
void Material::setHardness ( float  _highlight_size)

Sets the specular modulator for the specular contribution in the Phong shader.

Definition at line 32 of file Material.cpp.

References m_spec_hardness.

33 {
34  m_spec_hardness = _highlight_size;
35 }
float m_spec_hardness
This will drive the spreadness of the specular highlights.
Definition: Material.h:116
void Material::setReflection ( float  _refl_intensity,
float  _diffuse_intensity 
)

Sets the reflection parameters.

Parameters
[in]_refl_intensity(percentage, from 0 to 100) Reflectiveness of the object.
[in]_diffuse_intensity(percentage, from 0 to 100) This value equals to 100 - _refl_intensity.

Definition at line 37 of file Material.cpp.

References m_diffuse_intensity, m_isReflective, and m_refl_intensity.

38 {
39  m_isReflective = true;
40  m_refl_intensity = _refl_intensity;
41  m_diffuse_intensity = _diffuse_intensity;
42 }
float m_refl_intensity
Amount of reflection.
Definition: Material.h:104
bool m_isReflective
Tells whether the object is reflective.
Definition: Material.h:92
float m_diffuse_intensity
Diffuse intensity, self-explanatory.
Definition: Material.h:100

Here is the caller graph for this function:

void Material::setRefraction ( float  _ior,
float  _transparency,
float  _diffuse_intensity 
)

Sets the refraction settings.

Parameters
[in]_iorInex of refraction. You can look them up in a table or in the internet.
[in]_transparency(percentage, from 0 to 100) How refractive the material is.
[in]_diffuse_intensity(percentage, from 0 to 100) This value equals to 100 - _transparency.

Definition at line 44 of file Material.cpp.

References m_diffuse_intensity, m_ior, m_isRefractive, and m_transparency.

45 {
46  m_isRefractive = true;
47  m_ior = _ior;
48  m_transparency = _transparency;
49  m_diffuse_intensity = _diffuse_intensity;
50 }
bool m_isRefractive
Specifies whether object is transparent.
Definition: Material.h:96
float m_ior
Index of refraction.
Definition: Material.h:108
float m_transparency
Amount of refraction, in other words 'transparency'.
Definition: Material.h:112
float m_diffuse_intensity
Diffuse intensity, self-explanatory.
Definition: Material.h:100

Here is the caller graph for this function:

Member Data Documentation

ngl::Colour Material::m_colour1

Colour of the object.

Definition at line 121 of file Material.h.

ngl::Colour Material::m_colour2

For checker materials we will have colour1 and colour2, for plain ones just colour1.

Definition at line 125 of file Material.h.

float Material::m_diffuse_intensity

Diffuse intensity, self-explanatory.

Definition at line 100 of file Material.h.

float Material::m_ior

Index of refraction.

Definition at line 108 of file Material.h.

bool Material::m_isChecker

Specifies whether it is checker or not.

Definition at line 129 of file Material.h.

bool Material::m_isReflective = false

Tells whether the object is reflective.

Definition at line 92 of file Material.h.

bool Material::m_isRefractive = false

Specifies whether object is transparent.

Definition at line 96 of file Material.h.

float Material::m_refl_intensity

Amount of reflection.

Definition at line 104 of file Material.h.

float Material::m_spec_hardness = 40

This will drive the spreadness of the specular highlights.

Definition at line 116 of file Material.h.

float Material::m_transparency

Amount of refraction, in other words 'transparency'.

Definition at line 112 of file Material.h.


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