Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::Triangle Struct Reference

Simple triangle class including a collection of routines for analysis and transformation. More...

#include <mitsuba/core/triangle.h>

Public Member Functions

AABB getAABB (const Point *positions) const
 Construct an axis-aligned box, which contains the triangle. More...
 
AABB getClippedAABB (const Point *positions, const AABB &aabb) const
 Returns the axis-aligned bounding box of a triangle after it has clipped to the extends of another given AABB. More...
 
BSphere getBSphere (const Point *positions) const
 
Point sample (const Point *positions, const Normal *normals, const Point2 *texCoords, Normal &n, Point2 &uv, const Point2 &seed) const
 Uniformly sample a point on the triangle and return its normal and UV coordinates. More...
 
Float surfaceArea (const Point *positions) const
 Calculate the surface area of this triangle. More...
 
FINLINE bool rayIntersect (const Point *positions, const Ray &ray, Float &u, Float &v, Float &t) const
 Ray-triangle intersection test. More...
 

Static Public Member Functions

static FINLINE bool rayIntersect (const Point &p0, const Point &p1, const Point &p2, const Ray &ray, Float &u, Float &v, Float &t)
 Ray-triangle intersection test. More...
 

Public Attributes

uint32_t idx [3]
 Indices into a vertex buffer. More...
 

Detailed Description

Simple triangle class including a collection of routines for analysis and transformation.

Triangles are stored as indices into a vertex array

Member Function Documentation

AABB mitsuba::Triangle::getAABB ( const Point positions) const
inline

Construct an axis-aligned box, which contains the triangle.

BSphere mitsuba::Triangle::getBSphere ( const Point positions) const
inline
AABB mitsuba::Triangle::getClippedAABB ( const Point positions,
const AABB aabb 
) const

Returns the axis-aligned bounding box of a triangle after it has clipped to the extends of another given AABB.

This function uses the Sutherland-Hodgman algorithm to calculate the convex polygon that is created when applying all 6 AABB splitting planes to the triangle. Afterwards, the AABB of the newly created convex polygon is returned. This function is an important component for efficiently creating 'Perfect Split' KD-trees. For more detail, see "On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N)" by Ingo Wald and Vlastimil Havran

static FINLINE bool mitsuba::Triangle::rayIntersect ( const Point p0,
const Point p1,
const Point p2,
const Ray ray,
Float u,
Float v,
Float t 
)
inlinestatic

Ray-triangle intersection test.

Uses the algorithm by Moeller and Trumbore discussed at http://www.acm.org/jgt/papers/MollerTrumbore97/code.html.

Parameters
p0Position of the first vertex
p1Position of the second vertex
p2Position of the third vertex
rayThe ray segment to be used for the intersection query
tUpon success, t contains the distance from the ray origin to the intersection point,
uUpon success, u will contain the 'U' component of the intersection in barycentric coordinates
vUpon success, v will contain the 'V' component of the intersection in barycentric coordinates
Returns
true if an intersection has been detected
FINLINE bool mitsuba::Triangle::rayIntersect ( const Point positions,
const Ray ray,
Float u,
Float v,
Float t 
) const
inline

Ray-triangle intersection test.

Uses the algorithm by Moeller and Trumbore discussed at http://www.acm.org/jgt/papers/MollerTrumbore97/code.html.

Parameters
positionsPointer to the vertex positions of the underlying triangle mesh
indexIndex of the triangle that should be intersected
rayThe ray segment to be used for the intersection query
tUpon success, t contains the distance from the ray origin to the intersection point,
uUpon success, u will contain the 'U' component of the intersection in barycentric coordinates
vUpon success, v will contain the 'V' component of the intersection in barycentric coordinates
Returns
true if an intersection has been detected
Point mitsuba::Triangle::sample ( const Point positions,
const Normal normals,
const Point2 texCoords,
Normal n,
Point2 uv,
const Point2 seed 
) const

Uniformly sample a point on the triangle and return its normal and UV coordinates.

Float mitsuba::Triangle::surfaceArea ( const Point positions) const

Calculate the surface area of this triangle.

Member Data Documentation

uint32_t mitsuba::Triangle::idx[3]

Indices into a vertex buffer.


The documentation for this struct was generated from the following file: