Polygon Class Reference

#include <polygon.h>

Inheritance diagram for Polygon:

Inheritance graph
[legend]
Collaboration diagram for Polygon:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool add_vertex (Point3D vertex)
virtual bool collides_with (const Ray &ray, double &t) const
virtual Ray get_normal (const Point3D &p) const
 Returns the surface normal at point p.
 Polygon (std::string color, std::string material, std::string bumpmap)
 Creates a new plane defined by three points in 3-space.
virtual ~Polygon ()

Protected Attributes

float m_d
Ray m_normal
std::vector< Point3Dm_vertices

Static Protected Attributes

static StaticInit m_init
 Force static initialization.

Classes

class  StaticInit
 Fake a static initializer. More...

Detailed Description

Definition at line 19 of file polygon.h.


Constructor & Destructor Documentation

Polygon::Polygon ( std::string  color,
std::string  material,
std::string  bumpmap 
)

Creates a new plane defined by three points in 3-space.

Definition at line 16 of file polygon.cpp.

References Scene::get_bumpmap(), Scene::get_instance(), Scene::get_material(), Renderable::m_bumpmap, and Renderable::m_material.

Here is the call graph for this function:

virtual Polygon::~Polygon (  )  [inline, virtual]

Definition at line 50 of file polygon.h.


Member Function Documentation

bool Polygon::add_vertex ( Point3D  vertex  ) 

Adds the vertex to the polygon. The vertex must be coplanar to be added.

Parameters:
vertex The vertex to add to the polygon.
Returns:
True of this was a new vertex added to the polygon, false if the vertex already existed in the definition, or if the vertex is not coplanar with the other vertices.

Definition at line 27 of file polygon.cpp.

References cross_product(), Ray::direction(), dot_product(), log_warn, m_d, m_normal, and m_vertices.

Referenced by new_polygon().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Polygon::collides_with ( const Ray ray,
double &  t 
) const [virtual]

Does the ray passed in collide with this polygon?

Parameters:
ray The ray which is being traced.
t This is z-depth at which the ray collides with the polygon.
Returns:
True if the ray collides with the polygon.

Implements Renderable.

Definition at line 62 of file polygon.cpp.

References cross_product(), Ray::direction(), dot_product(), m_d, m_normal, m_vertices, and Ray::origin().

Here is the call graph for this function:

Ray Polygon::get_normal ( const Point3D p  )  const [virtual]

Returns the surface normal at point p.

Implements Renderable.

Definition at line 191 of file polygon.cpp.

References Ray::direction(), and m_normal.

Here is the call graph for this function:


Member Data Documentation

float Polygon::m_d [protected]

Definition at line 37 of file polygon.h.

Referenced by add_vertex(), and collides_with().

Polygon::StaticInit Polygon::m_init [static, protected]

Force static initialization.

Definition at line 32 of file polygon.h.

Ray Polygon::m_normal [protected]

The normal of a polygon is always the same so this stores it so we only have to calculate it once.

Definition at line 36 of file polygon.h.

Referenced by add_vertex(), collides_with(), and get_normal().

std::vector<Point3D> Polygon::m_vertices [protected]

This is the list of vertices of this polygon. All vertices in a polygon must be coplanar.

Definition at line 41 of file polygon.h.

Referenced by add_vertex(), and collides_with().


The documentation for this class was generated from the following files:
Generated on Tue Oct 30 22:12:23 2007 for mbrt by  doxygen 1.5.2