Jump to content
  • Advertisement
Sign in to follow this  
DumpAlien

OpenGL Really confuzed with Direct3D 10 transformations

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

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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!