0

I want to be able to view a planet sphere centred 0,0,0 with 10 units radius, 360 degrees and up down by clicking my keyboard buttons. What parameters do I put inside the glulookat() function as? I know the Center XYZ should be 000 but what should eye and up vector be?

void gluLookAt( GLdouble eyeX,
    GLdouble eyeY,
    GLdouble eyeZ,
    GLdouble centerX,
    GLdouble centerY,
    GLdouble centerZ,
    GLdouble upX,
    GLdouble upY,
    GLdouble upZ);
Yakov Galka
  • 70,775
  • 16
  • 139
  • 220
  • 1
    Which way is up? Is it (0,0,1)? If so, then use that for your "up" vector. The "eye" vector is the location of *you* the viewer (your eye). – Wyck Sep 21 '21 at 13:37
  • can you figure out how to calculate the camera position you want? – user253751 Sep 22 '21 at 09:56

1 Answers1

1

Don't use lookAt for this! The amount of trigonometry involved in calculating the eye vector is equivalent to building the view matrix from scratch.

Instead, maintain your camera pitch and yaw, and apply those by a series of translations and rotations:

glTranslatef(0, 0, -radius);
glRotatef(-pitch, 1, 0, 0);
glRotatef(-yaw, 0, 0, 1); // assumes Z is up
Yakov Galka
  • 70,775
  • 16
  • 139
  • 220