Archived

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

CruxMihiAncora

Changing a camera view

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