View Full Version : How to compute texture coordinates?

Hi!

Given a triangle with its vertices and the texture coordinates at each vertex known, is there anyway of finding the texture coordinates of a point on that triangle?

pls help................

DaViper

03-07-2001, 11:26 PM

What do you mean by

texture coordinates of a point on that triangle

if there is a point which falls within this triangle, is it possible to obtain the texture coordinates of this particular point?

DaViper

03-08-2001, 12:47 AM

hmmm ok i think it should be possible,

your 3 triangle vertices are v1,v2,v3, your new point is p and your tex-coordinates are t1,t2,t3 (as glTexCoord2*) and your new tex coord is tp

now you can setup to equations in vector notation

|v1-v2|/|v1-p|=|t1-t2|/|t1-tp|

|v1-v3|/|v1-p|=|t1-t3|/|t1-tp|

with |v1-v2|=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2))

.

.

and

|t1-t2|=sqrt((t1-t2)*(t1-t2)+(s1-s2)*(s1-s2))

with that ist should be possible to solve those equations for your new tex coord.

hope that helps

u want barycentric coordinate i think my friend

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.