i think i know what i am doing wrong.
vertex should have as much normals as the faces he is part of.
so everytime you draw a face you will have to put the normals that are related to that face.
example to calculat the normals if for face 1: i do
v_normal = face1Normal.
start testing neighbours
and for face 2 i do:
v_normal = face2Normal
start testing neioubours
and so on....
but what is the definition of neighbours faces?
3DS and normals
any face that share the vertex in question.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
if someone here is intrested the result code of our conversation is:
if you found any bug in my code please report to me by email
or by typing it here
Regards
BlackRyder
void Object::computeBlendedNormals(void){ unsigned int faceNum; //Holds the current face num Vector3D normal; //Holds the current vertex blended normal. Vector3D faceNormal; //Holds the current face normal unsigned int i; //Loop index Face face; //Holds the current face. for(faceNum=0;faceNum<face_list.size();faceNum++) { face = face_list[faceNum]; faceNormal = computeFaceNormal(face); //compute for every vertex in the face its blended normal for(i=0;i<3;i++) { normal = computeVertexBlendedNormal(face,faceNormal); face.setNormal(i,normal); } face_list[faceNum]=face; }}Vector3D Object::computeVertexBlendedNormal(unsigned int vertexNum,Vector3D &vNormal){ Face face; //Holds the current tested faces unsigned int faceNum; //Holds the current face number that we test. Vector3D faceNormal; //Holds the current face normal Vector3D blendNormal; //Holds the result blended normal for(faceNum=0;faceNum<face_list.size();faceNum++) { face = face_list.at(faceNum); //if this is a neighbor face if((face[0]==vertexNum)||(face[1]==vertexNum)||(face[2]==vertexNum)) { faceNormal = computeFaceNormal(face); if(vNormal.dotProduct(faceNormal)>=0.71) { blendNormal = vNormal+faceNormal; } } } blendNormal = blendNormal - vNormal; //we added twice the normal of the vertex blendNormal.normalize(); return blendNormal;}
if you found any bug in my code please report to me by email
or by typing it here
Regards
BlackRyder
The 3DS format does some interesting things, when exporting to it, it will frequently take 2 faces that share a vertex and make 2 instances of that vertex. This means if you normalize the combined normals, you wont get 1 nice smooth vertex normals, but 2 (or more) vertices in the same location with different normals.
I would advise not to use this format if you want smoothed/blended normals for shared verts (i'm currently in the transition of chaning formats myself).
I would advise not to use this format if you want smoothed/blended normals for shared verts (i'm currently in the transition of chaning formats myself).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement