rcrt::Triangle Class Reference

#include <Triangle.h>

Inheritance diagram for rcrt::Triangle:

Inheritance graph
[legend]
Collaboration diagram for rcrt::Triangle:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Triangle (const Point3D &a, const Point3D &b, const Point3D &c, const Vec3D &fNo, SolidObject *parent=0)
 Triangle (Vertex *av, Vertex *bv, Vertex *cv, SolidObject *parent=0, bool smooth=false)
virtual ~Triangle ()
Vertexoperator[] (int i) const
Vertex *& operator[] (int i)
virtual Intersection intersect (Ray &ray) const
virtual const AABBgetBoundingBox () const
virtual const Point3DgetCentroid () const
virtual Vec3D getSNormal (float beta, float gamma) const
virtual Vec3D getGNormal (float beta, float gamma) const
virtual Point2D getUV (float beta, float gamma) const
virtual Point3D getPoint (float beta, float gamma) const
virtual Point2D getUV (const Point2D &p) const
virtual Point3D getPoint (const Point2D &p) const
virtual Vec3D getTangent (float beta, float gamma) const
virtual bool isSmooth () const
void updateBox ()
void clipPlane (Axis axis, float plane, AABB &lBox, AABB &rBox) const

Protected Member Functions

float volume (const Point3D &o, const Point3D &e, const Point3D &a, const Point3D &b) const
bool sameSign (const float &a, const float &b) const

Protected Attributes

Vertexa
Vertexb
Vertexc
AABB box
Point3D center
Vec3D faceNormal
Vec3D tangent
bool ownVertices
bool smooth


Detailed Description

A primitive of three vertices.

Definition at line 18 of file Triangle.h.


Constructor & Destructor Documentation

rcrt::Triangle::Triangle ( const Point3D a,
const Point3D b,
const Point3D c,
const Vec3D fNo,
SolidObject parent = 0 
)

Creates a triangle without Vertex data. Triangles created this way are never smooth.

Parameters:
a 
b 
c 
fNo The normal of the triangle.
parent 

Definition at line 21 of file Triangle.cpp.

References a, b, c, faceNormal, ownVertices, and updateBox().

Referenced by rcrt::DisplacedTriangle::DisplacedTriangle(), and rcrt::DisplacedTriangle::intersect().

rcrt::Triangle::Triangle ( Vertex av,
Vertex bv,
Vertex cv,
SolidObject parent = 0,
bool  smooth = false 
)

Creates a triangle wit Vertex data.

Parameters:
av 
bv 
cv 
parent 
smooth Whether this Triangle should use interpolated normals.

Definition at line 33 of file Triangle.cpp.

References a, b, c, rcrt::Vec2D::det(), faceNormal, rcrt::Vec3D::normalize(), ownVertices, rcrt::Vertex::pos(), tangent, updateBox(), and rcrt::Vertex::uv().

rcrt::Triangle::~Triangle (  )  [virtual]

Definition at line 75 of file Triangle.cpp.

References a, b, c, and ownVertices.


Member Function Documentation

float rcrt::Triangle::volume ( const Point3D o,
const Point3D e,
const Point3D a,
const Point3D b 
) const [protected]

Definition at line 9 of file Triangle.cpp.

bool rcrt::Triangle::sameSign ( const float &  a,
const float &  b 
) const [protected]

Definition at line 16 of file Triangle.cpp.

Vertex * rcrt::Triangle::operator[] ( int  i  )  const

Parameters:
i The index of the Vertex to access.
Returns:
a Vertex*.

Definition at line 84 of file Triangle.cpp.

References a, b, and c.

Vertex *& rcrt::Triangle::operator[] ( int  i  ) 

Definition at line 94 of file Triangle.cpp.

References a, b, and c.

Intersection rcrt::Triangle::intersect ( Ray r  )  const [virtual]

Parameters:
The ray that will be tested against.
Returns:
An Intersection that contains the closest intersection that can be determined.

Implements rcrt::Traceable.

Reimplemented in rcrt::DisplacedTriangle.

Definition at line 156 of file Triangle.cpp.

References a, rcrt::Ray::atDistance(), b, c, rcrt::Vec3D::crossP(), rcrt::Ray::dir(), faceNormal, rcrt::Ray::maxDist(), rcrt::Ray::org(), rcrt::Vertex::pos(), rcrt::Intersection::setUV(), and rcrt::Ray::tris.

Referenced by rcrt::DisplacedTriangle::intersect().

const AABB & rcrt::Triangle::getBoundingBox (  )  const [virtual]

Returns:
The minimum Axis-Aligned Bounding Box of this Traceable.

Implements rcrt::Traceable.

Definition at line 197 of file Triangle.cpp.

References box.

const Point3D & rcrt::Triangle::getCentroid (  )  const [virtual]

Returns:
Some kind of central point of this object. This may just be an approximation (e.g. the central point of the AABB).

Implements rcrt::Traceable.

Definition at line 202 of file Triangle.cpp.

References center.

Vec3D rcrt::Triangle::getSNormal ( float  a,
float  b 
) const [virtual]

Parameters:
a 2D Parameterization of the surface
b 2D Parameterization of the surface
Returns:
The local space shading normal of the parameterized point on the primitive.

Implements rcrt::Primitive.

Definition at line 207 of file Triangle.cpp.

References a, b, c, faceNormal, rcrt::Vertex::normal(), and smooth.

Vec3D rcrt::Triangle::getGNormal ( float  a,
float  b 
) const [virtual]

