Sign in to follow this  

Can you teach me transform??:D

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

I started directX i have too many questions; 1-)Device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); //is this for see back face of triangle? 2-) D3DXMATRIXA16 matWorld; UINT iTime = timeGetTime() % 1000; FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f; D3DXMatrixRotationY( &matWorld, fAngle ); //this for rotate matrice Device->SetTransform( D3DTS_WORLD, &matWorld ); //what is this?why we used it? 3-) D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f ); //understand D3DXVECTOR3 vLookatPt( 0.0f, -1.0f, 0.0f ); //understand D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); //understand D3DXMATRIXA16 matView; //understand D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); //understand g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );//what is this?why we used it? 4-) D3DXMATRIXA16 matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );//i know this, for perspective setting, but how to use? g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ););//what is this?why we used it? Did you see?I have problems with Transform...What is transform?Why using?

Share this post


Link to post
Share on other sites
1) Yes, that line of code disables back-face culling. What this means is that triangles in all directions are drawn.

2, 3, 4) DirectX uses 3 matrices to determine how to draw. These are the World, View, and Projection matrices. To change one of these, you need to calculate a matrix that does what you want that matrix to do, and then use SetTransform() to set it.

Transform, in this case, means a Transformation Matrix, which is, a matrix that transforms from one space, to another.

In all 3 cases, the line you marked you do not understand is the line in which the matrix is set. That is, in that line, you tell DX which matrix to use World, View, and Projection matrices.

You MUST set all 3 of these matrices in order to get something to draw on-screen.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by gmax
1-)Device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); //is this for see back face of triangle?

Yes, this adjusts the culling mode. DirectX can cull triangles that are facing away from the camera. This is calculated from the order of the three triangle vertices. Setting this to none disables culling all over and renders all triangles. Other options are culling triangles that have their vertices in clockwise or counter-clockwise order (when seen from the current viewpoint).


Quote:

Device->SetTransform( D3DTS_WORLD, &matWorld ); //what is this?why we used it?
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );//what is this?why we used it?
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ););//what is this?why we used it?


DirectX works with explicit transforms. In 3D there are various spaces and transforms indicate how to move from one to the other. In total, an object passes from object space (vertices are relative to origin) to world space to view space to screen space. The transforms are:

world space --> object space: world matrix
object space --> view space: view matrix
view space --> screen space: projection matrix


You can set each of these matrices using SetTransform() and the first parameter indicates the type of transform you set. Without setting the three main transforms, DX has no idea of how to render your scene.

Illco

Share this post


Link to post
Share on other sites

This topic is 4337 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this