Jump to content
  • Advertisement
Sign in to follow this  
DevTuts

Reset states of the matrix

This topic is 2785 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 am studying DirectX 9, and I have a doubt:

I apply some transformations in a box, exactly those transformations
	// Setup world matrix
D3DXMATRIXA16 matWorld,matWorld2;

// set the rotation matrix
D3DXMatrixRotationYawPitchRoll(&matWorld2,rotation.x,rotation.y,rotation.z);

D3DXMatrixScaling(&matWorld,scale,scale,scale);

D3DXMatrixMultiply(&matWorld,&matWorld,&matWorld2);

D3DXMatrixTranslation( &matWorld2, vPos.x, vPos.y,vPos.z );

D3DXMatrixMultiply(&matWorld,&matWorld,&matWorld2);

m_pDevice->SetTransform( D3DTS_WORLD, &matWorld );


But the next box receives those changes too, would like to know how to "disable" those changes at the next object, leaving only one object


thanks

Share this post


Link to post
Share on other sites
Advertisement
if you are rendering objects seperately (without data encapsulation) you would do

(Psuedocode)

// object one
RotateMatrix
ScaleMatrix
Transform
Multiply
SetWorldMatrix (SetTransform)
RenderObject
// end of object one rendering
LoadMatrixIdentity(worldMat) => DirectX it's D3DXMatrixIdentity(&matWorld)
// object two
RotateMatrix
ScaleMatrix
Transform
Multiply
SetWorldMatrix (SetTransform)
RenderObject
// end of object two render
.. and so on...

Hope that helps

Share this post


Link to post
Share on other sites
Quote:
Original post by Kazuo5000
if you are rendering objects seperately (without data encapsulation) you would do

(Psuedocode)

// object one
RotateMatrix
ScaleMatrix
Transform
Multiply
SetWorldMatrix (SetTransform)
RenderObject
// end of object one rendering
LoadMatrixIdentity(worldMat) => DirectX it's D3DXMatrixIdentity(&matWorld)
// object two
RotateMatrix
ScaleMatrix
Transform
Multiply
SetWorldMatrix (SetTransform)
RenderObject
// end of object two render
.. and so on...

Hope that helps


I have to use the atrixIdentity?
What does it do exactly?

D3DXMATRIX worldMatrix;
D3DXMatrixIdentity( &worldMatrix );
m_pDevice->SetTransform(D3DTS_WORLD,&world_matrix);


so?

Share this post


Link to post
Share on other sites
The matrix identity for a 4x4 matrix is
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

so, if matrix a is the identity matrix and matrix b is a translation matrix
a * b = b

The when multiplied with the identity it does nothing.

So the identity will 'reset' the world matrix and when used in with the next object it will not be affected by the previous transformations (rotation, scaling etc.)

Use:

// object 1 transformation and rendering here
D3DXMatrixIdentity(&matWorld) // set the world matrix to its identity
m_pDevice->SetTransform(D3DTS_WORLD, &matWorld);
// render 2nd object.

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!