   Tangent space calculation
  I'm implementing tangent space calculation using the code fromhttp://www.terathon.com/code/tangent.htmlHowever, for example, when applying the function to a cube, every tangent vector is (0,0,0). I found that this is because of this linetangent[a] = (t - n * Dot(n, t)).Normalize();The tangent vector is perpendicular to the normal vector, and the dot product of both is zero, this nullifies all tangents in the mesh. Also for more complex meshes this also happens (but only for some triangles).Help?   
Quote:tangent[a] = (t - n * Dot(n, t)).Normalize();The tangent vector is perpendicular to the normal vector, and the dot product of both is zero, this nullifies all tangents in the mesh.Are you sure?  If n and t are orthogonal then (n * Dot(n, t)) is 0, and you get:(t - 0).Normalize() = t.Normalize() which should not be 0 unless t was 0 to begin with (which would be a bug somewhere else).All that code does is orthogonalize n and t in case they aren't already orthogonal.   ;  Ahh, thank you, I found the problem thanks to you.I was messing up the order of the operations, doing the subtraction before the dot product!   