Hi,

Math is not my strong suite and for the code below I searched a lot and this is what I was able to achieve, there's still a few issues that I can't seem to fix.

My camera is setup like this:
Code:
gluLookAt(eyeX, eyeY, eyeZ, eyeX + refX, eyeY + refY, eyeZ + refZ, 0.0f, 1.0f, 0.0f);
And this is my current code to move the camera:
Code:
void setCameraEye(int transformation, int direction) {
	switch(transformation) {
		case CAMERA_MOVE:
			eyeX += direction * sin(angleYaw) * MOVE_SPEED;
			eyeY += direction * sin(anglePitch) * MOVE_SPEED;
			eyeZ += direction * -cos(angleYaw) * MOVE_SPEED;

			break;
		case CAMERA_STRAFE:
			eyeX += direction * sin(angleYaw + PI/2) * MOVE_SPEED;
			eyeZ += direction * -cos(angleYaw + PI/2) * MOVE_SPEED;
			
			break;
		case CAMERA_ELEVATE:
			eyeY += direction * sin(anglePitch + PI/2) * MOVE_SPEED;
			eyeZ += direction * -cos(angleYaw + PI/2) * MOVE_SPEED;

			break;
		case CAMERA_PITCH:
			anglePitch += direction * ROTATE_SPEED;

			refY = tan(anglePitch);

			break;
		case CAMERA_YAW:
			angleYaw += direction * ROTATE_SPEED;

			refX = sin(angleYaw);
			refZ = -cos(angleYaw);

			break;
	}
}
All angles and camera points are floats.

Camera movement, strafe and elevation seems to be working just fine, yaw works too. I can even STRAFE and YAW around an object completing a 360º circle; camera moving in the XZ plane.

VIDEO DEMO (FLASH): Play - ShowMeWhatsWrong.com (You can see that it works fine)

My problem is that I want to do the same but MOVE and PITCH around the object completing a 360º circle, just as I can do with STRAFE/YAW. But it's not working, when I'm looking above -90º down or above 90º up the object I'm looking at disappears.

VIDEO DEMO (FLASH): Play - ShowMeWhatsWrong.com (You can see that when the angle is above -1.57 ~ 90º, the object disappears)

So...

Question 1)
How can I solve this MOVE/PITCH problem? Any easy solution?

Question 2)
Do you think there's something wrong my code? Specially the sine, cosine and tangent functions with those specific axis? I found lots of different implementations on the Web, this ones seems to produce the best (and correct?) results as far as I can tell.