Open Inventor Reference
|
Bundle that allows shapes to deal with normals and normal bindings more easily. More...
#include <Inventor/bundles/SoNormalBundle.h>
Public Member Functions | |
SoNormalBundle (SoAction *action, bool forRendering) | |
Constructor - takes the action the bundle is used for and a flag to indicate whether the bundle is being used for rendering. | |
~SoNormalBundle () | |
Destructor. | |
bool | shouldGenerate (int numNeeded) |
Returns TRUE if normals need to be generated. | |
void | initGenerator (int initialNum=100) |
Initializes generation in the case where shouldGenerate() is not called. | |
void | beginPolygon () |
If shouldGenerate() returns TRUE, these methods can be used by shapes to specify the geometry to generate normals for. | |
void | polygonVertex (const SbVec3f &point) |
void | endPolygon () |
void | triangle (const SbVec3f &p1, const SbVec3f &p2, const SbVec3f &p3) |
Send a triangle. | |
void | generate (int startIndex=0, bool addToState=TRUE) |
Calculates the normals once all vertices have been sent. | |
const SbVec3f * | getGeneratedNormals () const |
Returns the generated normals. | |
int | getNumGeneratedNormals () const |
void | set (int32_t numNormals, const SbVec3f *normals) |
This allows shapes that generate their own normals (for efficiency) to store the resulting normals in the state. | |
const SbVec3f & | get (int index) const |
Returns indexed normal. | |
void | send (int index) const |
Sends indexed normal to the GL, for use only during GL rendering. | |
Public Attributes | |
SoNormalGenerator * | generator |
Normal generator. | |
Additional Inherited Members | |
Protected Member Functions inherited from SoBundle | |
SoBundle (SoAction *action) | |
Constructor takes action from whose state bundle is to access elements. | |
~SoBundle () | |
Destructor. | |
Protected Attributes inherited from SoBundle | |
SoState * | state |
Stores state for any bundle. | |
This class provides a fairly simple interface to normal handling, including normal generation.
This class can be used during either rendering or primitive generation. For primitive generation, the get() method can be used to access normals. For GL rendering, the send() method can be used to send normals to GL.
Definition at line 77 of file SoNormalBundle.h.
SoNormalBundle::SoNormalBundle | ( | SoAction * | action, |
bool | forRendering | ||
) |
If this is TRUE, the bundle can be used to send normals to GL.
SoNormalBundle::~SoNormalBundle | ( | ) |
|
inline |
They are front-ends to methods on the SoNormalGenerator class: Send a polygon's worth of vertices. Begin a polygon, send as many vertices as you want, and then end the polygon.
Definition at line 105 of file SoNormalBundle.h.
|
inline |
Definition at line 109 of file SoNormalBundle.h.
void SoNormalBundle::generate | ( | int | startIndex = 0 , |
bool | addToState = TRUE |
||
) |
The normals are stored by the bundle so the caller does not have to deal with them directly. The startIndex argument specifies the index at which the generated normals will begin– it can be used by shapes that allow the coordinates and normals to be offset (non-indexed shapes). If addToState is TRUE, the state will be pushed, the normals will be added to the state; otherwise, you can just use getGeneratedNormals/getNumGeneratedNormals to get the generated normals.
The normal bundle DOES NOT FREE the generated normals! It is expected that normals will be added to a normal cache, and the normal cache will free the normals.
|
inline |
This can be used for primitive generation or during rendering
Definition at line 153 of file SoNormalBundle.h.
|
inline |
Definition at line 137 of file SoNormalBundle.h.
|
inline |
Definition at line 139 of file SoNormalBundle.h.
void SoNormalBundle::initGenerator | ( | int | initialNum = 100 | ) |
(shouldGenerate() does this automatically).
|
inline |
Definition at line 107 of file SoNormalBundle.h.
|
inline |
Definition at line 156 of file SoNormalBundle.h.
The bundle takes care of pushing/popping the state. Note: This method only adds the normals to the state, it does NOT store a pointer to them (so you cannot call the getGenerated() routines)
bool SoNormalBundle::shouldGenerate | ( | int | numNeeded | ) |
Definition at line 113 of file SoNormalBundle.h.
SoNormalGenerator* SoNormalBundle::generator |
Definition at line 159 of file SoNormalBundle.h.