so here is some code i stole borrowed from ClothPath for calculating normals
for(int i = 0; i<triangleCount; i++){
i1 = indexBuffer.get();
i2 = indexBuffer.get();
i3 = indexBuffer.get();
BufferUtils.populateFromBuffer(v1, vertexBuffer, i1);
BufferUtils.populateFromBuffer(v2, vertexBuffer, i2);
BufferUtils.populateFromBuffer(v3, vertexBuffer, i3);
getTriangleNormal(v1,v2,v3,norm);
BufferUtils.addInBuffer(norm, normalBuffer, i1);
BufferUtils.addInBuffer(norm, normalBuffer, i2);
BufferUtils.addInBuffer(norm, normalBuffer, i3);
}
//This iteration is here but i shouldn't have to call it... should i??
for(int i = 0; i<getBatch(0).getVertexCount(); i++)
BufferUtils.normalizeVector3(normalBuffer, i);
seems pretty straight forward, get the three vertecies of a triangle, calculate the triangle's normal and whala! you have the normal for the 3 verticies. But here comes the weird part.
getTriangleNormal() stores the normalized unit vector in norm. I checked it, if i add a System.out.println(norm.lengthSquared()); it usually gives a length 1 or something close.... But when i load the scene and check the normals (by pressing 'N' ) they seem to go to infinity... So, i have to make a another inorder to fix it, where i use bufferutils to normalize the enter buffer. But this shouldn't really be needed, should it? What am i doing wrong?