how to fix a point in the view by moving the camera?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
dujimache
Posts: 24
Joined: Mon Aug 03, 2009 3:22 am

how to fix a point in the view by moving the camera?

Post by dujimache »

i want to make the leftup corner of the grid stay at the (40,30) pixcel on the screen all the time,first,the camera is above the rightdown corner.so,when i move close to the grid,i have to move the camera to left and up. and set the camera's target renewedly,i use method as below:

Code: Select all

//xCamDist X offset
//zCamDist Z offset
f32 zCamDist = (tan((lookDownCamera->getFOV()/2.0))*(cameraDistanceOld - leftCameraDistance));
f32 xCamDist = zCamDist * lookDownCamera->getAspectRatio() ;
cameraXPos -= xCamDist;
cameraZPos += zCamDist;
lookDownCamera->setPosition(core::vector3df(cameraXPos,leftCameraDistance,cameraZPos));
lookDownCamera->setTarget(core::vector3df(cameraXPos,0,cameraZPos));
this is what bitplane tell me what to do,thanks bitplane,though i think it's right,but the display is wrong. the whole codes are in
http://pastebin.com/m566aee66
can somebody give me some advise??
Post Reply