MobileRT  1.0
A multi platform C++ CPU progressive Ray Tracer.
MobileRT::Triangle Class Referencefinal

#include <Triangle.hpp>

Collaboration diagram for MobileRT::Triangle:
Collaboration graph

Classes

class  Builder
 

Public Member Functions

 Triangle ()=delete
 
 Triangle (const Triangle &triangle)=default
 
 Triangle (Triangle &&triangle) noexcept=default
 
 ~Triangle ()=default
 
Triangleoperator= (const Triangle &triangle)=default
 
Triangleoperator= (Triangle &&triangle) noexcept=default
 
Intersection intersect (Intersection intersection) const
 
AABB getAABB () const
 
bool intersect (const AABB &box) const
 
::glm::vec3 getAC () const
 
::glm::vec3 getAB () const
 
::glm::vec3 getA () const
 
::glm::vec3 getNormalA () const
 
::glm::vec3 getNormalB () const
 
::glm::vec3 getNormalC () const
 
::glm::vec2 getTexCoordA () const
 
::glm::vec2 getTexCoordB () const
 
::glm::vec2 getTexCoordC () const
 
::std::int32_t getMaterialIndex () const
 

Private Member Functions

 Triangle (const Triangle::Builder &builder) noexcept
 
void checkArguments () const
 

Static Private Member Functions

static bool isNearFarInvalid (float near, float far)
 

Private Attributes

::glm::vec3 AC_ {}
 
::glm::vec3 AB_ {}
 
::glm::vec3 pointA_ {}
 
::glm::vec3 normalA_ {}
 
::glm::vec3 normalB_ {}
 
::glm::vec3 normalC_ {}
 
::glm::vec2 texCoordA_ {-1}
 
::glm::vec2 texCoordB_ {-1}
 
::glm::vec2 texCoordC_ {-1}
 
::std::int32_t materialIndex_ {-1}
 

Friends

::std::ostream & operator<< (::std::ostream &os, const Triangle &triangle)
 

Detailed Description

A class which represents a triangle in the scene.

Constructor & Destructor Documentation

◆ Triangle() [1/4]

MobileRT::Triangle::Triangle ( const Triangle::Builder builder)
explicitprivatenoexcept

◆ Triangle() [2/4]

MobileRT::Triangle::Triangle ( )
explicitdelete

◆ Triangle() [3/4]

MobileRT::Triangle::Triangle ( const Triangle triangle)
default

◆ Triangle() [4/4]

MobileRT::Triangle::Triangle ( Triangle &&  triangle)
defaultnoexcept

◆ ~Triangle()

MobileRT::Triangle::~Triangle ( )
default

Member Function Documentation

◆ checkArguments()

void Triangle::checkArguments ( ) const
private

Helper method which checks for invalid fields.

Here is the call graph for this function:

◆ getA()

glm::vec3 Triangle::getA ( ) const

Gets the point A of this triangle.

Returns
The point A.

◆ getAABB()

AABB Triangle::getAABB ( ) const

Calculates the bounding box of the triangle.

Returns
The bounding box of the triangle.

◆ getAB()

glm::vec3 Triangle::getAB ( ) const

Gets the AB vector of this triangle.

Returns
The AB vector.

◆ getAC()

glm::vec3 Triangle::getAC ( ) const

Gets the AC vector of this triangle.

Returns
The AC vector.

◆ getMaterialIndex()

std::int32_t Triangle::getMaterialIndex ( ) const

Gets the material index of this plane.

Returns
The material index.

◆ getNormalA()

glm::vec3 Triangle::getNormalA ( ) const

Gets the normal of vertex A of this triangle.

Returns
The normal A.

◆ getNormalB()

glm::vec3 Triangle::getNormalB ( ) const

Gets the normal of vertex B of this triangle.

Returns
The normal B.

◆ getNormalC()

glm::vec3 Triangle::getNormalC ( ) const

Gets the normal of vertex C of this triangle.

Returns
The normal C.

◆ getTexCoordA()

glm::vec2 Triangle::getTexCoordA ( ) const

Gets the texture coordinate of vertex A of this triangle.

Returns
The texture coordinate A.

◆ getTexCoordB()

glm::vec2 Triangle::getTexCoordB ( ) const

Gets the texture coordinate of vertex B of this triangle.

Returns
The texture coordinate B.

◆ getTexCoordC()

glm::vec2 Triangle::getTexCoordC ( ) const

Gets the texture coordinate of vertex C of this triangle.

Returns
The texture coordinate C.

◆ intersect() [1/2]

Intersection Triangle::intersect ( Intersection  intersection) const

Determines if a ray intersects this triangle or not and calculates the intersection point.

Parameters
intersectionThe previous intersection of the ray in the scene.
Returns
The intersection point.
Here is the call graph for this function:

◆ intersect() [2/2]

bool Triangle::intersect ( const AABB box) const

Checks if a bounding box intersects the triangle or not.

Parameters
boxA bounding box.
Returns
Whether if the bounding box intersects the triangle or not.
Here is the call graph for this function:

◆ isNearFarInvalid()

bool Triangle::isNearFarInvalid ( float  near,
float  far 
)
staticprivate

Checks if near and far are valid.

Parameters
nearThe distance of near.
farThe distance of far.
Returns
Whether they are invalid or not.

◆ operator=() [1/2]

Triangle& MobileRT::Triangle::operator= ( const Triangle triangle)
default

◆ operator=() [2/2]

Triangle& MobileRT::Triangle::operator= ( Triangle &&  triangle)
defaultnoexcept

Friends And Related Function Documentation

◆ operator<<

::std::ostream& operator<< ( ::std::ostream &  os,
const Triangle triangle 
)
friend

Member Data Documentation

◆ AB_

::glm::vec3 MobileRT::Triangle::AB_ {}
private

◆ AC_

::glm::vec3 MobileRT::Triangle::AC_ {}
private

◆ materialIndex_

::std::int32_t MobileRT::Triangle::materialIndex_ {-1}
private

◆ normalA_

::glm::vec3 MobileRT::Triangle::normalA_ {}
private

◆ normalB_

::glm::vec3 MobileRT::Triangle::normalB_ {}
private

◆ normalC_

::glm::vec3 MobileRT::Triangle::normalC_ {}
private

◆ pointA_

::glm::vec3 MobileRT::Triangle::pointA_ {}
private

◆ texCoordA_

::glm::vec2 MobileRT::Triangle::texCoordA_ {-1}
private

◆ texCoordB_

::glm::vec2 MobileRT::Triangle::texCoordB_ {-1}
private

◆ texCoordC_

::glm::vec2 MobileRT::Triangle::texCoordC_ {-1}
private

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