void calcTangent(VECTOR3D& p0,VECTOR3D& p1,VECTOR3D& p2, VECTOR2D& t0,VECTOR2D& t1,VECTOR2D& t2, VECTOR3D& tangent)
{
VECTOR3D edge1 = p1 - p0;
VECTOR3D edge2 = p2 - p0;
float du1 = t1.x - t0.x;
float du2 = t2.x - t0.x;
float dv1 = t1.y - t0.y;
float dv2 = t2.y - t0.y;
float f = 1.0f / (du1 * dv2 - du2 * dv1);
tangent.x = f * (dv2 * edge1.x - dv1 * edge2.x);
tangent.y = f * (dv2 * edge1.y - dv1 * edge2.y);
tangent.z = f * (dv2 * edge1.z - dv1 * edge2.z);
tangent.Normalize();
}
求三角形切线(转载)
原文:http://www.cnblogs.com/niomaa/p/5132817.html