Open Inventor Reference
SoNormalBundle Class Reference

Bundle that allows shapes to deal with normals and normal bindings more easily. More...

#include <Inventor/bundles/SoNormalBundle.h>

Inheritance diagram for SoNormalBundle:
SoBundle

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 SbVec3fgetGeneratedNormals () 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 SbVec3fget (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

SoNormalGeneratorgenerator
 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
SoStatestate
 Stores state for any bundle.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SoNormalBundle()

SoNormalBundle::SoNormalBundle ( SoAction action,
bool  forRendering 
)

If this is TRUE, the bundle can be used to send normals to GL.

◆ ~SoNormalBundle()

SoNormalBundle::~SoNormalBundle ( )

Member Function Documentation

◆ beginPolygon()

void SoNormalBundle::beginPolygon ( )
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.

◆ endPolygon()

void SoNormalBundle::endPolygon ( )
inline

Definition at line 109 of file SoNormalBundle.h.

◆ generate()

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.

◆ get()

const SbVec3f & SoNormalBundle::get ( int  index) const
inline

This can be used for primitive generation or during rendering

Definition at line 153 of file SoNormalBundle.h.

◆ getGeneratedNormals()

const SbVec3f * SoNormalBundle::getGeneratedNormals ( ) const
inline

Definition at line 137 of file SoNormalBundle.h.

◆ getNumGeneratedNormals()

int SoNormalBundle::getNumGeneratedNormals ( ) const
inline

Definition at line 139 of file SoNormalBundle.h.

◆ initGenerator()

void SoNormalBundle::initGenerator ( int  initialNum = 100)

(shouldGenerate() does this automatically).

◆ polygonVertex()

void SoNormalBundle::polygonVertex ( const SbVec3f point)
inline

Definition at line 107 of file SoNormalBundle.h.

◆ send()

void SoNormalBundle::send ( int  index) const
inline

Definition at line 156 of file SoNormalBundle.h.

◆ set()

void SoNormalBundle::set ( int32_t  numNormals,
const SbVec3f normals 
)

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)

◆ shouldGenerate()

bool SoNormalBundle::shouldGenerate ( int  numNeeded)

◆ triangle()

void SoNormalBundle::triangle ( const SbVec3f p1,
const SbVec3f p2,
const SbVec3f p3 
)
inline

Definition at line 113 of file SoNormalBundle.h.

Member Data Documentation

◆ generator

SoNormalGenerator* SoNormalBundle::generator

Definition at line 159 of file SoNormalBundle.h.


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