Triangle Class Reference

Basic representation of a Triangle with optional UV coordinates. More...

#include <Triangle.h>

Inheritance diagram for Triangle:

Transformable Shape Intersectable SSEAligned

List of all members.

Public Member Functions

Constructors
 Triangle ()
 Triangle (Vertex *vertices_=NULL, Normal *normals_=NULL, UV *uvs_=NULL)
 Triangle (const Vertex &vA, const Vertex &vB, const Vertex &vC)
 Triangle (const Vertex &vA, const Vertex &vB, const Vertex &vC, const UV &tA, const UV &tB, const UV &tC)
 Triangle (const Vertex &vA, const Vertex &vB, const Vertex &vC, const Normal &nA, const Normal &nB, const Normal &nC, const UV &tA, const UV &tB, const UV &tC)
Core functionality
virtual void init ()
 Initializes this triangle for intersection tests.
virtual void preview ()
virtual real_t getIntersection (const Ray &ray, SurfacePoint &pt)
 Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).
Accessors
Vector3 getNormal () const
Vector3 getCentroid () const
Sampling functionality
virtual void getRandomPoint (SurfacePoint &pt)
virtual Point3 getPosition (const UV &uv)

Public Attributes

Fast-access public data
Vertex vertices [3]
Normal normals [3]
UV uvs [3]

Protected Member Functions

virtual void _getUV (SurfacePoint &pt) const
virtual void _getGeometricNormal (SurfacePoint &pt) const
virtual real_t _getSurfaceArea ()


Detailed Description

Basic representation of a Triangle with optional UV coordinates.

Author:
Travis Fischer (fisch0920@gmail.com)

Nong Li (nongli@gmail.com)

Date:
Spring 2008
See also:
also MeshTriangle.h which defines a MeshTriangle class used within meshes and differs from Triangle in that it is a standalone Shape and doesn't depend on a parent Mesh to exist

Definition at line 24 of file Triangle.h.


Constructor & Destructor Documentation

Triangle::Triangle (  )  [inline]

Definition at line 39 of file Triangle.h.

Triangle::Triangle ( Vertex vertices_ = NULL,
Normal normals_ = NULL,
UV uvs_ = NULL 
) [inline]

Definition at line 42 of file Triangle.h.

Triangle::Triangle ( const Vertex vA,
const Vertex vB,
const Vertex vC 
) [inline]

Definition at line 55 of file Triangle.h.

Triangle::Triangle ( const Vertex vA,
const Vertex vB,
const Vertex vC,
const UV tA,
const UV tB,
const UV tC 
) [inline]

Definition at line 70 of file Triangle.h.

Triangle::Triangle ( const Vertex vA,
const Vertex vB,
const Vertex vC,
const Normal nA,
const Normal nB,
const Normal nC,
const UV tA,
const UV tB,
const UV tC 
) [inline]

Definition at line 86 of file Triangle.h.


Member Function Documentation

void Triangle::init (  )  [virtual]

Initializes this triangle for intersection tests.

Reimplemented from Transformable.

Definition at line 70 of file Triangle.cpp.

void Triangle::preview (  )  [virtual]

Display a crude OpenGL preview of this shape

Note:
Default implementation sets the ModelView matrix appropriately with respect to this Transformable's transformation

Reimplemented from Transformable.

Definition at line 47 of file Triangle.cpp.

real_t Triangle::getIntersection ( const Ray ray,
SurfacePoint pt 
) [virtual]

Tests the given ray with this object for intersection. If a valid intersection exists, its "t" value will be returned and the given SurfacePoint will be initialized with enough data for this object to later fill in all relevant information lazily (world space normal at intersection point, uv coordinates, etc.).

Note:
if you only care about whether or not an intersection exists and don't actually need to know the exact intersection point, see the intersects method instead.
Returns:
the smallest positive "t" value of any intersections found, or INFINITY if no valid intersection exists

Implements Intersectable.

Definition at line 218 of file Triangle.cpp.

Vector3 Triangle::getNormal (  )  const

Returns:
the normal of this triangle in object space

Definition at line 304 of file Triangle.cpp.

Vector3 Triangle::getCentroid (  )  const

Returns:
the centroid (center) of the triangle in object space

Definition at line 62 of file Triangle.cpp.

void Triangle::getRandomPoint ( SurfacePoint pt  )  [virtual]

Returns:
a point chosen uniformly random over the surface of this shape in 'pt'
Note:
the probability density of selecting this point is assumed to be (1.0 / getSurfaceArea())

Reimplemented from Shape.

Definition at line 311 of file Triangle.cpp.

Point3 Triangle::getPosition ( const UV uv  )  [virtual]

Returns:
the point on the surface of this shape corresponding to the given UV coordinates

Reimplemented from Transformable.

Definition at line 330 of file Triangle.cpp.

void Triangle::_getUV ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 21 of file Triangle.cpp.

void Triangle::_getGeometricNormal ( SurfacePoint pt  )  const [protected, virtual]

Implements Shape.

Definition at line 41 of file Triangle.cpp.

real_t Triangle::_getSurfaceArea (  )  [protected, virtual]

Returns:
the total surface area of this shape

Reimplemented from Shape.

Definition at line 354 of file Triangle.cpp.


Member Data Documentation

Definition at line 30 of file Triangle.h.

Definition at line 31 of file Triangle.h.

Definition at line 32 of file Triangle.h.


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

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6