pi3d / pi3d_demos

Demos and support files for pi3d (3D graphics python package for the raspberry pi)
Other
71 stars 33 forks source link

the world gradually tilts sideways in ForestWalk demo #8

Closed chris2560 closed 5 years ago

chris2560 commented 5 years ago

The world will gradually rotate to one side or the other. This is fixed by setting the camera 'absolute' argument to True, and adding to the previous rot and tilt variables each iteration.

line 116: CAMERA = pi3d.Camera(absolute=True) line 154: rot += - mx * 0.2 line 155: tilt += my * 0.2

paddywwoof commented 5 years ago

@chris-bunting yes, it's rather annoying if you use the demo with a mouse but it makes sense if the mx and my signals are coming from accelerometers measuring head movement such as with a VR display. The relative movement is explained a bit at the top of the program, but probably not very well. The logical thing, if changing to absolute is

  CAMERA = pi3d.Camera(absolute=True) # c.f. False
...
    mx, my = mymouse.position() # c.f. velocity()

rather than make rot and tilt += This is the way the camera is controlled in most of the first person demos