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?