zacharycarter / zengine

2D | 3D Game development library
157 stars 13 forks source link

Camera target doesn't match what it was initialized to. #18

Open define-private-public opened 6 years ago

define-private-public commented 6 years ago

From working some more on the Minimal example, I found it a little odd that upon startup my camera was looking down at the floor and I had to move it up to see the red cube. I thought I had the parameters correct to see the cube right when the window opens.

I have the camera initialized with these values:

  camera = Camera(
    position: Vector3(x: 0, y: 2, z: 5),
    target: Vector3(x: 0, y: 1, z: 0),
    up: Vector3(x: 0, y: 1, z: 0),
    fovY: 60
  )

But during the first loop of the game, my console put out these values. that target.y is really off

camera.position=(x: 0.0, y: 2.0, z: 5.0)
camera.target=(x: 0.0, y: -22.90486717224121, z: -20.0)
camera.up=(x: 0.0, y: 1.0, z: -0.0)

When I moved the mouse to focus on the red cube, I checked the values again:

camera.position=(x: 0.0, y: 2.0, z: 5.0)
camera.target=(x: 0.5999425649642944, y: -1.55119252204895, z: -19.99279975891113)
camera.up=(x: 0.0, y: 1.0, z: -0.0)

My suspicion is that maybe the programmatic movement of the mouse (because of First Person Mode) at startup causes that.

Source: https://github.com/define-private-public/zengine/blob/minimal/examples/src/zengine_examples/03_Minimal/main.nim

zacharycarter commented 6 years ago

Working on this now.