Open Inventor Reference
This class can be used by polyhedral shape classes to generate surface normals when they do not have valid ones specified. More...
|SoNormalGenerator (SbBool isCCW)|
|Constructors and destructor. |
|SoNormalGenerator (SbBool isCCW, int approxNumVertices)|
|Send a polygon's worth of vertices. |
|void||polygonVertex (const SbVec3f &point)|
|void||triangle (const SbVec3f &p1, const SbVec3f &p2, const SbVec3f &p3)|
|Send a triangle. |
|void||generate (float creaseAngle)|
|Calculate the normals once all vertices have been sent. |
|int||getNumNormals () const|
|The rest of the methods may be called only AFTER generate() has been called: |
|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)|
|Some shapes may need to adjust or reorder normals after generation. |
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 that 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.
Begin a polygon, send as many vertices as you want, and then end the polygon.
|const SbVec3f* SoNormalGenerator::getNormals||(||)|| const
|int SoNormalGenerator::getNumNormals||(||)|| const
|void SoNormalGenerator::polygonVertex||(||const SbVec3f &||point||)|
This method can be used to change a normal. It will insert room in the array if necessary to accommodate the new normal.