I currently have a triangle, each vertex has a texture coord. Now,I want to put a point anywhere on the face of that triangle, and find its texture point, coresponding to the current ones. Any ideas on how this could be done. Its obvious it must be able to be done in some way, but for the life of me, I cant figure out how.

Linear interpolation.

If you know where the point on the polygon is going to be, just interpolate between the other texture coordinates to find your answer

could you give me a bit more explanation, as to how that is done. I understand interpolation, but not sure how it would be done here.

Google for “barycentric coordinates” and all will become clear.

Find the Barycentric of the point in the triangle.

http://mathworld.wolfram.com/BarycentricCoordinates.html

The compute the texture coordinate as:

P(tex) = t1 * A1(tex) + t2 * A2(tex) + t3 * A3(tex)

Thank you all very much for the info, as soon as I figure out the math behind that equation, I will be good to go. Thankx a bunch.

Ok, im having an issue following the information on that sight that was posted. I am unsure as to how to get t1,t2,t3 (the barycentric coordinates) from the equations they have listed. Maybe i am missing something, anyone mind filling in the blanks?

Here is some code I borrowed from somewhere a long time ago:

(Where point1,point2, and point3 make the triangle, triPoint is the point to get weights for (All passed points are assumed to be non-coplaner. (ie make a valid triangle))

, and planeNormal is the normal of the three points. (could calculate from the points but if you already have it,…))

The result vector equates to:

triPoint = (retVector.x * point1) + (retVector.y * point2) + (retVector.z * point3)

Vector3 GetBaryCentricWeights(const Vector3 & point1,const Vector3 & point2,const Vector3 & point3, const Vector3 &triPoint,const Vector3 &planeNormal)

{

Vector3 edge1,edge2;

Vector3 pVect,tVect,qVect;

Vector3 retVect;

float det,invDet;

//Find the vectors for the two edges sharing point1

edge1 = point2 - point1;

edge2 = point3 - point1;

// Begin calculating determinant

planeNormal.Cross(edge2,pVect);

det = edge1.Dot(pVect);

//If the determinant is close to 0, we cannot proceed so return an empty vector

if(det > -0.000001 && det < 0.000001)

{

return Vector3(0.0f,0.0f,0.0f);

}

//Get the inverse of the determinant

invDet = 1.0f/det;

//Calculate the distance from point1 to to the testing point

tVect = triPoint - point1;

//Calculate the weight for point2

retVect.y = tVect.Dot(pVect) * invDet;

//Calculate the weight for point3

tVect.Cross(edge1,qVect);

retVect.z = planeNormal.Dot(qVect) * invDet;

//Calculate the weight for point1 (all point weights add to 1.0f)

retVect.x = (1.0f - retVect.y) - retVect.z;

//Return the weights

return retVect;

}

[This message has been edited by sqrt[-1] (edited 12-04-2003).]