IDirect3DRMMeshBuilder2::GenerateNormals2
Processes the Direct3DRMMeshBuilder2 object and generates normals for each vertex in a mesh by averaging the face normals for each face that shares the vertex. New normals are generated if the faces sharing a vertex have an angle between them greater than the crease angle.
HRESULT GenerateNormals2(
D3DVALUE dvCreaseAngle,
DWORD dwFlags
);
Parameters
dvCreaseAngle
The least angle in radians that faces can have between them and have a new normal generated.
dwFlags
One of the following values.
D3DRMGENERATENORMALS_PRECOMPACT (dwFlags = 1) - Specifies that the algorithm should attempt to compact mesh vertices before it generates normals. See comments below.
D3DRMGENERATENORMALS_USECREASEANGLE (dwFlags = 2) - Specifies that the dvCreaseAngle parameter should be used. Otherwise, the crease angle is ignored.
Return Values
Returns D3DRM_OK if successful, or an error otherwise. For a list of possible return codes, see Direct3D Retained-Mode Return Values.
Remarks
If you specify the D3DRMGENERATENORMALS_PRECOMPACT flag, the precompact pass searches all the vertices in the mesh and merges any that are the same. This is a good way of compacting a mesh that has been loaded. Some meshes have multiple vertices if they have multiple normals at that vertex. This is not necessary in Direct3D Retained Mode. Specifying this flag is the way to get rid of the multiple vertices.
After compacting, the normals are generated. The edges between faces are examined, and if the angle the faces make at the edge is less than the crease angle, the face normals are averaged to generate the vertex normal. If the angle is greater than the crease angle, a new normal is generated. Note that a new vertex is not generated.