Sign in to follow this  
DumpAlien

OpenGL Really confuzed with Direct3D 10 transformations

Recommended Posts

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 :/

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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