gluLookAt() center vs up?

I have found through a lot of searching and a lot of chance how to properly link GLUT in codeblocks. I feel as though I am grasping it, I have a torus example program that I modifying and can identify some of the processes working.

I have previously been attempting to write my own 3d perspective over the top of SDL using the atan2() function, but the lack of hardware accelerated polygons made this very slow, and working out a depth buffer system would be a great task.

Now I am onto GLUT. My problem is with this function below. As you can see, yaw was easy, requiring the most basic of trig, on only the X and Z values of centerXYZ. Now I need to sort out pitch, the problem lies here. In my understanding, both the centerXYZ and the upXYZ arguments of gluLookAt(). How do I describe the upXYZ required for pitch? Will a simple 90' rotation suffice?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

  gluLookAt(
  ///This one handles the actual viewer position:
  x, y, z,
  ///This one handles viewer direction - Yaw and Pitch
  x + sin(YAW / 180 * PI), y + sin(PITCH / 180 * PI), z + cos(YAW / 180 * PI),
  ///This one handles viewer orientation - Pitch and Roll
  ///The algorithm must eliminate pitch alteration,
  ///as this element appears both in centerXYZ and upXYZ
  0, 1, 0);

/* And the code without the comments:

  gluLookAt(
  x, y, z,
  x + sin(YAW / 180 * PI), y + sin(PITCH / 180 * PI), z + cos(YAW / 180 * PI),
  0, 1, 0);
 */


Next will be roll, which is a rotation within a rotation (PITCH), which is itself a rotation (YAW). But that is another problem and will only require description in upXYZ as it is viewer intrinsic.

I am on a RasPi 3 running Linux. I have about a year to get a flight simulator running as part of a secondary schools competition. Advanced graphics are fortunately not a must.
I have adjusted the code and now am going to have a very, very difficult time with roll.

1
2
3
4
5
6
7
8
9
  gluLookAt(
  ///This one handles the actual viewer position:
  x, y, z,
  ///This one handles viewer direction - Yaw and Pitch
  x + sin(YAW / 180 * PI), y + sin(PITCH / 180 * PI), z + sin(YAW / 180 * PI) + cos(PITCH / 180 * PI),
  ///This one handles viewer orientation - Pitch and Roll
  ///The algorithm must eliminate pitch alteration,
  ///as this element appears both in centerXYZ and upXYZ
  0, y + cos(PITCH / 180 * PI), z + sin(PITCH / 180 * PI));


I think that the rotations are behaving as they should, I can not tell until I have roll sorted, and to know if I have carried out the roll descriptions correctly, I need to know whether I implemented the yaw and pitch rotations correctly!

I will mark this thread as solved and will link to the roll thread, asking for help there.
Please see here for next thread: http://www.cplusplus.com/forum/beginner/195405/

Thankyou, Rob
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/195405/
Topic archived. No new replies allowed.