#include <Triangle.h>
Public Member Functions | |
Triangle (const MS3DTriangle *const triangle, const Model &model, bool smooth=true) | |
Initialize the Triangle using data from the corresponding Milkshape triangle. | |
Triangle (const Vertex &v1, const Vector &n1, const Vertex &v2, const Vector &n2, const Vertex &v3, const Vector &n3, const Model &model) | |
Initialize the Triangle using the given vertices and normals. | |
const Vertex & | getVertex (unsigned int which) const |
Retrieve the given Vertex for this Triangle. | |
const Vector & | getNormal (unsigned int which) const |
Retrieve the normal for the given Vertex of this Triangle. | |
const Vector & | getNormal (const Vertex &which) const |
Retrieve the normal for the given Vertex of this Triangle. | |
const Vector & | getNormal () const |
Retrieve the Triangle normal. | |
const Vector & | getTextureCoordinates (unsigned int which) const |
Retrieve the texture coordinates at the given Vertex for this Triangle. | |
const Matrix & | getObjectToTangentSpaceMatrix (unsigned int which) const |
Retrieve the matrix which converts from object to tangent space at the given Vertex for this Triangle. | |
int | getEdgeIndex (unsigned int which) const |
Retrieve the edge index for the given edge for this Triangle. | |
bool | isFacing (const Vector &point) const |
Is this Triangle facing the light? | |
Protected Attributes | |
std::vector< const Vertex * > | m_vertices |
The Vertex objects which define this Triangle. | |
Vector | m_normal |
The Triangle normal. | |
std::vector< Vector > | m_vertexNormals |
The normals at each Vertex. | |
std::vector< Vector > | m_textureCoordinates |
The texture coordinates at each Vertex. | |
std::vector< int > | m_edgeIndices |
The edge indices for this Triangle. | |
std::vector< Matrix > | m_objectToTangentSpace |
Per vertex transform from object to tangent space. | |
const Model & | m_model |
The Model to which this Triangle belongs. | |
Private Member Functions | |
Triangle (const Triangle ©) | |
Do not allow this Triangle to be copied. | |
Triangle & | operator= (const Triangle &rhs) |
Do not allow this Triangle to be copied. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Triangle &triangle) |
Insertion operator for this Triangle into an output stream. |
|
Is this Triangle facing the light? The determination is made by computing the angle between the Triangle's Normal and the direction from the light to one of the Triangle's Vertices. If this angle is between 180 and 360, it is facing away otherwise it is facing towards. |
|
The edge indices for this Triangle. The edge index is defined as the combination of the two Vertex indices for the two ends of that edge, listed in increasing order. For example, say this Triangle has Vertex indices 0xA3, 0x17 and 0xF8. The first edge is made of Vertices (0x17, 0xA3), the second edge (0x17, 0xF8) and the third edge (0xA3, 0xF8). The edge index of the first edge is 0x17A3, the second edge is 0x17F8 and the third edge is 0xA3F8. Each edge index is therefore guaranteed to be shared between two Triangles if they share the corresponding Vertices. |
|
Per vertex transform from object to tangent space. This matrix is used to bring the light Vector from object space into tangent space. "Tangent space" is the vector space defined by the s-, t- and (s- cross t-) texture directions. The (s- cross t-) direction "corresponds" to the triangle normal (in "object space"). Given a point P inside the face (with texture coordinates s_P and t_P), and a vertex E belonging to the face (with texture coordinates s_E and t_E) we would like for the following to hold:
|