Rav
06-28-2002, 04:45 AM
On a paper on the microsoft developers website, I found a forumula for generating tangentspace that goes like the following (pseudocode-ish):
Vec Vector1 = ( vertex3 - vertex2 )
Vec Vector2 = ( vertex1 - vertex2 )
float delta1 = vertex3.v - vertex2.v
float delta2 = vertex1.v - vertex2.v
Vector1.scale( delta2 );
Vector2.scale( delta1 );
tangentSpaceY.set( Vector1 - Vector2 )
tangentSpaceY.normalize();
tangentSpaceX.Cross3( tangentSpaceY, MainTriangle.normal );
tangentSpaceX.normalize3();
tangentSpaceZ.Cross3( tangentSpaceX, tangentSpaceY );
tangentSpaceZ.normalize();
After this code, tangentSpaceX,Y,Z should contain a matrix of "negative" tangentspace. Anyways, I tried it and it works, however I dont understand the following line:
tangentSpaceY.set( Vector1 - Vector2 )
how does that generate the tangent space vector for Y(or V)
Vec Vector1 = ( vertex3 - vertex2 )
Vec Vector2 = ( vertex1 - vertex2 )
float delta1 = vertex3.v - vertex2.v
float delta2 = vertex1.v - vertex2.v
Vector1.scale( delta2 );
Vector2.scale( delta1 );
tangentSpaceY.set( Vector1 - Vector2 )
tangentSpaceY.normalize();
tangentSpaceX.Cross3( tangentSpaceY, MainTriangle.normal );
tangentSpaceX.normalize3();
tangentSpaceZ.Cross3( tangentSpaceX, tangentSpaceY );
tangentSpaceZ.normalize();
After this code, tangentSpaceX,Y,Z should contain a matrix of "negative" tangentspace. Anyways, I tried it and it works, however I dont understand the following line:
tangentSpaceY.set( Vector1 - Vector2 )
how does that generate the tangent space vector for Y(or V)