Jump to content
  • Advertisement
Sign in to follow this  
minus4th

World, View, and Projection matrix

This topic is 4996 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

Hi, I'm working my way through a DirectX book and it's being a little contradictory. The book tells me that I need to set the world transformation first then the view transformation, and then the projection transformation before I can render my 3D vertex structures. This is all fine and dandy but in the examples in the book the author sets the projection then the view, and then finally the world transformation??? Is their any particular order you have to set it in? If so which form was right, the book or the example on the CD? Thanks for the help!

Share this post


Link to post
Share on other sites
Advertisement
There is no particular order that you need to set the view, world, and projection matrix. You will need to set the world matrix for every object in your scene. The view matrix may or may not update every frame. You can set this wherever you like so long as it is before rendering. The projection matrix usually has to be set very rarely -- such as on initializing the rendering environment.

Don't confuse this with creating other matricies however, where the order of operations makes a huge difference -- ie. (rotate * translation) is not the same as (translation * rotate)

Share this post


Link to post
Share on other sites
[qoute]Don't confuse this with creating other matricies however, where the order of operations makes a huge difference -- ie. (rotate * translation) is not the same as (translation * rotate)[/quote]

yah, in that case you alwasy want to do scaling and rotation first - before transformation. becuse if you have it rotate before a transformation, the center of an object will be where it was before the transformation, and you will get some messed up results

Share this post


Link to post
Share on other sites
Quote:
Original post by a_metalhead
yah, in that case you alwasy want to do scaling and rotation first - before transformation. becuse if you have it rotate before a transformation, the center of an object will be where it was before the transformation, and you will get some messed up results

Not exactly 'always'. There are cases where is desired to make the translation first and the rotation after. For example, to built a simple planetary system, with the planets initially placed at the origin. Or, as another example, to tranform a character that is not at the origin (you need to translate it to the origin, rotate it and translate it again to the original position).

rjackets meant that the product of matrices is not 'commutative', that is, M1*M2 could be different from M2*M1.

But I understood what you meant [smile]. You are considering the case where the position of model is initially at the origin, and you want to move it like a character's movement. For this case, it is perfect [wink].

Share this post


Link to post
Share on other sites
Thanks!! You all have been a HUGE help :) I'm trying to look into a better book or some good online tutorials as the one I have is not very clear (Programming RPG's with DirectX 2nd edition)

Share this post


Link to post
Share on other sites
This may be no help at all but, i've got a book called:
"Introduction to 3d Game Programming With DirectX 9.0" - By Frank Luna,
Although you should really avoid books with game in the title this book seems really helpful in such areas (and is really a D3D book).

Cheers,
Add

Share this post


Link to post
Share on other sites
It does not matter in which order do you set the D3D view, transform and projection matrices. In hardware, they are always applied in the order
[world] [view] [projection].

So to answer your question: yes order of matrix multiplication is EXTREMELY important. As long as you do not actually EXECUTE the multiplication, you can set them in any order!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!