c++openglmathrotationglulookat

openGL - Rotating above and below an object using gluLookAt


I have a cube in open GL. I have the cube rotating by multiplying by the rotation matrix. I have also got the camera rotating around the cube on the x axis using gluLookAt as you can see below.

    case 'j':
        eyeX = 10*cos(angle);
        eyeZ = 10*sin(angle);
        centerX = -cos(angle);
        centerZ = -sin(angle);
        angle -= 0.1;
        break;
    case'l':
        eyeX = 10*cos(angle);
        eyeZ = 10*sin(angle);
        centerX = -cos(angle);
        centerZ = -sin(angle);
        angle += 0.1;
        break;

where

gluLookAt( eyeX, eyeY, eyeZ, centerX, centerY, centerZ, 0.0, 1.0, 0.0);

What I am struggling with is getting the camera to rotate above and below the cube circling it on the y axis.


Solution

  • To make the cam orbiting an object