I looked up camera orbiting in the archives, and I found some pretty useful formulas. However, I'm having one issue... well, a few really, but one major one. I can't control how far up the camera goes.
To explain, what I want is that once the camera reaches about 85 degrees on the x-axis (almost looking straight down), it can go up no further and just orbits around the object on the x and z axis, because once it reaches 90 degrees, it flips the camera around, which is very jumpy and glitchy looking.
Also, I have the camera rotate around a 3d mouse coordinate, which is a dummy object that follows the mouse while staying on whatever the level of terrain is. When I click on a spot, the whole view jumps over to where it is. It would be better to cast a ray from the camera to the ground, find where it intersects, and then orbit around that, because when i hold down the mouse button (which makes the camera orbit) it would not jump, but merely orbit from that position.
A final problem is that sometimes when i initiate the orbit, the camera randomly jumps to under the terrain, looking up.
All this to say... help!