eng::VisitorComputeNormals Class Reference

Visitor to compute normal vectors on polygons and vertexs. More...

#include <eng_graph_draw.hh>

Inheritance diagram for eng::VisitorComputeNormals:

eng::Visitor

List of all members.

Public Member Functions

 VisitorComputeNormals (Graph &graph, NormalsNode &normalsNode, const LocalVertexs &localVertexs)
 ~VisitorComputeNormals ()
void Begin (void)
void End (void)

Private Member Functions

template<typename VIXS>
void ComputeAndTotalNormal (const Nix nix, const VIXS &vixs)
void Visit (PolygonNode &node)

Private Attributes

const LocalVertexs & mLocalVertexs
NormalVertexs & mPolygonNormals
NormalVertexs & mVertexNormals


Detailed Description

Visitor to compute normal vectors on polygons and vertexs.

Constructor & Destructor Documentation

eng::VisitorComputeNormals::VisitorComputeNormals ( Graph graph,
NormalsNode normalsNode,
const LocalVertexs &  localVertexs 
)

eng::VisitorComputeNormals::~VisitorComputeNormals (  ) 


Member Function Documentation

void eng::VisitorComputeNormals::Begin ( void   )  [inline]

void eng::VisitorComputeNormals::End ( void   )  [virtual]

Called at end of traversal. mVertexNormals now contains totals of vectors. The final step in averaging normal vectors is to normalize them. A mathematical property of vectors (OpenGL red book) is that adding vectors then normalizing the sum results in a normalized average. Normalize( v1 + v2 + v3 ) = Normalize( (v1 + v2 + v3) / 3.0 )

Reimplemented from eng::Visitor.

template<typename VIXS>
void eng::VisitorComputeNormals::ComputeAndTotalNormal ( const Nix  nix,
const VIXS &  vixs 
) [inline, private]

Compute normal vector on this polygon. Along the way, for the goal of averaging normal vectors of polygons adjacent to a vertex, add this normal vector to a total, to be later divided to produce an average.

A mathematical propery of vectors (OpenGL red book) is that adding vectors then normalizing the sum results in a normalized average. Normalize( v1 + v2 + v3 ) = Normalize( (v1 + v2 + v3) / 3.0 ) VisitorComputeNormals uses this property since it doesn't know how many vectors there will be (divisor unknown).

void eng::VisitorComputeNormals::Visit ( PolygonNode node  )  [inline, private, virtual]

Reimplemented from eng::Visitor.


Member Data Documentation

const LocalVertexs& eng::VisitorComputeNormals::mLocalVertexs [private]

NormalVertexs& eng::VisitorComputeNormals::mPolygonNormals [private]

NormalVertexs& eng::VisitorComputeNormals::mVertexNormals [private]


The documentation for this class was generated from the following files: Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:21 2007