Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
G3D::Triangle Class Reference

A generic triangle representation. More...

Public Member Functions

 Triangle (class BinaryInput &b)
 
 Triangle ()
 
 Triangle (const Point3 &v0, const Point3 &v1, const Point3 &v2)
 
 ~Triangle ()
 
float area () const
 
Point3 center () const
 Barycenter.
 
void deserialize (class BinaryInput &b)
 
const Vector3edge01 () const
 vertex[1] - vertex[0]
 
const Vector3edge02 () const
 vertex[2] - vertex[0]
 
void getBounds (class AABox &) const
 
void getRandomSurfacePoint (Point3 &P, Vector3 &N=Vector3::ignore()) const
 
size_t hashCode () const
 
bool intersect (const class Ray &ray, float &distance, float baryCoord[3]) const
 Intersect the ray at distance less than distance.
 
const Vector3normal () const
 
bool operator== (const Triangle &other) const
 For two triangles to be equal they must have the same vertices in the same order.
 
const Planeplane () const
 
Vector3::Axis primaryAxis () const
 
Point3 randomPoint () const
 Returns a random point in the triangle.
 
void serialize (class BinaryOutput &b)
 
const Point3vertex (int n) const
 0, 1, or 2
 

Friends

class CollisionDetection
 
class Ray
 

Detailed Description

A generic triangle representation.

This should not be used as the underlying triangle for creating models; it is intended for providing fast property queries but requires a lot of storage and is mostly immutable.

Constructor & Destructor Documentation

G3D::Triangle::Triangle ( class BinaryInput b)
G3D::Triangle::Triangle ( )
G3D::Triangle::Triangle ( const Point3 v0,
const Point3 v1,
const Point3 v2 
)
G3D::Triangle::~Triangle ( )

Member Function Documentation

float G3D::Triangle::area ( ) const
Point3 G3D::Triangle::center ( ) const

Barycenter.

Referenced by G3D::TriangleShape::center().

void G3D::Triangle::deserialize ( class BinaryInput b)
const Vector3& G3D::Triangle::edge01 ( ) const
inline

vertex[1] - vertex[0]

Referenced by G3D::Ray::intersectionTime().

const Vector3& G3D::Triangle::edge02 ( ) const
inline

vertex[2] - vertex[0]

Referenced by G3D::Ray::intersectionTime().

void G3D::Triangle::getBounds ( class AABox ) const
void G3D::Triangle::getRandomSurfacePoint ( Point3 P,
Vector3 N = Vector3::ignore() 
) const
inline
size_t G3D::Triangle::hashCode ( ) const
inline
bool G3D::Triangle::intersect ( const class Ray ray,
float &  distance,
float  baryCoord[3] 
) const

Intersect the ray at distance less than distance.

Parameters
distanceSet to the maximum distance (can be G3D::inf()) to search for an intersection. On return, this is the smaller of the distance to the intersection, if one exists, and the original value.
baryCoordIf a triangle is hit before distance, a the barycentric coordinates of the hit location on the triangle. Otherwise, unmodified.
Returns
True if there was an intersection before the original distance.
const Vector3& G3D::Triangle::normal ( ) const
bool G3D::Triangle::operator== ( const Triangle other) const
inline

For two triangles to be equal they must have the same vertices in the same order.

That is, vertex[0] == vertex[0], etc.

const Plane& G3D::Triangle::plane ( ) const
Vector3::Axis G3D::Triangle::primaryAxis ( ) const
inline
Point3 G3D::Triangle::randomPoint ( ) const

Returns a random point in the triangle.

Referenced by getRandomSurfacePoint(), and G3D::TriangleShape::randomInteriorPoint().

void G3D::Triangle::serialize ( class BinaryOutput b)
const Point3& G3D::Triangle::vertex ( int  n) const
inline

Friends And Related Function Documentation

friend class CollisionDetection
friend
friend class Ray
friend

documentation generated on Sat Jan 12 2013 22:49:57 using doxygen 1.8.2