I need to be able to have a camera go about YAW, PITCH and ROLL viewing rotations. The code I have below deals with YAW and PITCH perfectly, but roll is far more difficult. I understand that the rotation needs to be described as a rotation that is rotated by the YAW and PITCH, and so forms a circle perpendicular to the direction faced.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
gluLookAt(
///This one handles the actual viewer position:
x, y, z,
///This one handles viewer direction - Yaw and Pitch
x+
(sin(YAW / 180 * PI)) * cos(PITCH / 180 * PI)
, ///-------------------------------------
y+
sin(PITCH / 180 * PI)
, ///-------------------------------------
z+
(cos(YAW / 180 * PI)) * cos(PITCH / 180 * PI)
,
0,
cos(PITCH / 180 * PI),
0
);
|
How do I go about roll? I also have this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
gluLookAt(
x, y, z,
x+
(sin(YAW / 180 * PI)) * cos(PITCH / 180 * PI)
, ///-------------------------------------
y+
sin(PITCH / 180 * PI)
, ///-------------------------------------
z+
(cos(YAW / 180 * PI)) * cos(PITCH / 180 * PI)
,
cos(YAW / 180 * PI) * sin(ROLL / 180 * PI),
cos(PITCH / 180 * PI),
sin(YAW / 180 * PI) * sin(ROLL / 180 * PI)
);
|
Which very vaguely handles roll, but when I try to combine YAW, PITCH and ROLL at the same time, it becomes unusable. I know it involves XYZup, but I do not really know how to progress, I have tried many different combinations, most of which have been me thinking about the problem, but the latest ones have been guesses.
I really, really need help. I have to do this, I am 15 and need to have a working flight simulator by the end of next summer. Please could the solution keep to trig, I do not understand matrix notation and do not believe I have time to learn it. Is there an alternative to gluLookAt()? would glRotate do anything? I do not know what I need any more, and with all my other problems this is weighing me down.
I appreciate any help