private Vector3 getTranslation (Matrix4 worldTransform, Vector3 center, Vector3 output) { if (center.isZero()) worldTransform.getTranslation(output); else if (!worldTransform.hasRotationOrScaling()) worldTransform.getTranslation(output).add(center); else output.set(center).mul(worldTransform); return output; }
/** 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(); } }
private Vector3 getTranslation (Matrix4 worldTransform, Vector3 center, Vector3 output) { if (center.isZero()) worldTransform.getTranslation(output); else if (!worldTransform.hasRotationOrScaling()) worldTransform.getTranslation(output).add(center); else output.set(center).mul(worldTransform); return output; }
/** 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(); } }
if (forward.isZero()) forward.set(Vector3.X); forward.crs(up).nor(); Vector3 left = obtainV3().set(up).crs(forward).nor();
if (forward.isZero()) forward.set(Vector3.X); forward.crs(up).nor(); Vector3 left = obtainV3().set(up).crs(forward).nor();
/** * @return True if linear velocity of body is not within threshold of zero */ public boolean isMoving() { return !body.getLinearVelocity().isZero(getZeroLinearSpeedThreshold()); }
private Vector3 getTranslation (Matrix4 worldTransform, Vector3 center, Vector3 output) { if (center.isZero()) worldTransform.getTranslation(output); else if (!worldTransform.hasRotationOrScaling()) worldTransform.getTranslation(output).add(center); else output.set(center).mul(worldTransform); return output; }
/** 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 boolean onContactAdded(btCollisionObject colObj0, int partId0, int index0, btCollisionObject colObj1, int partId1, int index1) { Entity entity0 = getEntity(colObj0.getUserPointer()); Entity entity1 = getEntity(colObj1.getUserPointer()); Stick stick = null; if (entity0 instanceof Stick) { stick = (Stick) entity0; } else if (entity1 instanceof Stick) { stick = (Stick) entity1; } if (stick != null && !stick.hasLanded && stick.body.getLinearVelocity().isZero(0.1f)) { stick.owner.onStickLanded(); } return true; } }
if (!linearVelocity.isZero(getZeroLinearSpeedThreshold())) { position = getPosition(); targetOrientationVector.set(linearVelocity.x, 0, -linearVelocity.z).nor();
if (forward.isZero()) forward.set(Vector3.X); forward.crs(up).nor();
if (forward.isZero()) forward.set(Vector3.X); forward.crs(up).nor(); Vector3 left = obtainV3().set(up).crs(forward).nor();