• ### Popular Now

• 10
• 12
• 12
• 14
• 16

#### Archived

This topic is now archived and is closed to further replies.

# Quick matrix transformation question

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

## Recommended Posts

I have a bunch of coplanar points in world space. I also have two orthogonal vectors that specify texture space (U and V). I can easily generate a third mutually orthogonal vector W if I have to. My question is how to generate the transformation matrix that will transform the points in world space to points in texture space. I could always do something similar "the long way", involving generating a plane perpendicular to each of U, V, and W and taking the dot product of each point to get the coordinates, but I''d much rather do it the "proper" way.

##### Share on other sites
hmm. suppose you have the matrix with column vectors u,v, and w,
this matrix transforms texture points (Tu,Tv,0) to the world x,y,z values.
Just invert that matrix, and you can go from world x,y,z, to texture Tu,Tv
Of course, this is a linear transform. Add an offset if you need a specific origin.

##### Share on other sites
Great. So if I have this matrix:
| Ux Vx Wx 0 || Uy Vy Wy 0 || Uz Vz Wz 0 || 0  0  0  1 |

Which goes from texture space to world space, I just invert it, and that's my world space to texture space matrix. I guess that makes sense, the matrix multiplication mimicks the dot product operation I would have done otherwise.

Awesome - o

[edited by - Zipster on June 8, 2004 12:12:49 PM]

##### Share on other sites
yep, look into basis matrices, and transforming vectors to and from different basis matrices, if you want to know more.

##### Share on other sites
As it turns out, the map tool formats the UV vectors in such a way that I don''t have to invert the matrix.

However, I''m having some problems in another area that I hope you guys could help me with. I needed to enable wrap texture addressing mode so that my textures could tile across polygons. The problem is that if the texture dimensions aren''t powers of two, Direct3D freaks out and falls back on clamping. This is very bad, since most of the textures aren''t powers of two.

Is there any way around this?