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

## TriangleNormalGenerator()

SurgSim::Graphics::TriangleNormalGenerator::TriangleNormalGenerator | ( |  | ) |

protected

Constructor.

## Member Function Documentation

## normalize()

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.

## operator()()

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

  vertexIndex1 | First triangle vertex index
  vertexIndex2 | Second triangle vertex index
  vertexIndex3 | Third triangle vertex index

## reset()

void SurgSim::Graphics::TriangleNormalGenerator::reset | ( |  | ) |

Resets all calculated normals to 0.

## set()

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

  vertexArray | Array containing vertex positions
  normalArray | Array to store calculated normals

## Member Data Documentation

## m_normalArray

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

private

Array storing calculated normals.

## m_size

size_t SurgSim::Graphics::TriangleNormalGenerator::m_size

private

Size of vertex and normal array.

## m_vertexArray

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:

- SurgSim/Graphics/TriangleNormalGenerator.h
- SurgSim/Graphics/TriangleNormalGenerator.cpp