Sign in to follow this  
d3dnewb

Moving the camera pivot

Recommended Posts

d3dnewb    122
Hi, I hope I can explain this properly.... I am building moving map software for aerial navigation in direct3d. The problem is that the camera focus is the aircraft, and this has to be down the bottom of the screen (say about 1/10th the way up). The camera will defualt to overhead the aircraft pointing down. So I set all this ... and its fine. But the thing is direct3d has the camera centered in the screen and i need it 1/10th the way up and i have no clue how. I have thought of rendering to a larger than screen surface off screen, if this is possible and then cropping the piece I want out and drawing that to screen. But this would use extra of CPU/GPU. Would it be possible to render a certain segment only of the camera view or something like that? I hope this all made sense.

Share this post


Link to post
Share on other sites
Xeile    256
I think I didn't understand you question properly, but this is the way I handle my camera:



D3DXMATRIX View;
D3DXVECTOR3vEyePt, vLookatPt, vUpVec(0.0f, 0.0f, 1.0f); // I use the Z-axis as the up and down axis.

vEyePt = D3DXVECTOR3(
fX + ((fZoom * (float)cos(fAngle[1])) * (float)sin(fAngle[0])),
fY + ((fZoom * (float)cos(fAngle[1])) * (float)cos(fAngle[0])),
fZoom * (float)sin(fAngle[1]));
vLookatPt = D3DXVECTOR3(fX, fY, 0.0f);

D3DXMatrixLookAtLH(&View, &vEyePt, &vLookatPt, &vUpVec);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &View);




Explaination:
fX and fY are global floats that define my look at position. vEyePt is the vector where my camera position is defined. In my situation my Eye is able to move freely in a hemispheric space (this might not be interesting to you, it only explains the trouble with those sin/cos functions), it will always look at the LookAt vector.

The D3DXMATRIX View is a matrix I use to store my vectors in, with the D3DXMatrixLookAtLH function and with SetTransform(D3DTS_VIEW, &View) statement I set that as my view.

In your case the fX and fY could be the coordinates for the plane (you should of course add a fZ).

I hope this helps, if you have any further questions, feel free to ask.

Share this post


Link to post
Share on other sites
d3dnewb    122
You didnt understand me. Say your eye focus's on object X. Then you want that object X 1/10th the way up from the bottom of the screen, and the rest of the screen to contain the foward portion of the cameras view. Kinda like zooming in on the camera view. I was hoping directX would have a way to do this... but since i typed the post ive had second thoughts and may or may not do it cuz it might look un natural, anyways i gotta go start trying stuff out.

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