Hi All,
So i have a set of four points in 3D Space.
P1 [0, 0, 0]
P2 [128, 0, 0]
P3 [0, 128, 0]
P4 [128, 128, 0]
Which I'm then projecting orthographically to the screen effectively giving me two wireframe triangles in screen space.
I now want to map a texture to this "plane" comprised of the two triangles. So i take my square texture, and using u,v coordinates I can map the texture into these two triangles.
The problem comes when I try to add a z component to the verticies. The resulting triangles in screen space are now somewhat distorted but the texture mapping is completely off.
It seems to me though that since it's just three points, they still form an affine rectangle of some sort and we can represent that rectangle as a matrix in the form:
[a b 0] [c d 0] [tx ty 1]
Can anyone give me some tips, ideas about how to convert three 2D points in screen space into a matrix in the above form?
All the tutorials etc that I've looked up explain a loose theory of texture mapping, and then let OpenGl/DirectX native functions do the actual mapping.
I'm looking for more of a direct approach where given three points, i can map a texure to that triangle using an affine matrix. (Not doing a scanline rendering approach)
Thanks!