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

toxic::Mesh Class Reference

#include <mesh.h>

Inheritance diagram for toxic::Mesh:

toxic::IAreaLight toxic::IBoundedObject toxic::ILight toxic::IObject toxic::Basis List of all members.

Public Types

typedef unsigned int FeatureId

Public Member Functions

 Mesh (const sheep::Matrix4 &m, const ISurfaceShader *surface_shader, IntersectionMask intersection_mask=INTERSECT_ALL_RAYS)
 m is the object space to world space transformation matrix.

virtual ~Mesh ()
FeatureId AppendVertex (const sheep::Point3 &v)
FeatureId AppendNormal (const sheep::Vector3 &vn)
FeatureId AppendTexCoord (const sheep::Vector2 &vt)
FeatureId AppendTriangle (FeatureId v0, FeatureId v1, FeatureId v2)
void SetTriangleNormals (FeatureId tri, FeatureId n0, FeatureId n1, FeatureId n2)
void SetTriangleTexCoords (FeatureId tri, FeatureId t0, FeatureId t1, FeatureId t2)
virtual void Finalize (const Context &context)
virtual const sheep::AABB3GetAABB () const
virtual sheep::Real ComputeSurfaceArea () const
 Computes the surface area of this object.

virtual void EvaluateSurface (const sheep::Point2 &input, sheep::Point3 *point, sheep::Vector3 *geometric_normal) const
virtual bool Intersect (const Context &context, const Ray &ray, Hit *hit=0) const
virtual void Annotate (const Context &context, const ICamera *camera, Framebuffer *framebuffer) const

Private Types

typedef std::vector< sheep::Point3vertex_vector
typedef std::vector< sheep::Vector3normal_vector
typedef std::vector< sheep::Vector2texcoord_vector
typedef std::vector< triangletriangle_vector
typedef vertex_vector::iterator vertex_vector_it
typedef triangle_vector::iterator triangle_vector_it
typedef vertex_vector::const_iterator vertex_vector_const_it
typedef triangle_vector::const_iterator triangle_vector_const_it
typedef sheep::Octree< const
triangle * > 
octree
typedef sheep::OctreeNode<
const triangle * > 
octree_node

Private Member Functions

void finalize_geometry ()

Private Attributes

vertex_vector m_vertices
normal_vector m_normals
texcoord_vector m_texcoords
triangle_vector m_triangles
octreem_octree
 Used only if the mesh contains enough triangles.

sheep::AABB3 m_aabb
 Bounding box of the object, expressed in world space.


Friends

class MeshBuilder

Member Typedef Documentation

typedef unsigned int toxic::Mesh::FeatureId
 

Definition at line 62 of file mesh.h.

Referenced by AppendNormal(), AppendTexCoord(), AppendTriangle(), AppendVertex(), SetTriangleNormals(), and SetTriangleTexCoords().

typedef std::vector<sheep::Vector3> toxic::Mesh::normal_vector [private]
 

Definition at line 124 of file mesh.h.

typedef sheep::Octree<const triangle *> toxic::Mesh::octree [private]
 

Definition at line 133 of file mesh.h.

Referenced by Finalize().

typedef sheep::OctreeNode<const triangle *> toxic::Mesh::octree_node [private]
 

Definition at line 134 of file mesh.h.

Referenced by toxic::Mesh::octree_full_visitor::Trace(), and toxic::Mesh::octree_test_visitor::Trace().

typedef std::vector<sheep::Vector2> toxic::Mesh::texcoord_vector [private]
 

Definition at line 125 of file mesh.h.

typedef std::vector<triangle> toxic::Mesh::triangle_vector [private]
 

Definition at line 126 of file mesh.h.

typedef triangle_vector::const_iterator toxic::Mesh::triangle_vector_const_it [private]
 

Definition at line 131 of file mesh.h.

Referenced by Annotate(), Finalize(), and Intersect().

typedef triangle_vector::iterator toxic::Mesh::triangle_vector_it [private]
 

Definition at line 129 of file mesh.h.

Referenced by finalize_geometry().

typedef std::vector<sheep::Point3> toxic::Mesh::vertex_vector [private]
 

Definition at line 123 of file mesh.h.

