# tri tri intersect with uv coordinates

4 replies to this topic

### #1rouncer

Senior Member

• Members
• 2725 posts

Posted 22 June 2010 - 02:25 PM

Ive been constantly lurking the site, but havent been posting much lately, but now I've got another important question!

Im getting geometric boolean objects working at the moment right, but then I suddenly decided I needed to preserve 2 objects with full uv intersecting with each other. :)

Ive nearly got it all done, right, but im stuck sorta at the beginning with this part I left till last, I need a tri tri intersect that describes not only the 2 intersection points, but uv coordinates for the 2 intersection points also.

At the moment, my system is using a battery of ray tri intersects to intersect the edges of triangle a with triangle b and vice versa and its working, but now I need uv coordinates for the two intersection points.

Is there some simple method for doing this, is all im asking, any help would be nice. When I figure it out I'll close the thread with a result.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #2rouncer

Senior Member

• Members
• 2725 posts

Posted 22 June 2010 - 02:30 PM

Heres an example of a nice tri tri (probably faster than my implementation out of ray tri's by a long shot) http://jgt.akpeters....r97/tritri.html but it has no uv calculation, so its no good to me.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #3.oisyn

DevMaster Staff

• Moderators
• 1842 posts

Posted 22 June 2010 - 04:11 PM

Oh that's easy. Calculate the barycentric coordinates for the intersection points at both triangles, and then you can simply evaluate the uv's at those positions. For example, if (a, b, c) are the barycentric coordinates for one of the intersection points of triangle A, then the u at that position is a*v[0].u + b*v[1].u + c*v[2].u. Same for the v.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

### #4rouncer

Senior Member

• Members
• 2725 posts

Posted 22 June 2010 - 05:15 PM

Thats not the first time ive ever heard barycentric coordinates mentioned, but I unfortunately didnt learn it. :(

So off I go on the net "barycentric coordinates"... thanks .oisyn, if only I had you as a next door neighbour then you could come over and finish my project for me. hehe.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

### #5rouncer

Senior Member

• Members
• 2725 posts

Posted 23 June 2010 - 10:11 AM

I read up baricentric coordinates but it blew my mind, went right over my head.

But ive got a solution, I rotate the triangle so its parallel to the camera then I spin it so edge 0 is totally vertical, then I do a line intersection using the edge 1 ray direction and measure the distances along the lines where it intersects.

I then have a weight for both edges then I use the uv's of edge 0 and edge 1 to produce the uv coordinate.

I bet thats something to do with baricentrics anyway, even though I couldnt say it came from what I read at all, it just totally blew me out of the water.

Thankyou.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users