All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SurgSim::Graphics::TriangleNormalGenerator Class Reference

Triangle index functor which calculates normals for the vertices of a geometry, use createNormalGenerator to instantiate this. More...

#include <SurgSim/Graphics/TriangleNormalGenerator.h>

Public Member Functions

void set (osg::Vec3Array *vertexArray, osg::Vec3Array *normalArray)
 Sets the arrays required to generate normals. More...
 
void normalize ()
 Normalizes the calculated normals, this needs to be called after the pass to normalize all the normals Due to the osg way this object is called there is no real good way of having this called automatically. More...
 
void reset ()
 Resets all calculated normals to 0. More...
 
void operator() (size_t vertexIndex1, size_t vertexIndex2, size_t vertexIndex3)
 Calculates the triangle normal and adds it to each adjacent vertex normal. More...
 

Protected Member Functions

 TriangleNormalGenerator ()
 Constructor. More...
 

Private Attributes

osg::ref_ptr< osg::Vec3Array > m_vertexArray
 Array containing vertex positions. More...
 
osg::ref_ptr< osg::Vec3Array > m_normalArray
 Array storing calculated normals. More...
 
size_t m_size
 Size of vertex and normal array. More...
 

Detailed Description

Triangle index functor which calculates normals for the vertices of a geometry, use createNormalGenerator to instantiate this.

Constructor & Destructor Documentation

SurgSim::Graphics::TriangleNormalGenerator::TriangleNormalGenerator ( )
protected

Constructor.

Member Function Documentation

void SurgSim::Graphics::TriangleNormalGenerator::normalize ( )

Normalizes the calculated normals, this needs to be called after the pass to normalize all the normals Due to the osg way this object is called there is no real good way of having this called automatically.

void SurgSim::Graphics::TriangleNormalGenerator::operator() ( size_t  vertexIndex1,
size_t  vertexIndex2,
size_t  vertexIndex3 
)

Calculates the triangle normal and adds it to each adjacent vertex normal.

Parameters
vertexIndex1First triangle vertex index
vertexIndex2Second triangle vertex index
vertexIndex3Third triangle vertex index
void SurgSim::Graphics::TriangleNormalGenerator::reset ( )

Resets all calculated normals to 0.

void SurgSim::Graphics::TriangleNormalGenerator::set ( osg::Vec3Array *  vertexArray,
osg::Vec3Array *  normalArray 
)

Sets the arrays required to generate normals.

Precondition
vertexArray and normalArray, need to have the same number of entries and not be nullptr
Parameters
vertexArrayArray containing vertex positions
normalArrayArray to store calculated normals

Member Data Documentation

osg::ref_ptr<osg::Vec3Array> SurgSim::Graphics::TriangleNormalGenerator::m_normalArray
private

Array storing calculated normals.

size_t SurgSim::Graphics::TriangleNormalGenerator::m_size
private

Size of vertex and normal array.

osg::ref_ptr<osg::Vec3Array> SurgSim::Graphics::TriangleNormalGenerator::m_vertexArray
private

Array containing vertex positions.


The documentation for this class was generated from the following files: