Phongo Clap RT
1.0
Simple Raytracing Renderer
|
Class that hold an implicit definition of a sphere through center and radius parameters. It also implements a method for finding intersections. More...
#include <Sphere.h>
Public Member Functions | |
Sphere () | |
Sphere constructor, by default it will instanciate a 1 unit radius sphere in the origin (0,0,0) . More... | |
Sphere (ngl::Vec3 _center, float _radius, ngl::Colour _colour) | |
Sphere ctor using a radius and a center. More... | |
~Sphere () | |
Destructor so that all memory is freed. More... | |
void | setRadius (float _radius) |
Setter for the radius. More... | |
void | setCenter (ngl::Vec3 _center) |
Setter for the center. More... | |
float | getRadius () const |
Returns radius of a sphere. More... | |
ngl::Vec3 | getCenter () const |
Returns center of a sphere. More... | |
virtual float | getIntersection (geo::Ray &_ray) |
Calculates the intersection of the passed ray with the sphere according to the parametric form of a ray: R(t) = P + t * (Q - P) More... | |
virtual ngl::Vec3 | getNormalAt (ngl::Vec3 _p) |
Calculates what the normal is at a given point of a sphere. It doesn't check whether it is on the surface or not because that point will be passed through an intersection which we are sure about. More... | |
virtual ngl::Colour | getColour () |
Gets colour of the sphere through its material object. More... | |
virtual ngl::Colour | getColour (ngl::Vec3 &_isect) |
Gets colour of the sphere through its material object. More... | |
![]() | |
Shape () | |
Default constructor. More... | |
~Shape () | |
Frees any memory grabbed from the heap. More... | |
void | hasRefraction (float _ior, float _transparency, float _diffuse_intensity) |
Sets parameters related to refraction, this will be given to the Material class. More... | |
void | hasReflection (float _refl_intensity, float _diffuse_intensity) |
Sets reflection attributes. More... | |
Material * | getMaterial () |
Returns the material attached to a shape object. This is useful for querying or changing private interface, that's why it is not const. More... | |
char | getType () |
Derived classes will be Spheres or Planes, I will store the type of geometry in this attribute. More... | |
Private Attributes | |
ngl::Vec3 | m_center |
Center of the sphere, in world space coordinates. More... | |
double | m_radius |
Radius of the sphere. More... | |
Additional Inherited Members | |
![]() | |
char | m_type |
Type of geometric object it is. More... | |
ngl::Colour | m_colour |
Colour of the shape. More... | |
Material * | m_material |
Material attached to the Shape object. More... | |
Class that hold an implicit definition of a sphere through center and radius parameters. It also implements a method for finding intersections.
|
inline |
Sphere constructor, by default it will instanciate a 1
unit radius sphere in the origin (0,0,0)
.
Definition at line 29 of file Sphere.h.
References geo::Shape::m_colour, geo::Shape::m_material, and geo::Shape::m_type.
|
inline |
Sphere ctor using a radius and a center.
[in] | _center | The position in where the sphere is positioned. |
[in] | _radius | The radius in scene units of the sphere object. |
[in] | _colour | The colour of the Sphere |
Definition at line 42 of file Sphere.h.
References geo::Shape::m_colour, geo::Shape::m_material, and geo::Shape::m_type.
|
inline |
|
inline |
Returns center of a sphere.
Definition at line 76 of file Sphere.h.
References m_center.
|
inlinevirtual |
Gets colour of the sphere through its material object.
[in] | _p | The position in the surface of the spehere where we calculate the normal. |
Implements geo::Shape.
Definition at line 98 of file Sphere.h.
References Material::m_colour1, and geo::Shape::m_material.
|
inlinevirtual |
Gets colour of the sphere through its material object.
[in] | _p | The position in the surface of the spehere where we calculate the normal. |
Implements geo::Shape.
Definition at line 104 of file Sphere.h.
References Material::m_colour1, and geo::Shape::m_material.
|
virtual |
Calculates the intersection of the passed ray with the sphere according to the parametric form of a ray: R(t) = P + t * (Q - P)
[in] | _ray |
Implements geo::Shape.
Definition at line 12 of file Sphere.cpp.
References getCenter(), geo::Ray::getDirection(), geo::Ray::getOrigin(), and getRadius().
|
virtual |
Calculates what the normal is at a given point of a sphere. It doesn't check whether it is on the surface or not because that point will be passed through an intersection which we are sure about.
[in] | _p | The position in the surface of the spehere where we calculate the normal. |
Implements geo::Shape.
Definition at line 61 of file Sphere.cpp.
References m_center.
|
inline |
|
inline |
Setter for the center.
[in] | _center | Center of the sphere. |
Definition at line 64 of file Sphere.h.
References m_center.
|
inline |
|
private |