math & physics
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.
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.com/papers/Moller97/tritri.html but it has no uv calculation, so its no good to me.
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.u + b*v.u + c*v.u. Same for the v.
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.
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.