   Calculate binormals and tangents for mesh?
  Could anyone tell me if this functions seems right?For use in GLSL should I calculate per vertex or are they all the same?void CSurface::UpdateBTN(){this->face_binormal = new float[tris_count*3*3];this->face_normal = new float[tris_count*3*3];this->face_tangent = new float[tris_count*3*3];for(int i=0;i<this->tris_count;i++){UINT v0 = tris[i*3+0];UINT v1 = tris[i*3+1];UINT v2 = tris[i*3+2];CVector3 vec1 = CVector3(vert_coords[v0*3],vert_coords[v0*3+1],vert_coords[v0*3+2]);CVector3 vec2 = CVector3(vert_coords[v1*3],vert_coords[v1*3+1],vert_coords[v1*3+2]);CVector3 vec3 = CVector3(vert_coords[v2*3],vert_coords[v2*3+1],vert_coords[v2*3+2]);CVector2 tex1 = CVector2(vert_tex_coords[v0*2],vert_tex_coords[v0*2+1]);CVector2 tex2 = CVector2(vert_tex_coords[v1*2],vert_tex_coords[v1*2+1]);CVector2 tex3 = CVector2(vert_tex_coords[v2*2],vert_tex_coords[v2*2+1]);CVector2 tex21 = tex2 - tex1;CVector2 tex31 = tex3 - tex1;CVector3 vec21 = vec2-vec1;CVector3 vec31 = vec3-vec1;CVector3 tangent = vec21*tex31.y-vec31*tex21.y;tangent.normalize();CVector3 binormal = vec31*tex21.x-vec21*tex31.x;binormal.normalize();CVector3 normal = tangent.cross(binormal);CVector3 temp1 = normal*normal.dot(tangent);tangent -=normal*normal.dot(tangent);tangent.normalize();bool rightHanded = tangent.cross(binormal).dot(normal) >=0;if(!rightHanded)binormal*=-1;this->SetVertexBinormal(v0,binormal.x,binormal.y,binormal.z);this->SetVertexBinormal(v1,binormal.x,binormal.y,binormal.z);this->SetVertexBinormal(v1,binormal.x,binormal.y,binormal.z);this->SetVertexTangent(v0,tangent.x,tangent.y,tangent.z);this->SetVertexTangent(v1,tangent.x,tangent.y,tangent.z);this->SetVertexTangent(v2,tangent.x,tangent.y,tangent.z);}}
  Well, I don't have time or energy right now (been working 12 hours days for a while...super tired) to review code, but I can point you to a good reference implementation. You could check your own algorithm against this:Eric Lengyel's Tangent Space Calculation