void render( void )
{
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );
g_pd3dDevice->BeginScene();
D3DXMATRIX mWorld;
D3DXMatrixTranslation( &mWorld, 0.0f, 1.0f, v );
D3DXMatrixRotationY( &mWorld , 2);
g_pd3dDevice->SetTransform( D3DTS_WORLD, &mWorld );
g_pd3dDevice->SetStreamSource( 0, g_pTriangleList_VB, 0, sizeof(Vertex) );
g_pd3dDevice->SetFVF( D3DFVF_MY_VERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 4 );
g_pd3dDevice->EndScene();
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Problom With D3DXMatrixRotationY
hello i got a problom with D3DXMatrixRotationY
before i added the line of it
everything worked fine and i saw what i wanted to see.
now i dont see anything i think i killed the matrix O_o
but thats only becuase i had no idea where to give the Rotation information to.
here is the code:
can anyone tell me whats wrong here?
thanks in advance
Btw how do i make the Code to be in a BOX?
i writed <source> but it doesnt seem to work O_o
The rotation angle is in radians. 2 is almost 180 degrees.
D3DX has a couple of useful functions to convert from radians to degrees and back - D3DXToDegree() and D3DXToRadian() I think, I don't have the SDK with me here.
For source code, use [ source ] and [ /source ].
EDIT: Assuming you want to rotate and translate, you need to create 3 matrices. One to translate, one to rotate, and then one to do both:
Bear in mind that the order of multiplication does matter though, since matrix multiplication isn't communative.
Edit2: What Jack said - D3DXToRadian (singular).
D3DX has a couple of useful functions to convert from radians to degrees and back - D3DXToDegree() and D3DXToRadian() I think, I don't have the SDK with me here.
For source code, use [ source ] and [ /source ].
EDIT: Assuming you want to rotate and translate, you need to create 3 matrices. One to translate, one to rotate, and then one to do both:
D3DXMATRIX mTrans, mRot, mWorld;D3DXMatrixTranslation( &mTrans, 0.0f, 1.0f, v );D3DXMatrixRotationY( &mRot , D3DXToRadian(15.0f));D3DXMatrixMultiply( &mWorld, &mRot , &mTrams);g_pd3dDevice->SetTransform( D3DTS_WORLD, &mWorld );
Bear in mind that the order of multiplication does matter though, since matrix multiplication isn't communative.
Edit2: What Jack said - D3DXToRadian (singular).
Quote:Original post by mc30900You need square brackets instead of angled brackets: [ source ] ... [ /source ]
Btw how do i make the Code to be in a BOX?
i writed <source> but it doesnt seem to work O_o
As for your question, you're requesting a rotation of 2 radians - which is approximately 115 degrees. You might want to use D3DXToRadian() or D3DXToDegree() helper functions.
Also, your call to D3DXMatrixRotationY() is wiping out the results from D3DXMatrixTranslation(); if you want both transforms you want to use a temporary matrix and multiply the intermediary results together.
Also, depending on your vertex format you might be viewing the back-face after the rotation. Try setting D3DRS_CULLMODE to D3DCULL_NONE if you can't see anything.
hth
Jack
yep, i know what are radians...
and 3.14 Radians are 180 degrees :P.
but you sure i did it right?
i think that the Veriable that needs to contain the Translate information now have only the Rotation information.
Can u give another look at it please?
thanks in advance
and 3.14 Radians are 180 degrees :P.
but you sure i did it right?
i think that the Veriable that needs to contain the Translate information now have only the Rotation information.
Can u give another look at it please?
thanks in advance
Quote:Original post by mc30900Take a look at my post (I edited it, probably while you were posting), and the source snippet there.
yep, i know what are radians...
and 3.14 Radians are 180 degrees :P.
but you sure i did it right?
i think that the Veriable that needs to contain the Translate information now have only the Rotation information.
Quote:Original post by Evil Steve
The rotation angle is in radians. 2 is almost 180 degrees.
D3DX has a couple of useful functions to convert from radians to degrees and back - D3DXToDegree() and D3DXToRadian() I think, I don't have the SDK with me here.
For source code, use [ source ] and [ /source ].
EDIT: Assuming you want to rotate and translate, you need to create 3 matrices. One to translate, one to rotate, and then one to do both:
*** Source Snippet Removed ***
Bear in mind that the order of multiplication does matter though, since matrix multiplication isn't communative.
Edit2: What Jack said - D3DXToRadian (singular).
umm i'm not sure i understand what u wrote.
you made 3 Matrices
1 for Translation
1 for Rotation
and the 3rd one is to combine both of them?
p.s Sorry for my bad english
Yup. If you want to translate and rotate, then you need to build a translation matrix, build a rotation matrix, and then build a combined matrix from the translation and rotation combined.
In this case it does the rotation first, then the translation (rot*trans). You could also have the object "swing arond" the origin by going the translation then the rotation.
In this case it does the rotation first, then the translation (rot*trans). You could also have the object "swing arond" the origin by going the translation then the rotation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement