I’m trying to get an FPS style camera working, while following along from the examples in the openGL SuperBible book.
It was all going very well until I ran into the problem where you end up having roll happen, when you really only want pitch and yaw.
This question is basically asking the same thing, but I was hoping someone might be able to be a bit more verbose about the implementation, ideally with experience of the SuperBible GLTools framework.
I’ve already tried implementing GluLookAt code which I’ve got to compile, but either I made a mistake when duplicating the functions needed, or I’m passing in the wrong parameters when using it.
I guess I’m finding it a bit confusing as the SuperBible code abstracts a bit of how the camera works, and so I’m finding it hard to implement it correctly. When testing my current version, I’m passing in parameters like this
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera); //returns the matrix of the CameraFrame.
M3DVector3f up = { 0.0f, 1.0f, 0.0f };
M3DVector3f look = { xHeading,yHeading,0.0f };
//xHeading & yHeading ranges from -1 to 1 based on mouse movement, is this correct?
How should I be managing and passing in the look variables? It appears currently that the look value is staying in the same place and so if I move backwards, I end up rotating around the scene.
glhLookAtf2(mCamera, mCamera, look, up);
I feel that I have to be managing my look direction better, and possibly my camera location as well. It seems odd that the look position doesn’t seem to change.
Can anyone help, or point me in the direction of a solid tutorial path? I’m trying to avoid doing anything deprecated, but at this point I’d be really happy just to get something working.
Thanks for everyones answers but the problem I had was this. In the openGL super bible, I was using their built in frame of reference class, and the problem I had was two functions, one called rotate, and rotateWorld.
I needed to use rotate for up/down movement, and rotateWorld for left right movement. This made the camera behave correctly (fly camera).
It makes sense as regardless of where you are looking up/down, you want the whole world to always spin around the vertical axis. Phew!