I have an application where the user drives a car on a network of roads in a 3D environment which can sometimes stretch over several kilometers. At the start of a simulation, the camera is attached to a 3D model of the vehicle the user is driving in, and the camera is positioned such that the user looks through the front window from behind the steering wheel. Screens on the left and right have the cameras positioned such that the out of the window view is to left and to right. This is the code for the forward view :
base.camera.reparentTo( self.MainTarget.MainCarModel )
base.camera.setPos(self.dlat, self.dlon, self.height)
So this is done only once.
During the simulation, the 3D model of the vehicle is moved by updating the position and angles (heading etc) each frame:
self.MainTarget.MainCarModel.setPosHpr( x, y, z, h, p, r )
This works fine, however, when the vehicle is at a large distance (more than 5 km) from the origin [0,0] the model is shaking, first a little bit and hardly noticable, but the shaking becomes worse as the distance from the origin increases. The out of the window environment is moving very smoothly, and framerate is always 60 Hz. Only the model of the vehicle the user is sitting in is shaking, and this seems to be clearly related to the distance from the origin.
Does anyone have an idea what could be the cause of this? Maybe something to do with rounding errors?