librtl

rtl_polyhedron Class Reference

Implements an object which is a group of polygons (Triangles). More...

#include <polyhedron.h>

Inherits rtl_groupobj.

List of all members.

Public Members

Protected Members


Detailed Description

Implements an object which is a group of polygons (Triangles).

A polyhedron is defined as a mesh of polygons. This class implements such a mesh. It is important though that you use it correctly. If you build a polyhedron from a stream containing the appropriate information everything is correct however if you specify the mesh programmatically using addvertex and compute normals you should follow these steps:

Construct the polyhedron object
Make all the calls to add vertex for every vertex in the model
Add all of the polygons to the object (see note below)
Call compute normals

Note: if you construct a polyhedron programmatically it is important to ensure that all vertices are added before any of the triangles are constructed. Polygons are added as Triangles through the

Examples:
Polyhedrons.

Member Enumeration Type Documentation

enum rtl_polyhedron::VertexOrder

Enumeration values:


Member Function Documentation

rtl_polyhedron::rtl_polyhedron( jInt v_cnt, VertexOrder = cw )

Builds a polyhedron with room for the given number of vertices.

rtl_polyhedron::rtl_polyhedron( rtl_polyhedron* )

Builds a polyhedron that references another.

rtl_polyhedron::~rtl_polyhedron()

void rtl_polyhedron::addvertex( jInt, jFlt, jFlt, jFlt, jFlt=0, jFlt=0, jInt=-1, jInt=-1 )

Adds a vertex to the polyhedron. This function should not be called if the polyhedron was built from a stream.

Examples:
Polyhedrons.

void rtl_polyhedron::setnormal( jInt, jFlt, jFlt, jFlt )

Sets the normal for the ith vertex. Using this function will usurp automatic normal calculation for the vertex.

Examples:
Polyhedrons.

void rtl_polyhedron::computenormals()

Computes the vertex normals. This function should not be called if the polyhedron was built from a stream. Also this function should be called after the last call to addvertex.

Examples:
Polyhedrons.

rtl_material* rtl_polyhedron::material()

Returns the material which is the tri-linear combination of the materials of the vertices of the last triangle hit. If there has not been a triangle struck then the base class material is returned.

Reimplemented from rtl_subobject.

void rtl_polyhedron::scale( bool = false )

Scale the model so that it fits inside -1..1 in the widest dimension.

jVec3& rtl_polyhedron::getVertex( int i )

Returns the ith vertex for you to play with.

int rtl_polyhedron::vertexCount() const

Returns the number of vertices there are in the model.

Type rtl_polyhedron::type() const

Reimplemented from rtl_object.

jFlt rtl_polyhedron::intersect( const rtl_ray&, bool = false ) [protected]

Reimplemented from rtl_subobject.

bool rtl_polyhedron::volintersect( const jBBox& box ) const [protected]

Reimplemented from rtl_subobject.

jVec2 rtl_polyhedron::uv( const jVec3& ) [protected]

Reimplemented from rtl_object.

void rtl_polyhedron::setMaterial( rtl_material* ) [protected]

Sets the material for this object.

Reimplemented from rtl_object.


Member Data Documentation

int rtl_polyhedron::v_cnt [protected]

Number of vertices in the model.

vertex* rtl_polyhedron::v_tbl [protected]

Table of vertices.

rtl_material rtl_polyhedron::imat [protected]

rtl_material for triangles to compute the interpolated material into.

VertexOrder rtl_polyhedron::v_ord [protected]

Specifies the vertex order used to compute normals.


The documentation for this class was generated from the following file:
JSP / librtl v0.2 mtigges@cpsc.ucalgary.ca