|
Ray Tracer Common Project
Image rendering program based on the ray tracing technique.
|
Geometric surface element unit. More...
#include <element.hpp>
Public Member Functions | |
| element () | |
| Default constructor. More... | |
| element (const Geometry *g, const vector &position, const vector &normal, const vector &tangent) | |
| Contruct a surface element from its attributes. More... | |
| element (const element &) | |
| Copy constructor. | |
| ~element () | |
| Destructor. | |
| vector | uv () const |
| Get uv mapping of the element. More... | |
| const vector & | position () const |
| Position of the element on the surface. More... | |
| const vector & | normal () const |
| Normal of the element on the surface. More... | |
| const vector & | tangent () const |
| A tangent of the surface at this position. More... | |
| vector | binormal () const |
| A binormal of the surface at this point. More... | |
| const Geometry * | geometry () const |
| The geometry owner. More... | |
| const Material * | material () const |
| The surface material. More... | |
| void | setMaterial (Material *m) |
| Attach a material to the element. More... | |
| const vector & | globalPosition () const |
| Global position of the surface element. More... | |
| const vector & | globalNormal () const |
| Global normal of the surface element. More... | |
| const vector & | globalTangent () const |
| Global tangent of the surface element. More... | |
| vector | globalBinormal () const |
| Global binormal of the surface element. More... | |
| element & | operator= (const element &) |
| operator = More... | |
Geometric surface element unit.
This class represents a unit of surface of a geometric element. It is described by its Geometry owner, the unit position, normal and tangent in the local geometry space.
Global position, normal and tangent can be retreived, but with some inexorable time consumtion. For this reason, global attributes will be computed only when its needed, and only one time.
A surface element can be attached to a Material. By default, the material is set to null.
There is some work to do around this class to avoid useless calculations of global components. Maybe construct an element directly from its global coordinates ? But local coordinantes will be needed to compute texture mapping...
| rt::element::element | ( | ) |
Default constructor.
Make a new null surface element.
| rt::element::element | ( | const Geometry * | g, |
| const vector & | position, | ||
| const vector & | normal, | ||
| const vector & | tangent | ||
| ) |
Contruct a surface element from its attributes.
| g | the Geometry owner |
| position | Location vector of the surface on the geometry |
| normal | Normal vector of the surface at this position |
| tangent | A tangent to the surface at this position |
The element is build with material attribute set to null.
|
inline |
A binormal of the surface at this point.
|
inline |
The geometry owner.
|
inline |
Global binormal of the surface element.
| const vector & rt::element::globalNormal | ( | ) | const |
Global normal of the surface element.
This vector is computed only the first time this method is called.
| const vector & rt::element::globalPosition | ( | ) | const |
Global position of the surface element.
This vector is computed only the first time this method is called.
| const vector & rt::element::globalTangent | ( | ) | const |
Global tangent of the surface element.
This vector is computed only the first time this method is called.
|
inline |
The surface material.
By default, the material is set to null.
|
inline |
Normal of the element on the surface.
operator =
|
inline |
Position of the element on the surface.
|
inline |
Attach a material to the element.
| m | A pointer to the material to attach to. |
Conventionally, and for the ray-tracer purpose, this material matchs the surface material at this location. This method is used by Object::hit in this very way.
|
inline |
A tangent of the surface at this position.
| vector rt::element::uv | ( | ) | const |
Get uv mapping of the element.
This function directly call Geometry::uv. Make sure that this is not a null surface element in order to call this function to avoid segmentation fault.
1.8.15