Can you teach me transform??:D

Started by
3 comments, last by remigius 18 years, 2 months ago
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?
Advertisement
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.
Sirob Yes.» - status: Work-O-Rama.
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 matrixobject space --> view space: view matrixview 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

thanks a lot...
If you need more information on the concepts behind the tranform matrices, this reply might be of help. It's in C#, but the concepts are the same.

Hope this helps
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement