for this project i am working on, i am having a bit of difficulty with calculating the yaw alongside a camera using the gluLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
function, having the camera follow the helicopter with the yaw just wont work
gluLookAt(cameraPosition[0], cameraPosition[1], cameraPosition[2],
heliLocation[0], heliLocation[1], heliLocation[2],
0, 1.0, 0.0);`
if (keyboardMotion.Yaw != MOTION_NONE) {
/* TEMPLATE: Turn your object right (clockwise) if .Yaw < 0, or left (anticlockwise) if .Yaw > 0 */
heliYaw += keyboardMotion.Yaw * heliYawSpeed * FRAME_TIME_SEC;
cameraPosition[0] = heliYaw;
if (heliYaw > 360) {
heliYaw = 0;
}
else if (heliYaw < -360) {
heliYaw = 0;
}
}
I also have trouble with the camera following forward movement especially if the yaw has been changed as im unsure as to how to calculate the direction of the helicopter, i have tried but cant seem to understand what im doing, so i dont understand what im doing wrong could anyone please explain
if (keyboardMotion.Surge != MOTION_NONE) {
float Rotation = heliYaw * (PI / 180);
/* TEMPLATE: Move your object backward if .Surge < 0, or forward if .Surge > 0 */
heliLocation[2] += keyboardMotion.Surge * moveSpeed * FRAME_TIME_SEC * -1;
//heliLocation[2] += (float)cos(Rotation);
//heliLocation[0] += (float)sin(Rotation);
//heliLocation[0] += (float)cos(heliYaw / (PI * 180.0f)) *keyboardMotion.Surge * moveSpeed * FRAME_TIME_SEC;
//cameraPosition[2] += keyboardMotion.Surge * moveSpeed * FRAME_TIME_SEC;
the commented out areas are just what i thought would work.