-3

I tried many times, but I can't get the result what I want.

my rotation logic is like this.

  1. if mouse move to left or right, then rotate yaw. if mouse moves to up or down, rotate pitch.
  2. Mouse can moves to diagonal direction. so in this case I will get two quarternions. (pitch and yaw)
  3. I don't know how to compose these two quaternions.

when I use just one rotation pitch or yaw, It works like what I want. but if I use two rotations pitch and yaw, the result is something wrong.

I tried many ways to compose quaternions.. but I can't reach the result what I want.

woohyeon
  • 29
  • 6

1 Answers1

0

Implementing 3D cameras is a surprising complex problem. A full discussion is beyond this thread, but there are a few basic types you can look at:

  1. A simple 'look' camera is similar to what you describe. Take a look at this tutorial for an example implementation.

  2. Another common camera is an 'orbit' camera for examining a 3D scene. There's an example implementation on GitHub: OrbitCamera.h / OrbitCamera.cpp.

  3. A "free-fly" camera is another common camera model for moving through a 3D scene. This one is a bit more challenging to get right and tends to use quaternions to avoid gimbal lock and other problems.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81