# 3D, Projecting quad onto triangles or vice versa

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, It's me and my clumsy attempts on a modeller. Last time i got awesome help on cylindrical texture mapping, now i'm in need for simple quad mapping. Basically, i define a texture section (texture and texture coordinates of the subsection) and want to uv map the selected faces to that quad. The quad is freely defined by its four corner points (clumsy, yes). I create a plane from three of the points assuming the quad is completely planar. A) For every vertex i calculate the intersection of the line from the vertex (P1) and vertex plus plane normal (P2) with the plane. This gets me the projected point on the plane. This seems to work fine so far. Now i'm having trouble to transform the intersection point onto the quad (i'd simply need the x and y value to calculate TU and TV). B) I tried an inverse LookAt matrix which was created by the top left corner point and two edges of the quad. C) In the end i should get a point from which i can directly use X and Y (discarding Z) to calculate the position factor from 0 to 1 (or outside) regarding the original quad. It's either B or C where i'm going wrong. The code works if the quad lies on the X-Z plane, but not if the quad is perpendicular to that plane. Could someone give me a hint into the right direction? Please go easy on the maths, i'm not too fluent with vector and matrix math. I'd also be interested in a more elegant method since i probably used a pretty naive approach. Many thanks in advance!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 15
• 11
• 9
• 38
• 16
• ### Forum Statistics

• Total Topics
634128
• Total Posts
3015692
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!