Flight Sim Jitters Solved (Tentatively)

Blitz3D Forums/Blitz3D Programming/Flight Sim Jitters Solved (Tentatively)

Chroma(Posted 2009) [#1]
Ok, it hit me 2 days ago as I was driving. I had started to write a flight sim in Blitz3D several years ago (anyone remember Luftwaffe Ace or Air War 1946?). I shelved it because of 2 reasons: One, I couldn't get the physics right, and two, because the plane/camera would jitter severely the more distance you got from 0,0,0.

I solved the first problem and finally figured out the correct way to model flight realistically. But without double floats, B3D lacked the mathematical accuracy to do a flight sim.

And now the solution:

The map is placed so that the airfield is at 0,0,0. The aircraft is on the runway and you apply full thrust and take off. You level out at 2000 feet and are cruising along. Your distance from 0,0,0 is steadily increasing. Now, let's say that when your aircraft exceeds the distance of 2500 units from 0,0,0...that the whole world is repositioned so that the aircraft is at 0,0,0 and the world is offset appropriately. This way, the aircraft never exceeds 2500 units from 0,0,0.

I can't wait to get some test code going.

Opinions?


big10p(Posted 2009) [#2]
It's an old trick to move the terrain instead of the player (aircraft, in your case).


Chroma(Posted 2009) [#3]
Hmm...yeah it will work. You just take the last xyz pos and the current xyz pos and set current pos to 0 and previous pos to 0 - (current pos- previous pos). That would allow a seamless transition (not detectable to the human eye or physics simulation).


Chroma(Posted 2009) [#4]
@ big10p: Hmm...wouldn't that make doing the physics like...confusing as hell? I mean...I suppose you could parent everything to a pivot and just move the pivot but then you're moving the pivot to more than 2500 units from zero...wouldn't that cause jitters. Or are you resetting the pivot of the terrain to 0 each cycle?

EDIT: The thought of moving the terrain makes my head hurt severely...


Andy(Posted 2009) [#5]

And now the solution:



This is one way to do it

http://web.archive.org/web/20040814155424/http://www.blitzcoder.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum4&topic=000352


Opinions?



It works very well.


Vorderman(Posted 2009) [#6]
I tried to use a similar technique for my Deathchase game - as you can theoretically drive for as long as you want into an endless field of trees, I needed to be able to reposition the player to near the zero position at regular intervals to avoid loosing precision.

I found this only works (when using rendertweening) if you perform all the reposition movements in a single step just before the CaptureWorld command, to isolate them from the tweening. Even then it was tricky to avoid glitching and judders.

However I subsequently discovered that it was much easier to leave the player permanently at X and Z = 0, and just move all the trees and landscape around instead, repositioning them as required when they go out of range - any judders here are not visible because the tree being repositioned is far away from the player. This is how my final Deathchase code works, and it copes OK with a few hundred tree meshes at 60fps.


Chroma(Posted 2009) [#7]
Hmm...I haven't actually tried applying all the forces to the terrain/objects but it'd be an interesting effort. I'll give it a shot.