Jump to content
  • Advertisement
Sign in to follow this  
jagguy

what does this do ?

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

why do some programs i see use this code in a view matrix, as it appears to work without it. The scaling command is simple enough but 1 and 2 I don't get why you need. D3DXMATRIX T,S; D3DXMatrixScaling(&S, 1.0f, 1.0f, 1.0f); 1) D3DXMatrixIdentity(&T); // ? why use T = T * S; 2)g_pd3dDevice->SetTransform(D3DTS_WORLD, &T); //why use?

Share this post


Link to post
Share on other sites
Advertisement
You mean the world matrix instead of the view?

Anyway, setting ANY transform to the identity matrix guarantees that no transformation actually occurs - what goes in is exactly the same as what comes out.

Thus setting the world transform to identity effectively disables that transformation.

A <1,1,1> scaling matrix is actually the same as the identity matrix, so thats a bit pointless really. I'm not too sure why bother with that either - what is the surrounding code doing (or what is it trying to render?)

hth
Jack

Share this post


Link to post
Share on other sites
hi

ok i forgot about scaling so that's is easy.
I am still confused about why do this. You said it
1) D3DXMatrixIdentity(&T); // ? why use

>Anyway, setting ANY transform to the identity matrix guarantees that no >transformation actually occurs - what goes in is exactly the same as what >comes out.

so why ?

Share this post


Link to post
Share on other sites
Quote:
Original post by jagguy
hi

ok i forgot about scaling so that's is easy.
I am still confused about why do this. You said it
1) D3DXMatrixIdentity(&T); // ? why use

>Anyway, setting ANY transform to the identity matrix guarantees that no >transformation actually occurs - what goes in is exactly the same as what >comes out.

so why ?


You set it to the identity matrix to ensure that all of the following transformations happen to an identity (not empty, but identity!) matrix. You dont want any junk in there from the previous time you used it as this will ruin your current operations.

Andy

Share this post


Link to post
Share on other sites
Quote:
Original post by jagguy
are these world or view tansformations?
I don't know - you tell us [smile] although when discussing the identity matrix it doesn't so much matter where you're using it.

To simplify things you could consider it in terms of multiplying by 1.0:

f(x) = x * 1.0

The returned value will be the same as the input. However, if you were to put a zero in place of the one you'd always get zero back (same as if you had an all-zero matrix).

As for making that call each time (without more detail on your program structure its difficult to say) its exactly as NineYearCycle posted. You should never rely on default values for render-states; thus you always re-configure the device before using it in a particular way.

hth
Jack

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!