/** Recalculates the direction of the camera to look at the point (x, y, z). This function assumes the up vector is normalized. * @param x the x-coordinate of the point to look at * @param y the y-coordinate of the point to look at * @param z the z-coordinate of the point to look at */ public void lookAt (float x, float y, float z) { tmpVec.set(x, y, z).sub(position).nor(); if (!tmpVec.isZero()) { float dot = tmpVec.dot(up); // up and direction must ALWAYS be orthonormal vectors if (Math.abs(dot - 1) < 0.000000001f) { // Collinear up.set(direction).scl(-1); } else if (Math.abs(dot + 1) < 0.000000001f) { // Collinear opposite up.set(direction); } direction.set(tmpVec); normalizeUp(); } }
public void update (final Vector3 center, final Vector3 forward) { // cam.position.set(10,10,10); cam.position.set(direction).scl(-halfDepth).add(center); cam.direction.set(direction).nor(); // cam.up.set(forward).nor(); cam.normalizeUp(); cam.update(); }
public void update (final Vector3 center, final Vector3 forward) { // cam.position.set(10,10,10); cam.position.set(direction).scl(-halfDepth).add(center); cam.direction.set(direction).nor(); // cam.up.set(forward).nor(); cam.normalizeUp(); cam.update(); }
/** Recalculates the direction of the camera to look at the point (x, y, z). This function assumes the up vector is normalized. * @param x the x-coordinate of the point to look at * @param y the y-coordinate of the point to look at * @param z the z-coordinate of the point to look at */ public void lookAt (float x, float y, float z) { tmpVec.set(x, y, z).sub(position).nor(); if (!tmpVec.isZero()) { float dot = tmpVec.dot(up); // up and direction must ALWAYS be orthonormal vectors if (Math.abs(dot - 1) < 0.000000001f) { // Collinear up.set(direction).scl(-1); } else if (Math.abs(dot + 1) < 0.000000001f) { // Collinear opposite up.set(direction); } direction.set(tmpVec); normalizeUp(); } }
public void update (final Vector3 center, final Vector3 forward) { // cam.position.set(10,10,10); cam.position.set(direction).scl(-halfDepth).add(center); cam.direction.set(direction).nor(); // cam.up.set(forward).nor(); cam.normalizeUp(); cam.update(); }
/** Recalculates the direction of the camera to look at the point (x, y, z). This function assumes the up vector is normalized. * @param x the x-coordinate of the point to look at * @param y the y-coordinate of the point to look at * @param z the z-coordinate of the point to look at */ public void lookAt (float x, float y, float z) { tmpVec.set(x, y, z).sub(position).nor(); if (!tmpVec.isZero()) { float dot = tmpVec.dot(up); // up and direction must ALWAYS be orthonormal vectors if (Math.abs(dot - 1) < 0.000000001f) { // Collinear up.set(direction).scl(-1); } else if (Math.abs(dot + 1) < 0.000000001f) { // Collinear opposite up.set(direction); } direction.set(tmpVec); normalizeUp(); } }