I use the following function to orbit around the center or a predefined point.
[java]
public void orbitUp(Vector3f camLookAt, float tpf) {
Quaternion tempQuat = new Quaternion();
Quaternion camRot = new Quaternion();
Vector3f camPos = cam.getLocation();
if(camPos.x == 0.0 && camPos.y == 0.0)
{
logger.info(“Orbitting request denied - can’t orbit aorund center”);
}
else {
tempQuat.fromAngles(0, 0, tpf + 0.01f).multLocal(camPos);
camRot.lookAt(camLookAt.subtract(camPos), new Vector3f(Vector3f.UNIT_Z));
cam.setLocation(camLookAt.add(camPos));
cam.setRotation(camRot);
}
}
[/java]
How can I orbit around where the Camera is pointing at?
@nightwolf911 said:
How can I orbit around where the Camera is pointing at?
Which "where the camera is pointing at"? The camera is "pointing at" an infinite number of points.
I already looked it up guys (googled this forum extensively)
I want to be able to point at a location and rotate around it (orbit) rather than orbit around a given point (center in my example set at (0,0,0) every time.
Use a chase cam.
You need to pick a point in space that you want to rotate around. Maybe its where your camera is looking at the ground? Cast a ray in the direction of your camera and find the point of collision with what you want to rotate around.
1 Like
@nightwolf911 said:
I already looked it up guys (googled this forum extensively)
I want to be able to point at a location and rotate around it (orbit) rather than orbit around a given point (center in my example set at (0,0,0) every time.
What is the difference between "location" and "point" in the above sentence?
"point at a location and rotate around it"
"orbit around a given point"
Sound identical to me.
+1