Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

Triangle Class Reference

A simple Triangle primitive that stores information directly. More...

#include <surfaces/Triangle.h>

Inheritance diagram for Triangle:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Triangle (const Vector3 &_p0, const Vector3 &_p1, const Vector3 &_p2, SurfaceShader *mat)
 Triangle (const Vector3 &_p0, const Vector3 &_p1, const Vector3 &_p2, const Vector3 &_n0, const Vector3 &_n1, const Vector3 &_n2, SurfaceShader *mat)
 Triangle (const Vector3 &_p0, const Vector3 &_p1, const Vector3 &_p2, const Vector3 &_n0, const Vector3 &_n1, const Vector3 &_n2, const Vector2 &_u0, const Vector2 &_u1, const Vector2 &_u2, SurfaceShader *mat)
bool hit (Ray &r, HitRecord &rec, Context &context) const
bool shadowHit (Ray &r, Context &context) const
BBox boundingBox (double time0, double time1) const
bool overlapsBox (const BBox &box) const
 Uses Tomas Akenine-Moller's code for Triangle-Box overlap.
double pdfDirection (const Vector3 &vout, const HitRecord &hrec, Context &context) const
double area () const

Public Attributes

SurfaceShadersshader
Vertices
The vertex positions.

Vector3 p0
Vector3 p1
Vector3 p2
Normals
Per vertex normals.

Vector3 n0
Vector3 n1
Vector3 n2
TextureCoordinates
Per vertex texture coordinates.

Vector2 u0
Vector2 u1
Vector2 u2

Detailed Description

A simple Triangle primitive that stores information directly.

A Triangle primitive that stores all information (position, normals and texture coordinates) explicitly. Shading information is interpolated according to the barycentric coordinates of the hit location.


Member Function Documentation

bool Triangle::hit Ray r,
HitRecord rec,
Context context
const [virtual]
 

Intersect given ray with the surface.

Parameters:
[in,out] r Ray to be intersected.
[in,out] rec Struct for passed back shading geometry.
[in,out] context Rendering context.
Returns:
Returns true if a new closest intersection has been found.

Implements Surface.

bool Triangle::shadowHit Ray r,
Context context
const [virtual]
 

Intersect without visibility ordering or shading geometry.

Parameters:
[in,out] r Ray to be intersected.
[in,out] context Rendering context.
Returns:
Returns true if a valid intersection is found.

Reimplemented from Surface.

BBox Triangle::boundingBox double  time0,
double  time1
const [virtual]
 

Calculate the bounding box of the surface.

Parameters:
[in] time0 Minimum of time interval being sampled.
[in] time1 Maximum of time interval being sampled.
Returns:
The bounding box of the object in the interval [time0, time1).

Implements Surface.

double Triangle::pdfDirection const Vector3 w_in,
const HitRecord rec,
Context context
const [virtual]
 

We assume that a point is chosen at random on the triangle, so the pdf with area measure is 1/A. For a given point on the triangle with area dA we know $(1/A) dA = q(\omega_{in})d\Omega$ . We also know that $d\Omega = dA cosine / dist^2$ , so $(1/A) = q(\omega_{in}) cosine / dist^2$ so $q(\omega_{in}) = dist^2 / (A cosine)$ .

Reimplemented from Surface.


The documentation for this class was generated from the following files:
Generated on Wed Jul 20 16:15:30 2005 for galileo by  doxygen 1.4.3