Interpolation fov shifts with adv. cam?
by Kirk Longendyke · in Torque Game Engine · 05/13/2007 (1:36 pm) · 1 replies
For a while now, I've been working with the TrackingCamera rescource, as well as looking into the AdvancedCamera one... both are by and large verry nice implementations, but they lack a lil something: past a certain distance, the cars become so tiny it's hard to make out, so I figured what I'd do is just toss in a quick fov shift based on distance from camera for auto-zooming. What I ended up with only half-worked:
now, rather obviously that'll just pop from one fov to another, so i started looking into interpolating the fov shift. unfortunately, i can't seem to figure out just where the *client* fov is used, rather than the game connection one, aside from a few entries in game.cc, like the following:
(note: post-hack. numbers were alot smaller)
according to GameTSCtrl::processCameraQuery, GameUpdateCameraFov(); gets called, wich uses comparrisons between sCameraFov and sTargetFov for smoothly shifting, but I can't for the life of me seem to be able to trace the relationship between the target fov and the process querie's fov... lil help?
void AdvancedCamera::onCameraScopeQuery(NetConnection *cr, CameraScopeQuery * query) {
if (mPlayerObject)
cr->objectInScope(mPlayerObject);
Point3F objPos;
if (this->getLookAtPos(&objPos))
{
Point3F camPos = this->getPosition();
F32 objDist = mSqrt(mPow(camPos.x-objPos.x,2) + mPow(camPos.y-objPos.y,2) + mPow(camPos.z-objPos.z,2))/2;
F32 fov = 90.0f * (500 - objDist)/500;
GameConnection * con = dynamic_cast<GameConnection*>(cr);
con->setControlCameraFov(fov);
}
Parent::onCameraScopeQuery(cr, query);
}now, rather obviously that'll just pop from one fov to another, so i started looking into interpolating the fov shift. unfortunately, i can't seem to figure out just where the *client* fov is used, rather than the game connection one, aside from a few entries in game.cc, like the following:
const U32 MaxZoomSpeed = 900000; ///< max number of ms to reach target FOV static F32 sConsoleCameraFov = 90.f; ///< updated to camera FOV each frame static F32 sDefaultFov = 90.f; ///< normal FOV static F32 sCameraFov = 90.f; ///< current camera FOV static F32 sTargetFov = 90.f; ///< the desired FOV static F32 sLastCameraUpdateTime = 0; ///< last time camera was updated static S32 sZoomSpeed = 90000; ///< ms per 90deg fov change
(note: post-hack. numbers were alot smaller)
according to GameTSCtrl::processCameraQuery, GameUpdateCameraFov(); gets called, wich uses comparrisons between sCameraFov and sTargetFov for smoothly shifting, but I can't for the life of me seem to be able to trace the relationship between the target fov and the process querie's fov... lil help?
Torque Owner Kirk Longendyke
instead of the query:
void AdvancedCamera::advanceTime(F32 dt) {
Point3F objPos; // Update position based on which mode the camera is in switch (mMode) { case TrackMode : if (this->getLookAtPos(&objPos)) { Point3F camPos = this->getCameraPosition(); F32 objDist = mSqrt(mPow(camPos.x-objPos.x,2) + mPow(camPos.y-objPos.y,2) + mPow(camPos.z-objPos.z,2)); F32 fov = 60.0f * (500 - objDist)/500; if (fov<5) fov=5; GameSetCameraFov(fov); }note also the base fov shift from 90.0f degrees, to 60.0f degrees... oddly, I found this greatly reduces the artifacting mentioned in the rescource...
origional work found: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5471