what does this do ?

Started by
4 comments, last by jollyjeffers 17 years, 9 months ago
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?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

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 ?
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

"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"

"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."

are these world or view tansformations?
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement