Model jittering in front of camera

It seems to me I am getting into floating precision related problems, that I don’t know how to fix. The following test code constructs the node chaser, parents the camera to it, and then moves chaser with a certain velocity. A model is loaded as object node, parented to chaser, scaled and put in front of the camera. If the model is put very near to camera (case == 1 branch), then it quite visibly jitters when run. If it is put much further away (case == 2 branch) and enlarged, such that visual apparence on the screen is the same as in case 1, then there is no jitter any more.

chaser = render.attachNewNode("chaser")
chaser.setPos(0, 0, 4000)
chaser.setHpr(0, 10, 0)
base.camera.reparentTo(chaser)
base.camLens.setNear(0.1)

object = loader.loadModel("sphere1280.egg")
object.reparentTo(chaser)

case = 1
if case == 1:
    object.setScale(0.01)
    object.setPos(0, 0.5, 0)
elif case == 2:
    object.setScale(0.2)
    object.setPos(0, 10.5, 0)

spd = 200.0
vel = render.getRelativeVector(chaser, PM.Vec3(0, spd, 0))
def test_task (task):
    dt = globalClock.getDt()
    chaser.setPos(chaser.getPos() + vel * dt)
    return task.cont
task = taskMgr.add(test_task, "test-task")

Note that initial position of chaser is (0, 0, 4000); if I put that to (0, 0, 0) instead, then the jitter is gone in case 1 as well at first, but starts to appear and increase as chaser moves away from (0, 0, 0). Jitter permanently disappears if HPR of chaser is set to (0, 0, 0). (The full code, including the model: http://caslav.gmxhome.de/misc/test-jitter.tar.gz)

Background: I’m trying to make a 3D airplane cockpit, and when I set all positions and sizes realistically against the full scene (taking 1 scene unit = 1 meter), then the cockpit is jittering. Maybe there is a known best way to do this, instead of making the cockpit a normal part of the full scene?

since your cockpit usualy is always drawn ontop of your landscape you could easily set up a new scene+camera and draw it over (like aspect and render2d). just with your own setup.

havent checked the actual jittering yet.

The problem with putting cockpit in separate scene is that I would have to “simulate” every interaction with the environment that would otherwise be automatic. Like lighting, or positioning of outer airplane elements (as pilot turns head). Of course, if that’s the only way…

I think you will find that in order to achieve a particular visual effect, you will need to simulate all of this stuff anyway. This is the way almost all games do it, because if you relied on physically correct rendering, the look would tend to be unsatisfying.

David

If that’s the case, I’m off to “simulating” :slight_smile: Thanks, folks.