Ray Tracer Common Project
Image rendering program based on the ray tracing technique.
Public Member Functions | List of all members
rt::element Class Reference

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 vectorposition () const
 Position of the element on the surface. More...
 
const vectornormal () const
 Normal of the element on the surface. More...
 
const vectortangent () const
 A tangent of the surface at this position. More...
 
vector binormal () const
 A binormal of the surface at this point. More...
 
const Geometrygeometry () const
 The geometry owner. More...
 
const Materialmaterial () const
 The surface material. More...
 
void setMaterial (Material *m)
 Attach a material to the element. More...
 
const vectorglobalPosition () const
 Global position of the surface element. More...
 
const vectorglobalNormal () const
 Global normal of the surface element. More...
 
const vectorglobalTangent () const
 Global tangent of the surface element. More...
 
vector globalBinormal () const
 Global binormal of the surface element. More...
 
elementoperator= (const element &)
 operator = More...
 

Detailed Description

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...

Constructor & Destructor Documentation

◆ element() [1/2]

rt::element::element ( )

Default constructor.

Make a new null surface element.

◆ element() [2/2]

rt::element::element ( const Geometry g,
const vector position,
const vector normal,
const vector tangent 
)

Contruct a surface element from its attributes.

Parameters
gthe Geometry owner
positionLocation vector of the surface on the geometry
normalNormal vector of the surface at this position
tangentA tangent to the surface at this position

The element is build with material attribute set to null.

Member Function Documentation

◆ binormal()

vector rt::element::binormal ( ) const
inline

A binormal of the surface at this point.

Returns
The cross product between the normal and a tangent.

◆ geometry()

const Geometry* rt::element::geometry ( ) const
inline

The geometry owner.

Returns
A pointer to the Geometry this element belong to. Can be null.

◆ globalBinormal()

vector rt::element::globalBinormal ( ) const
inline

Global binormal of the surface element.

Returns
The cross product between the global normal and a global tangent.

◆ globalNormal()

const vector & rt::element::globalNormal ( ) const

Global normal of the surface element.

Returns
The normal vector of the surface in global space referential.

This vector is computed only the first time this method is called.

◆ globalPosition()

const vector & rt::element::globalPosition ( ) const

Global position of the surface element.

Returns
The location vector in global space referential

This vector is computed only the first time this method is called.

◆ globalTangent()

const vector & rt::element::globalTangent ( ) const

Global tangent of the surface element.

Returns
A tangent vector mapped in global space referential.

This vector is computed only the first time this method is called.

◆ material()

const Material* rt::element::material ( ) const
inline

The surface material.

By default, the material is set to null.

Returns
A pointer to the material attached to this element. Typicaly, it correspond to the material of the surface at this point. Can be null.

◆ normal()

const vector& rt::element::normal ( ) const
inline

Normal of the element on the surface.

Returns
A normal vector in Geometry owner local space

◆ operator=()

element & rt::element::operator= ( const element e)

operator =

Returns
This element after modification.

◆ position()

const vector& rt::element::position ( ) const
inline

Position of the element on the surface.

Returns
A location vector in Geometry owner local space

◆ setMaterial()

void rt::element::setMaterial ( Material m)
inline

Attach a material to the element.

Parameters
mA 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.

◆ tangent()

const vector& rt::element::tangent ( ) const
inline

A tangent of the surface at this position.

Returns
A tangent vector in Geometry owner local space

◆ uv()

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.

Returns
The UV texture coordinate of the surface at this point

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