Hey, I just realized I was having the same problem as (I rotated an object and changed the camera to match), except I didn't know it because I was using a sphere to test with.
Anyway, check this out, it should help you out:
float cameraXRotate1 = 0.0f; // Rotating camera only
float cameraXRotate2 = 0.0f; // Rotating camera only
float mouseY1; // Used to apply camera rotation
float mouseX1; // Used to apply camera rotation
float mouseY2; // Used to apply camera rotation
float mouseX2; // Used to apply camera rotation
bool rClicked = false; // For correctly controlling mouse look
// Enter mouse control when right mouse button is pressed
if (dbMouseClick() == 2) {
if (rClicked == false) {
mouseX2 = dbMouseX();
mouseY2 = dbMouseY();
rClicked = true;
}
dbHideMouse();
dbXRotateCamera(cameraXRotate1 = dbObjectAngleX(2) + (dbMouseY() - mouseY2));
dbYRotateObject(2, dbObjectAngleY(2) + (dbMouseX() - mouseX2));
cameraXRotate2 += cameraXRotate1; // This tracks the changes made to the X-rotation
dbPositionMouse(mouseX2, mouseY2);
} else { dbShowMouse(); rClicked = false; }
// Position the player
dbPositionObject(2, playerPositionX, oldY, playerPositionZ);
// Position the camera
dbPositionCamera(dbObjectPositionX(2), dbObjectPositionY(2), dbObjectPositionZ(2));
dbRotateCamera(cameraXRotate2, dbObjectAngleY(2) + playerHeight, dbObjectAngleZ(2));
// When I rotate the camera I use cameraXRotate2 so that it applies the correct rotation
That is obviously not all of the code for moving my character, but it should be enough to fix your problem.
The problem I had in my code (once I changed it to only rotate the camera along the X-axis) was that every time I went through the game loop I had a new rotation value along the X-axis. This meant the camera would jump to where ever this new rotation value told it to. The solution was to add a second variable that would "track" all of the different rotations made along the X-axis