Really confuzed with Direct3D 10 transformations

Started by
1 comment, last by DumpAlien 16 years, 4 months ago
Hello there! I made my first Direct 3D contact some days ago. I am using Direct3D 10 but I am a little confuzed about transformations. I have only program OpenGL in the past and now I am a little confuzed how the transformations for the camera and objects are done using vertex shaders. I have a scene and an object moving arround. Can someone explain me how i will do the transormations to move the camera and the object? The order I will do it using Vertex shaders? Just with words or in with code, pseudocode. I tried to find example on google but i didnt find much :( Thanks for your time and sorry for my noobish questions :/
Advertisement
Have you had a look at the SDK samples? Tutorial 5: 3D Transformation might well be worth checking out.

A lot of the time you'll use the D3DXMatrix***() functions within the application to construct a D3DXMATRIX to send to the VS. The shader itself doesn't need to know what that transformation is.

You'll often see code that concatenates the world/view/proj matrix together before uploading it to the shader. This isn't a requirement, more a common sense optimization.

//Assume that THETA is the angle that you're rotating the camera //around and OBJECT contains the position of the object you're rotating around.D3DXMATRIX mWorld;D3DXMatrixTranslation( &mWorld, OBJECT.x, OBJECT.y, OBJECT.z );D3DXMATRIX mView;D3DXVECTOR3 vLookAt = D3DXVECTOR3( OBJECT.X, OBJECT.y, OBJECT.z );D3DXVECTOR3 vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );D3DXVECTOR3 vLookFrom = D3DXVECTOR3( OBJECT.x + sinf(THETA) * Distance, OBJECT.y, OBJECT.z + cosf(THETA) * Distance );D3DXMatrixLookAtLH( &mView, &vLookFrom, &vLookAt, &vUp );D3DXMATRIX mProj;D3DXMatrixPerspectiveFovLH( &mProj, D3DX_PI / 3.0f, 1.0f, 1.0f, 1000.0f );D3DXMATRIX mWorldViewProj = mWorld * mView * mProj;pMatrixVariable->SetMatrix( &mWorldViewProj );// ... stuff ...pDevice->Draw()


That help?

Jack

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

cool! I start getting it.. I am still a little confuzed but i will try to find some D3D10 Camera source example to understand it completely! thanks man! :D

This topic is closed to new replies.

Advertisement