Referenced by toxic::Mesh::octree_full_visitor::octree_full_visitor(), toxic::Mesh::octree_test_visitor::octree_test_visitor(), and toxic::Mesh::triangle_voxel_intersector::triangle_voxel_intersector().

typedef vertex_vector::const_iterator toxic::Mesh::vertex_vector_const_it [private]
 

Definition at line 130 of file mesh.h.

Referenced by Finalize().

typedef vertex_vector::iterator toxic::Mesh::vertex_vector_it [private]
 

Definition at line 128 of file mesh.h.

Referenced by Finalize().


Constructor & Destructor Documentation

Mesh::Mesh const sheep::Matrix4 m,
const ISurfaceShader surface_shader,
IntersectionMask  intersection_mask = INTERSECT_ALL_RAYS
 

m is the object space to world space transformation matrix.

Definition at line 39 of file mesh.cpp.

Mesh::~Mesh  )  [virtual]
 

Definition at line 47 of file mesh.cpp.


Member Function Documentation

void Mesh::Annotate const Context context,
const ICamera camera,
Framebuffer framebuffer
const [virtual]
 

Reimplemented from toxic::IObject.

Definition at line 328 of file mesh.cpp.

References sheep::Vector3::IsUnitLength(), line(), m_normals, m_triangles, toxic::Basis::TransformNormalToWorld(), and triangle_vector_const_it.

Mesh::FeatureId Mesh::AppendNormal const sheep::Vector3 vn  ) 
 

Definition at line 57 of file mesh.cpp.

References FeatureId, sheep::Vector3::IsUnitLength(), and m_normals.

Mesh::FeatureId Mesh::AppendTexCoord const sheep::Vector2 vt  ) 
 

Definition at line 65 of file mesh.cpp.

References FeatureId, and m_texcoords.

Mesh::FeatureId Mesh::AppendTriangle FeatureId  v0,
FeatureId  v1,
FeatureId  v2
 

Definition at line 71 of file mesh.cpp.

References FeatureId, toxic::Mesh::triangle::m_n0, toxic::Mesh::triangle::m_n1, toxic::Mesh::triangle::m_n2, toxic::Mesh::triangle::m_t0, toxic::Mesh::triangle::m_t1, toxic::Mesh::triangle::m_t2, m_triangles, toxic::Mesh::triangle::m_v0, toxic::Mesh::triangle::m_v1, and toxic::Mesh::triangle::m_v2.

Mesh::FeatureId Mesh::AppendVertex const sheep::Point3 v  ) 
 

Definition at line 51 of file mesh.cpp.

References FeatureId.

Real Mesh::ComputeSurfaceArea  )  const [virtual]
 

Computes the surface area of this object.

Todo:
Implement.

Implements toxic::IBoundedObject.

Definition at line 153 of file mesh.cpp.

void Mesh::EvaluateSurface const sheep::Point2 input,
sheep::Point3 point,
sheep::Vector3 geometric_normal
const [virtual]
 

Given a point in the unit square (the set of points in [0..1]^2), this method computes the corresponding surface point and normal (both are expressed in world space).

Todo:
Implement.

Implements toxic::IBoundedObject.

Definition at line 159 of file mesh.cpp.

void Mesh::Finalize const Context context  )  [virtual]
 

This method must be called only once, after the object is completely configured, and before it is used for the first time.

Todo:
This is probably incorrect...

Reimplemented from toxic::IAreaLight.

Definition at line 102 of file mesh.cpp.

References sheep::AABB3::Extend(), toxic::IAreaLight::Finalize(), finalize_geometry(), sheep::Octree< Item >::GetAABB(), sheep::AABB3::Include(), sheep::Octree< Item >::Insert(), sheep::AABB3::Invalidate(), m_triangles, toxic::OBJECT_AABB_EXTENSION(), octree, sheep::Octree< Item >::Subdivide(), toxic::Basis::TransformToWorld(), triangle_vector_const_it, vertex_vector_const_it, and vertex_vector_it.

void Mesh::finalize_geometry  )  [private]
 

Definition at line 475 of file mesh.cpp.

