Jump to content
  • Advertisement

Archived

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

Zipster

Quick matrix transformation question

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites
Figured it out again. For anyone who ever has this problem and searches the forums, do not use the device''s StretchRect/StretchRectangle function, it only leads to more problems than it''s worth.

Instead, use StretchBlt from Windows GDI. If you''re using managed code than interop with the function. Textures expose surface levels, which in turn expose graphic objects, which expose HDCs, which you can pass to the function. It works and it''s fast.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!