Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CruxMihiAncora

Changing a camera view

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

Okay, this is what I need. I am doing a basic example of displaying a polygon with a texture mapped onto it. Well, I was wondering how I would go about moving the camera. What I want is when the user presses the left arrow for instance, the camera will move to the left but stay focused forward (so it isn''t a rotation around an axis). I know how to get the program to recognize the arrows in my callback function so that isn''t an issue. I just need to know what transformations I need to apply to what matrices in order for this to happen. So you know, I am using the helper functions in d3dx8.lib. Any help would be much appreciated.

Share this post


Link to post
Share on other sites
Advertisement
I don''t know if you already have something like this, but this is what you need to move the camera.

D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView,
&D3DXVECTOR3(0,0,0) //Where the camera is
&D3DXVECTOR3(0,0,5) //What you are looking at
&D3DXVECTOR3(0,1,0));//what direction is up to the camera.
pDirect3DDevice->SetTransform( D3DTS_VIEW, &matView );

Lets say you want the camera to move left, you would to do something like this: (It is greatlty abreviated)


if( moveleft )
{
left -= .1(float);
}

device->BeginScene();
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView,
&D3DXVECTOR3(left,0,0) //Where the camera is
&D3DXVECTOR3(left,0,5) //What you are looking at
&D3DXVECTOR3(0,1,0));//what direction is up to the camera.
pDirect3DDevice->SetTransform( D3DTS_VIEW, &matView );

//Render the rest of the scene

device->EndScene();


Hope this helps

Share this post


Link to post
Share on other sites

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