0

I'm trying to do a first cam person using OPENGL. But here's my problem. Let me introduce you my code. First of all, I have this function that allows me to get the mouse X and Y position:

case WM_MOUSEMOVE:
    CameraManager.oldMouseX = CameraManager.mouseX;
    CameraManager.oldMouseY = CameraManager.mouseY;

    CameraManager.mouseX = GET_X_LPARAM(lParam);
    CameraManager.mouseY = GET_Y_LPARAM(lParam);

    mousePoint.x = CameraManager.mouseX - CameraManager.oldMouseX;
    mousePoint.y = CameraManager.mouseY - CameraManager.oldMouseY;
    mousePoint.z = 0.f;

    CameraManager.lookAt(mousePoint);

    App.onRender();
    break;

Here I get the difference between the old mouse position and the new one (just because I want to know when I have to increase/decrease the angle). Then, I call the lookAt function on my CameraManager.

Here I do the following:

    if (point.x > 0.f) {
    camAngle.x -= 0.3f;
}
else if (point.x < 0.f) {
    camAngle.x += 0.3f ;
}

float radiansX = MathUtils::CalculateRadians(camAngle.x);

//eye.x = sinf(radiansX);
//center.x += sinf(radiansX);
//center.z += (-cosf(radiansX));
Update();

And then my update does:

    glLoadIdentity();
gluLookAt(eye.x, eye.y, eye.z,
    center.x, center.y, center.z,
    up.x, up.y, up.z);

I've read a lot of stuff on how to refresh the eye and center, but I couldn't get anything to work.

Any advices?

genpfault
  • 51,148
  • 11
  • 85
  • 139
James
  • 95
  • 1
  • 9
  • So what's the problem? What do you see when you debug your code? – UnholySheep Jun 27 '17 at 14:58
  • @UnholySheep the problem is that I don't know how to change my eye(x,y,z) and center(x,y,z) variables to follow my mouse while it's moving. – James Jun 27 '17 at 15:03

0 Answers0