for( int i = 0; i < m_iNumFaces; i++ )
{
CVector normal = m_pFaceNorms[ m_pFaces[i].fn_index ];
for( int j = 0; j < m_pFaces[i].num_vertices; j++ )
{
m_pFaces[i].n_indices[j] = m_pFaces[i].v_indices[j];
m_pNormals[ m_pFaces[i].n_indices[j] ] += normal;
m_pNormals[ m_pFaces[i].n_indices[j] ].Normalize();
}
}
// m_pFaceNorms[ m_pFaces.fn_index ] is the normal of the face .
</font>
</pre><!–ENDSCRIPT–>
This method works well except when I have 2 normals in the same direction but in opposite sense (!? I hope it's how we say that in english). So when adding them I got a null vector :/ and when normalizing I got an infinite vector <img src="sad.gif" width=15 height=15 align=middle>
v1: v2:
<——- ——->
v3 = v1 + v2 = 0
v3.Normalize() :
x/0 = infinite
y/0 = infinite
z/0 = infinite
=> v3 is infinite :/
I've got better illustrations :
<img src="http://tfclan.halflifexpert.com/dolphins_flat_normals.gif">
Facet normals. In red : two normals which are going to raise problem…
<img src="http://tfclan.halflifexpert.com/dolphins_smooth_normals.gif">
Vertex normals. In red : the *infinite* normal
I hope that it is understandable. thanks.
<SPAN CLASS=editedby>[edited by - V3rt3x on July 19, 2003 6:44:58 AM]</SPAN>
What to do with my bad normal?
I'm calculating vertex normals of my models making an interpolation between the current normal of the vertex and the normal of the current face I'm parsing like that :
you can use the edge directions of the edges connected to the vertex.
for vertex normals, it would be better if you normalise only at the end, when all the normals of the faces conencted to a vertex have been accumulated.
for bad normals, you do the same and acumulate the edge directions (normalised before hand) into the normal vector, and then when all the edges directions have been added, normalise teh vetex normal.
for vertex normals, it would be better if you normalise only at the end, when all the normals of the faces conencted to a vertex have been accumulated.
for bad normals, you do the same and acumulate the edge directions (normalised before hand) into the normal vector, and then when all the edges directions have been added, normalise teh vetex normal.
Everything is better with Metal.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement