Camera rotation around a central pivot point?

I’m trying to use vector math to rotate the view around a central pivot point, which may move around. This is the code that I have so far:


	public void followObject(Object target) {
		if (target instanceof Voxel) {
			Vector3f tpos = new Vector3f(((Voxel)target).x, ((Voxel)target).y, ((Voxel)target).z);
			pitch = Vector3f.angle(new Vector3f(1, 0, 0), tpos);
			yaw = Vector3f.angle(new Vector3f(0, 1, 0), tpos);
			roll = Vector3f.angle(new Vector3f(0, 0, 1), tpos);
			this.setPosition(tpos.x + (pitch * 10.0f * zoom), tpos.y + (yaw * 10.0f * zoom), tpos.z +(roll * 10.0f * zoom));
			GLU.gluLookAt(this.x, this.y, this.z, tpos.x, tpos.y, tpos.z, 0, 1.0f, 0);
		}
	}

Could anyone give me tips or pointers as to how I can get this to work?

Here is part of my Obit camera I was using in a recent LibGDX project:

		//the amount to "tilt" the camera vertically around origin 
		camera.position.y = tilt * TILT_SPEED;

		//orbits slowly around centre point
		camera.lookAt(0, 0, 0);
		camera.rotateAround(new Vector3(0, 0, 0), new Vector3(0, 1, 0), ORBIT_SPEED);
		
		//amount to pan up/down along the Y axis
		camera.position.add(0, panY * PAN_Y_SPEED, 0);
		camera.update();

I had tilt affected by mouse scroll, and pan affected by mouse Y drag.

See the source for LibGDX’s Camera class if you want to re-invent the wheel.

Alternately, you could use the spherical coordinate system which is quite natural in cases like this.

No matter what method you use, be carefull about passing up as (0,1,0) since it won’t work in all cases.