Parameters:
a 2D Parameterization of the surface
b 2D Parameterization of the surface
Returns:
The local space geometry normal of the parameterized point on the primitive.

Implements rcrt::Primitive.

Definition at line 215 of file Triangle.cpp.

References faceNormal.

Point2D rcrt::Triangle::getUV ( float  a,
float  b 
) const [virtual]

Parameters:
a 2D Parameterization of the surface
b 2D Parameterization of the surface
Returns:
UV texture coordinates of this point.

Implements rcrt::Primitive.

Definition at line 220 of file Triangle.cpp.

References a, b, c, rcrt::Vertex::uv(), rcrt::Point2D::x(), and rcrt::Point2D::y().

Referenced by rcrt::DisplacedTriangle::getDispPoint(), and getUV().

Point3D rcrt::Triangle::getPoint ( float  beta,
float  gamma 
) const [virtual]

Definition at line 227 of file Triangle.cpp.

References a, b, c, and rcrt::Vertex::pos().

Referenced by rcrt::DisplacedTriangle::getDispNormal(), rcrt::DisplacedTriangle::getDispPoint(), getPoint(), and rcrt::DisplacedTriangle::intersect().

Point2D rcrt::Triangle::getUV ( const Point2D p  )  const [virtual]

Definition at line 233 of file Triangle.cpp.

References getUV().

Point3D rcrt::Triangle::getPoint ( const Point2D p  )  const [virtual]

Definition at line 240 of file Triangle.cpp.

References getPoint().

Vec3D rcrt::Triangle::getTangent ( float  a,
float  b 
) const [virtual]

Parameters:
a 2D Parameterization of the surface
b 2D Parameterization of the surface
Returns:
The local space tangent vector of the parameterized point on the primitive.

Reimplemented from rcrt::Primitive.

Definition at line 247 of file Triangle.cpp.

References tangent.

bool rcrt::Triangle::isSmooth (  )  const [virtual]

Definition at line 274 of file Triangle.cpp.

References smooth.

void rcrt::Triangle::updateBox (  ) 

Definition at line 252 of file Triangle.cpp.

References a, b, box, c, rcrt::AABB::extend(), rcrt::Vertex::pos(), rcrt::Point3D::x(), rcrt::Point3D::y(), and rcrt::Point3D::z().

Referenced by Triangle().

void rcrt::Triangle::clipPlane ( Axis  axis,
float  plane,
AABB lBox,
AABB rBox 
) const [virtual]

Parameters:
axis The Axis of the plane with which to clip.
plane The value along the axis which describes the plane.
lBox An AABB that should contain the left part (with respect to the clipping plane) of the object after calling this method.
rBox An AABB that should contain the right part of the object after this method.

Reimplemented from rcrt::Traceable.

Definition at line 279 of file Triangle.cpp.

References a, b, c, rcrt::AABB::extend(), and rcrt::Vertex::pos().


Member Data Documentation

Vertex* rcrt::Triangle::a [protected]

Definition at line 21 of file Triangle.h.

Referenced by rcrt::DisplacedTriangle::baseIntersect(), clipPlane(), rcrt::DisplacedTriangle::DisplacedTriangle(), getPoint(), getSNormal(), getUV(), intersect(), rcrt::DisplacedTriangle::intersect(), operator[](), Triangle(), updateBox(), and ~Triangle().

Vertex* rcrt::Triangle::b [protected]

Definition at line 22 of file Triangle.h.

Referenced by rcrt::DisplacedTriangle::baseIntersect(), clipPlane(), rcrt::DisplacedTriangle::DisplacedTriangle(), getPoint(), getSNormal(), getUV(), intersect(), rcrt::DisplacedTriangle::intersect(), operator[](), Triangle(), updateBox(), and ~Triangle().

Vertex* rcrt::Triangle::c [protected]

Definition at line 23 of file Triangle.h.

Referenced by rcrt::DisplacedTriangle::baseIntersect(), clipPlane(), rcrt::DisplacedTriangle::DisplacedTriangle(), getPoint(), getSNormal(), getUV(), intersect(), rcrt::DisplacedTriangle::intersect(), operator[](), Triangle(), updateBox(), and ~Triangle().

AABB rcrt::Triangle::box [protected]

Definition at line 24 of file Triangle.h.

Referenced by rcrt::DisplacedTriangle::DisplacedTriangle(), getBoundingBox(), rcrt::DisplacedTriangle::intersect(), and updateBox().

Point3D rcrt::Triangle::center [protected]

Definition at line 26 of file Triangle.h.

Referenced by getCentroid().

Vec3D rcrt::Triangle::faceNormal [protected]

Definition at line 27 of file Triangle.h.

Referenced by rcrt::DisplacedTriangle::baseIntersect(), rcrt::DisplacedTriangle::DisplacedTriangle(), getGNormal(), getSNormal(), intersect(), rcrt::DisplacedTriangle::intersect(), and Triangle().

Vec3D rcrt::Triangle::tangent [protected]

Definition at line 28 of file Triangle.h.

Referenced by getTangent(), and Triangle().

bool rcrt::Triangle::ownVertices [protected]

Definition at line 29 of file Triangle.h.

Referenced by Triangle(), and ~Triangle().

bool rcrt::Triangle::smooth [protected]

Definition at line 30 of file Triangle.h.

Referenced by getSNormal(), and isSmooth().


The documentation for this class was generated from the following files:
Generated on Thu Jan 31 19:33:13 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3