#include <Inventor/SbLinear.h>
#include <Inventor/elements/SoNeighborToleranceElement.h>
#include <Inventor/STL/vector>
#include <Inventor/STL/utility>
Go to the source code of this file.
Functions | |
~SoNormalGenerator () | |
Surface normal generator. | |
void | setupApproxShapeSize (const int32_t approxNumVertices, const int32_t approxNumFaces) |
Resets the approximative number of vertices and faces that we have to generate normals for. | |
void | beginPolygon () |
Send a polygon's worth of vertices. | |
void | polygonVertex (const SbVec3f &point) |
void | endPolygon () |
void | triangle (const SbVec3f &p1, const SbVec3f &p2, const SbVec3f &p3) |
Send a triangle. | |
void | setupIndexedVertexArray (const SbVec3f *pointArray) |
Specifies a pointer to the array of points that will be used in subsequent calls to polygonVertex(index) and triangle(index1,index2,index3). | |
void | setupIndexedConnectivity (const int32_t *connectivityArray) |
Specifies a per-vertex connectivity array. | |
void | polygonVertex (const int32_t pointIndex) |
Send a polygon's worth of vertices using indexed vertices. | |
void | triangle (const int32_t index1, const int32_t index2, const int32_t index3) |
Send a triangle using indexed vertices. | |
void | generate () |
Calculate the normals once all vertices have been sent. | |
int | getNumNormals () const |
Returns number of normals generated. | |
void | setNumNormals (int newNum) |
Truncate the array so there are only the given number of normals. | |
const SbVec3f * | getNormals () const |
Returns a pointer to the array of normals. | |
const SbVec3f & | getNormal (int32_t i) const |
Returns the i'th normal in the array. | |
void | setNormal (int32_t index, const SbVec3f &newNormal) |
Add or modify a normal vector. | |
int32_t | numNormalCrack () const |
Returns the number of connected points that have different normals. | |
void beginPolygon | ( | ) |
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 104 of file SoNormalBundle.h.
void endPolygon | ( | ) |
Definition at line 108 of file SoNormalBundle.h.
void generate | ( | ) |
Calculate the normals once all vertices have been sent.
const SbVec3f & getNormal | ( | int32_t | i | ) | const |
Returns the i'th normal in the array.
NOTE: must be called after generate().
Definition at line 199 of file SoNormalGenerator.h.
const SbVec3f * getNormals | ( | ) | const |
Returns a pointer to the array of normals.
NOTE: must be called after generate().
Definition at line 192 of file SoNormalGenerator.h.
int getNumNormals | ( | ) | const |
Returns number of normals generated.
This will be equal to the number of points sent.
NOTE: must be called after generate().
Definition at line 180 of file SoNormalGenerator.h.
int32_t numNormalCrack | ( | ) | const |
Returns the number of connected points that have different normals.
If 0 then the shape is fully smooth and using indexed normals could be an optimization for the caller.
if -1 this info is not available.
Definition at line 218 of file SoNormalGenerator.h.
void polygonVertex | ( | const int32_t | pointIndex | ) |
Send a polygon's worth of vertices using indexed vertices.
NOTE: must be called after setupIndexedVertexArray().
Definition at line 120 of file SoNormalBundle.h.
void polygonVertex | ( | const SbVec3f & | point | ) |
Definition at line 106 of file SoNormalBundle.h.
void setNormal | ( | int32_t | index, |
const SbVec3f & | newNormal | ||
) |
Add or modify a normal vector.
Some shapes may need to adjust or reorder normals after generation. This method can be used to change a normal. It will insert room in the array if necessary to accommodate the new normal. NOTE: must be called after generate().
void setNumNormals | ( | int | newNum | ) |
Truncate the array so there are only the given number of normals.
NOTE: must be called after generate().
void setupApproxShapeSize | ( | const int32_t | approxNumVertices, |
const int32_t | approxNumFaces | ||
) |
Resets the approximative number of vertices and faces that we have to generate normals for.
These correspond to the same parameters in the constructor, but allows setting them after creation.
Note: Must be called before first call to polygonVertex or triangle calls..
Definition at line 126 of file SoNormalBundle.h.
void setupIndexedConnectivity | ( | const int32_t * | connectivityArray | ) |
Specifies a per-vertex connectivity array.
This array should be dimensioned the number of vertices, and represent a double link list of connectivity for each vertex.
Definition at line 124 of file SoNormalBundle.h.
void setupIndexedVertexArray | ( | const SbVec3f * | pointArray | ) |
Specifies a pointer to the array of points that will be used in subsequent calls to polygonVertex(index) and triangle(index1,index2,index3).
Using this mode allows reusing vertices, avoiding data copy and increasing performance. IMPORTANT NOTE:
Definition at line 118 of file SoNormalBundle.h.
void triangle | ( | const int32_t | index1, |
const int32_t | index2, | ||
const int32_t | index3 | ||
) |
Send a triangle using indexed vertices.
NOTE: must be called after setupIndexedVertexArray().
Definition at line 122 of file SoNormalBundle.h.
Send a triangle.
Definition at line 112 of file SoNormalBundle.h.
~SoNormalGenerator | ( | ) |
Surface normal generator.
This class can be used by polyhedral shape classes to generate surface normals when they do not have valid ones specified. To generate normals, create an instance of this class, then specify each polygon in the shape, then call generate(). After generate() is called, the normals can be accessed from the instance. There will be one normal generated for each vertex of each polygon, in the order passed in.
For convenience, there is a method to send down a triangle of vertices.
For efficiency, a constructor is provided that takes an approximate number of vertices that will be specified. Use this constructor if you know roughly how many vertices will be sent; this will cut down on allocation overhead.
The generate() method takes a crease angle that is used to determine whether to create normals that simulate a sharp crease at an edge between two polygons or to create normals that simulate smooth shading over the edge. The crease angle is the minimum angle (in radians) between the face normals on either side of an edge that will be used to consider the edge a crease. For example, a crease angle of pi/4 radians (45 degrees) means that adjacent face normals must be within 45 degrees of each other for the edge to be shaded smoothly.
NOTE The SoNormalGenerator destructor DOES NOT delete the array of generated normals. The caller is responsible for doing so. This allows the normals to be cached elsewhere without having to copy them. Destructor.