#include <CTriangle.h>
Public Member Functions | |
cTriangle (cMesh *a_parent, const unsigned int a_indexVertex0, const unsigned int a_indexVertex1, const unsigned int a_indexVertex2) | |
cTriangle () | |
~cTriangle () | |
void | setVertices (const unsigned int a_indexVertex0, const unsigned int a_indexVertex1, const unsigned int a_indexVertex2) |
cVertex * | getVertex0 () const |
cVertex * | getVertex1 () const |
cVertex * | getVertex2 () const |
cVertex * | getVertex (int vi) const |
unsigned int | getVertexIndex (int vi) const |
unsigned int | getIndexVertex0 () const |
unsigned int | getIndexVertex1 () const |
unsigned int | getIndexVertex2 () const |
unsigned int | getIndex () const |
cMesh * | getParent () const |
void | setParent (cMesh *parent) |
bool | allocated () const |
bool | computeCollision (const cVector3d &a_rayOrigin, const cVector3d &a_rayDir, cGenericObject *&a_colObject, cTriangle *&a_colTriangle, cVector3d &a_colPoint, double &a_colSquareDistance) const |
double | compute_area () |
Public Attributes | |
int | m_tag |
For custom use. No specific purpose. | |
std::vector< cTriangle * > * | m_neighbors |
A mesh can be organized into a network of neighboring triangles, which are stored here... | |
unsigned int | m_indexVertex0 |
Index number of vertex 0 (defines a location in my owning mesh's vertex array). | |
unsigned int | m_indexVertex1 |
Index number of vertex 1 (defines a location in my owning mesh's vertex array). | |
unsigned int | m_indexVertex2 |
Index number of vertex 2 (defines a location in my owning mesh's vertex array). | |
unsigned int | m_index |
Index number of this triangle (defines a location in my owning mesh's triangle array). | |
cMesh * | m_parent |
The mesh that owns me. | |
bool | m_allocated |
Is this triangle still active? |
cTriangle::cTriangle | ( | cMesh * | a_parent, | |
const unsigned int | a_indexVertex0, | |||
const unsigned int | a_indexVertex1, | |||
const unsigned int | a_indexVertex2 | |||
) | [inline] |
Constructor of cTriangle.
a_parent | Parent mesh. | |
a_indexVertex0 | index position of vertex 0. | |
a_indexVertex1 | index position of vertex 1. | |
a_indexVertex2 | index position of vertex 2. |
cTriangle::cTriangle | ( | ) | [inline] |
Default constructor of cTriangle.
cTriangle::~cTriangle | ( | ) | [inline] |
Destructor of cTriangle.
void cTriangle::setVertices | ( | const unsigned int | a_indexVertex0, | |
const unsigned int | a_indexVertex1, | |||
const unsigned int | a_indexVertex2 | |||
) | [inline] |
Set the vertices of the triangle by passing the index numbers of the corresponding vertices.
a_indexVertex0 | index position of vertex 0. | |
a_indexVertex1 | index position of vertex 1. | |
a_indexVertex2 | index position of vertex 2. |
cVertex* cTriangle::getVertex0 | ( | ) | const [inline] |
Read pointer to vertex 0 of triangle
cVertex* cTriangle::getVertex1 | ( | ) | const [inline] |
Read pointer to vertex 1 of triangle
cVertex* cTriangle::getVertex2 | ( | ) | const [inline] |
Read pointer to vertex 2 of triangle
cVertex* cTriangle::getVertex | ( | int | vi | ) | const [inline] |
Access a pointer to the specified vertex of this triangle
vi | The triangle (0, 1, or 2) to access |
unsigned int cTriangle::getVertexIndex | ( | int | vi | ) | const [inline] |
Access the index of the specified vertex of this triangle
vi | The triangle (0, 1, or 2) to access |
unsigned int cTriangle::getIndexVertex0 | ( | ) | const [inline] |
Read index number of vertex 0 (defines a location in my owning mesh's vertex array)
unsigned int cTriangle::getIndexVertex1 | ( | ) | const [inline] |
Read index number of vertex 1 (defines a location in my owning mesh's vertex array)
unsigned int cTriangle::getIndexVertex2 | ( | ) | const [inline] |
Read index number of vertex 2 (defines a location in my owning mesh's vertex array)
unsigned int cTriangle::getIndex | ( | ) | const [inline] |
Read the index of this triangle (defines a location in my owning mesh's triangle array)
cMesh* cTriangle::getParent | ( | ) | const [inline] |
Retrieve a pointer to the mesh that owns this triangle
void cTriangle::setParent | ( | cMesh * | parent | ) | [inline] |
Set pointer to mesh parent of triangle.
bool cTriangle::allocated | ( | ) | const [inline] |
Is this triangle allocated to an existing mesh?
bool cTriangle::computeCollision | ( | const cVector3d & | a_rayOrigin, | |
const cVector3d & | a_rayDir, | |||
cGenericObject *& | a_colObject, | |||
cTriangle *& | a_colTriangle, | |||
cVector3d & | a_colPoint, | |||
double & | a_colSquareDistance | |||
) | const [inline] |
Check if a ray intersects this triangle. The ray is described by its origin (/e a_origin) and its direction (/e a_direction).
If a collision occurs, the square distance between the ray origin and the collision point in measured and compared to any previous collision information stored in parameters a_colObject, a_colTriangle, a_colPoint, and a_colSquareDistance.
If the new collision is located nearer to the ray origin than the previous collision point, it is stored in the corresponding parameters a_colObject, a_colTriangle, a_colPoint, and a_colSquareDistance.
a_rayOrigin | Point from where collision ray starts (in local frame). | |
a_rayDir | Direction vector of collision ray (in local frame). | |
a_colObject | Pointer to nearest collided object. | |
a_colTriangle | Pointer to nearest collided triangle. | |
a_colPoint | Position of nearest collision. | |
a_colSquareDistance | Distance between ray origin and nearest collision point. |
This is one of the most performance-critical routines in CHAI, so we have code here for a couple different approaches that may become useful in different scenarios.
double cTriangle::compute_area | ( | ) | [inline] |
Compute and return the area of this triangle