Thread: [TuxKart-devel] Patch for smooth camera motion...
Status: Alpha
Brought to you by:
sjbaker
From: <co...@ys...> - 2000-07-07 10:08:52
Attachments:
patch
|
Here's a patch which makes the camera move much more smoothly. It's not the right solution, but it is simple and to my eye rather better than the current effect. Its against 0.0.2 but applies OK against 0.0.3 too. I guess the right solution is to give the camera its own physics model and collision detection with walls. Sorry the code is ugly, my first language is Fortran. |
From: Steve B. <sjb...@ai...> - 2000-07-13 03:01:29
|
co...@ys... wrote: > Here's a patch which makes the camera move much more smoothly. Thanks! > It's not > the right solution, but it is simple and to my eye rather better than > the current effect. Its against 0.0.2 but applies OK against 0.0.3 too. Do you think the 0.2 and 0.1's here should actually be somehow related to the time delta between frames? > ! steady_cam.xyz[0] = steady_cam.xyz[0] + 0.2f*diff.xyz[0]; > ! steady_cam.xyz[1] = steady_cam.xyz[1] + 0.2f*diff.xyz[1]; > ! steady_cam.xyz[2] = steady_cam.xyz[2] + 0.2f*diff.xyz[2]; > ! steady_cam.hpr[0] = steady_cam.hpr[0] + 0.1f*diff.hpr[0]; > ! steady_cam.hpr[1] = steady_cam.hpr[1] + 0.1f*diff.hpr[1]; > ! steady_cam.hpr[2] = steady_cam.hpr[2] + 0.1f*diff.hpr[2]; It seems like this would look different on a high frame rate machine than on a low rate system. I'll experiment. > I guess the right solution is to give the camera its own physics model > and collision detection with walls. Yes - I agree...someday. :-) -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net |
From: Kevin C. <co...@ys...> - 2000-07-13 10:18:02
|
Steve Baker wrote: > Do you think the 0.2 and 0.1's here should actually be somehow > related to the time delta between frames? > > > ! steady_cam.xyz[0] = steady_cam.xyz[0] + 0.2f*diff.xyz[0]; > > ! steady_cam.xyz[1] = steady_cam.xyz[1] + 0.2f*diff.xyz[1]; > > ! steady_cam.xyz[2] = steady_cam.xyz[2] + 0.2f*diff.xyz[2]; > > ! steady_cam.hpr[0] = steady_cam.hpr[0] + 0.1f*diff.hpr[0]; > > ! steady_cam.hpr[1] = steady_cam.hpr[1] + 0.1f*diff.hpr[1]; > > ! steady_cam.hpr[2] = steady_cam.hpr[2] + 0.1f*diff.hpr[2]; > > It seems like this would look different on a high frame rate machine > than on a low rate system. Oh yes, you are absolutely right. The values either need to be scaled proportionally to the time since the last frame, or there needs to be some sort of time based history mechanism (which I presume is what your cart history does). I initially meant to have a look and see if this routine was driven off a timer or off the frame update, and then didn't get round to it. Also, from the code, it looks like there is the possibility (unimplemented?) of flipping the view between karts. My patch will cause the camera to spin erratically through walls if this happens. Kevin |
From: Steve B. <sjb...@ai...> - 2000-07-14 20:47:58
|
Kevin Cowtan wrote: > > Steve Baker wrote: > > Do you think the 0.2 and 0.1's here should actually be somehow > > related to the time delta between frames? > > > > > ! steady_cam.xyz[0] = steady_cam.xyz[0] + 0.2f*diff.xyz[0]; > > > ! steady_cam.xyz[1] = steady_cam.xyz[1] + 0.2f*diff.xyz[1]; > > > ! steady_cam.xyz[2] = steady_cam.xyz[2] + 0.2f*diff.xyz[2]; > > > ! steady_cam.hpr[0] = steady_cam.hpr[0] + 0.1f*diff.hpr[0]; > > > ! steady_cam.hpr[1] = steady_cam.hpr[1] + 0.1f*diff.hpr[1]; > > > ! steady_cam.hpr[2] = steady_cam.hpr[2] + 0.1f*diff.hpr[2]; > > > > It seems like this would look different on a high frame rate machine > > than on a low rate system. > > Oh yes, you are absolutely right. The values either need to be scaled > proportionally to the time since the last frame, or there needs to be > some sort of time based history mechanism (which I presume is what your > cart history does). Yep - I just need to change those 0.1/0.2 values into <something>*delta_t Those hard-coded numbers seem to look good at ~30Hz frame rate - so <something> should be about 30*0.1 and 30*0.2 or so. > I initially meant to have a look and see if this routine was driven off > a timer or off the frame update, and then didn't get round to it. It's executed once per frame (unless you have a VERY slow PC) and the timer sets delta_t to ensure your speed is not affected by the frame rate. > Also, from the code, it looks like there is the possibility > (unimplemented?) of flipping the view between karts. My patch will cause > the camera to spin erratically through walls if this happens. Actually, it is implemented - page-up and page-down steps through a number of fixed cameras and each of the karts in turn. It's useful when debugging (eg "Gown doesn't seem to be moving anymore - I wonder what went wrong" - I can move the camera to follow her and see why she's driving around in circles or whatever). We should implement that properly and have a 1st person view, a far distant view, a close up view and a view looking backwards or something. It won't be hard to fix your code so that the camera can 'teleport' between views rather than interpolating it's way across half the 'world'. -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net |
From: Steve B. <sjb...@ai...> - 2000-07-13 03:01:32
|
co...@ys... wrote: > > Here's a patch which makes the camera move much more smoothly. It's not > the right solution, but it is simple and to my eye rather better than > the current effect. OK - my son, Oliver, is yelling "Woahhh! Cool!", etc. ...it passes the "Mk I child" test. :-) -- Steve Baker HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sourceforge.net http://tuxaqfh.sourceforge.net http://tuxkart.sourceforge.net http://prettypoly.sourceforge.net |