averaged normals between 2 planes in md2 calculateNormals()

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
trotta
Posts: 5
Joined: Tue Jun 28, 2005 6:24 pm

averaged normals between 2 planes in md2 calculateNormals()

Post by trotta »

in the md2 code of the engine, if calculateNormals is called, it creates a 3dplane for every triangle in the mesh and assigns the indices for that triangle the normal of the plane:
what I've got:
//.....................normal1.....normal2
//................................ \../
//................................. \/
//........................90deg /\90deg
//................................ /..\
//.....................plane1 /.....\ plane2

What I need:
//....................................|normal 1 and 2
//....................................|
//..........................90deg /\90deg
//.................................. /..\
//.......................plane1 /.....\ plane2
would someone know a way to average the normals for a group of indeces comeing from the same vertex? something similar is done in the terrain node code. Any help would be really appreciated.
don_Pedro
Posts: 84
Joined: Fri Jun 10, 2005 1:34 pm
Location: Poland
Contact:

Post by don_Pedro »

Just add them all and then normalize result - normal.normalize();
Post Reply