DD::Image::Triangle Class Reference

Inherits DD::Image::PolygonPrimitive.

List of all members.

Public Member Functions

const char * Class () const
 Triangle (int p0=0, int p1=1, int p2=2)
 Triangle (const Triangle &)
Triangleoperator= (const Triangle &b)
Primitiveduplicate () const
Vector3 average_center (const PointList *) const
 Returns the xyz center average of the triangle.
bool IntersectsRay (const Ray &ray, int n, const PointList *pointList, CollisionResult *result) const
 Test for the intersection of this primitive with a given ray.
void validate (PrimitiveContext *)
unsigned faces () const
void draw_wireframe (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const
void draw_solid (ViewerContext *, PrimitiveContext *, Primitive *prev_prim=0) const
void draw_solid_face (int n, ViewerContext *, PrimitiveContext *) const
void draw_primitive_num (ViewerContext *, PrimitiveContext *) const
void draw_primitive_normal (ViewerContext *, PrimitiveContext *) const
void print_info () const
PrimitiveType getPrimitiveType () const

Protected Member Functions

void copy (const Triangle *)

Detailed Description

Simple triangle primitive.


Constructor & Destructor Documentation

Triangle::Triangle ( int  p0 = 0,
int  p1 = 1,
int  p2 = 2 
)

Constructor accepting 3 points.

References DD::Image::Primitive::vertex_.

Referenced by duplicate().

Triangle::Triangle ( const Triangle b)

Copy constuctor.

References copy().


Member Function Documentation

void Triangle::copy ( const Triangle b) [protected]

Destructive copy.

Referenced by Triangle().

Primitive * Triangle::duplicate ( ) const [virtual]

Copy this Triangle into a new one, and return a pointer to it. Vertex data is duplicated, point indices are unchanged.

Implements DD::Image::Primitive.

References Triangle().

Vector3 Triangle::average_center ( const PointList *  points) const [virtual]

Returns the xyz center average of the triangle.

Return the primitive's xyz local-space center.

Reimplemented from DD::Image::Primitive.

bool DD::Image::Triangle::IntersectsRay ( const Ray ray,
int  n,
const PointList *  pointList,
CollisionResult *  result 
) const [inline, virtual]

Test for the intersection of this primitive with a given ray.

If a collision is detected, information is returned in the collision result

Reimplemented from DD::Image::Primitive.

References DD::Image::Primitive::PolyIntersectsRay().

void Triangle::validate ( PrimitiveContext ptx) [virtual]

Calculate the surface normal - points out with a ccw winding.

Reimplemented from DD::Image::Primitive.

References DD::Image::Primitive::normal_, and DD::Image::Vector3::normalize().

void Triangle::draw_solid_face ( int  n,
ViewerContext ctx,
PrimitiveContext ptx 
) const [virtual]

Draw the single face as a filled triangle.

Reimplemented from DD::Image::Primitive.

References DD::Image::Vector3::array(), and DD::Image::Primitive::vertex_.