References toxic::Mesh::triangle::m_geometric_normal, toxic::Mesh::triangle::m_n0, toxic::Mesh::triangle::m_n1, toxic::Mesh::triangle::m_n2, m_normals, toxic::Mesh::triangle::m_t0, toxic::Mesh::triangle::m_t1, toxic::Mesh::triangle::m_t2, m_texcoords, m_triangles, toxic::Mesh::triangle::m_v0, toxic::Mesh::triangle::m_v1, toxic::Mesh::triangle::m_v2, sheep::Vector3::Normalized(), and triangle_vector_it.

Referenced by Finalize().

const sheep::AABB3 & Mesh::GetAABB  )  const [inline, virtual]
 

Returns the Axis Aligned Bounding Box of this object. The AABB is expressed in world space.

Implements toxic::IBoundedObject.

Definition at line 216 of file mesh.h.

bool Mesh::Intersect const Context context,
const Ray ray,
Hit hit = 0
const [virtual]
 

This method returns true if the ray intersect the object, or false otherwise. If 'hit' is not null, intersection data are reported through the 'hit' parameter (only if an intersection has been found; if no intersection has been found, the 'hit' parameter is left unchanged). The ray is expressed in world space.

Todo:
Interpolate vertex normals using spherical interpolation.

Hack...

Interpolate normals with a spherical interpolation.

Hack...

Parameters:
ray  'ray' is expressed in world space.

Implements toxic::IObject.

Definition at line 170 of file mesh.cpp.

References toxic::Ray::GetType(), toxic::intersect_triangle(), toxic::Hit::m_abscissa, toxic::Ray::m_direction, toxic::Mesh::octree_test_visitor::m_found, toxic::Mesh::triangle::m_geometric_normal, toxic::Hit::m_geometric_normal, toxic::Statistics::m_intersections_found, toxic::Mesh::triangle::m_n0, toxic::Mesh::triangle::m_n1, toxic::Mesh::triangle::m_n2, m_normals, toxic::Hit::m_object, toxic::Ray::m_origin, toxic::Hit::m_shading_normal, toxic::Context::m_statistics, toxic::Mesh::octree_full_visitor::m_t, toxic::Mesh::triangle::m_t0, toxic::Mesh::triangle::m_t1, toxic::Mesh::triangle::m_t2, toxic::Statistics::m_tested_intersections, m_texcoords, toxic::Mesh::octree_full_visitor::m_triangle, m_triangles, toxic::Hit::m_u, toxic::Mesh::octree_full_visitor::m_u, toxic::Hit::m_v, toxic::Mesh::octree_full_visitor::m_v, max(), sheep::Octree< Item >::Trace(), and triangle_vector_const_it.

void Mesh::SetTriangleNormals FeatureId  tri,
FeatureId  n0,
FeatureId  n1,
FeatureId  n2
 

Definition at line 86 of file mesh.cpp.

References FeatureId, and m_triangles.

void Mesh::SetTriangleTexCoords FeatureId  tri,
FeatureId  t0,
FeatureId  t1,
FeatureId  t2
 

Definition at line 94 of file mesh.cpp.

References FeatureId, and m_triangles.


Friends And Related Function Documentation

friend class MeshBuilder [friend]
 

Definition at line 52 of file mesh.h.


Member Data Documentation

sheep::AABB3 toxic::Mesh::m_aabb [private]
 

Bounding box of the object, expressed in world space.

Definition at line 188 of file mesh.h.

normal_vector toxic::Mesh::m_normals [private]
 

Definition at line 182 of file mesh.h.

Referenced by Annotate(), AppendNormal(), finalize_geometry(), and Intersect().

octree* toxic::Mesh::m_octree [private]
 

Used only if the mesh contains enough triangles.

Definition at line 186 of file mesh.h.

texcoord_vector toxic::Mesh::m_texcoords [private]
 

Definition at line 183 of file mesh.h.

Referenced by AppendTexCoord(), finalize_geometry(), and Intersect().

triangle_vector toxic::Mesh::m_triangles [private]
 

Definition at line 184 of file mesh.h.

Referenced by Annotate(), AppendTriangle(), Finalize(), finalize_geometry(), Intersect(), SetTriangleNormals(), and SetTriangleTexCoords().

vertex_vector toxic::Mesh::m_vertices [private]
 

Definition at line 181 of file mesh.h.


The documentation for this class was generated from the following files:
Generated on Tue May 11 01:31:57 2004 for toxic by doxygen 1.3.6