@Override public Vector3 sub (final Vector3 a_vec) { return this.sub(a_vec.x, a_vec.y, a_vec.z); }
@Override public Vector3 sub (final Vector3 a_vec) { return this.sub(a_vec.x, a_vec.y, a_vec.z); }
public SpotLight setTarget (final Vector3 target) { direction.set(target).sub(position).nor(); return this; }
/** Sets the rotation of the Decal to face the given point. Useful for billboarding. * @param position * @param up */ public void lookAt (Vector3 position, Vector3 up) { dir.set(position).sub(this.position).nor(); setRotation(dir, up); }
/** Sets the rotation of the Decal to face the given point. Useful for billboarding. * @param position * @param up */ public void lookAt (Vector3 position, Vector3 up) { dir.set(position).sub(this.position).nor(); setRotation(dir, up); }
/** Return center point's rectangle * @param point0 * @param point1 * @param point2 * @return the center point */ private static Vector3 centerPoint (Vector3 point0, Vector3 point1, Vector3 point2) { tmpV0.set(point1).sub(point0).scl(0.5f); tmpV1.set(point0).add(tmpV0); tmpV0.set(point2).sub(point1).scl(0.5f); return tmpV1.add(tmpV0); } }
/** Return center point's rectangle * @param point0 * @param point1 * @param point2 * @return the center point */ private static Vector3 centerPoint (Vector3 point0, Vector3 point1, Vector3 point2) { tmpV0.set(point1).sub(point0).scl(0.5f); tmpV1.set(point0).add(tmpV0); tmpV0.set(point2).sub(point1).scl(0.5f); return tmpV1.add(tmpV0); } }
/** Return middle point's segment * @param point0 First segment's point * @param point1 Second segment's point * @return the middle point */ private static Vector3 middlePoint (Vector3 point0, Vector3 point1) { tmpV0.set(point1).sub(point0).scl(0.5f); return tmpV1.set(point0).add(tmpV0); }
/** Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane. * The normal is calculated via a cross product between (point1-point2)x(point2-point3) * * @param point1 * @param point2 * @param point3 */ public void set (Vector3 point1, Vector3 point2, Vector3 point3) { normal.set(point1).sub(point2).crs(point2.x-point3.x, point2.y-point3.y, point2.z-point3.z).nor(); d = -point1.dot(normal); }
/** Sets this matrix to a look at matrix with the given position, target and up vector. * * @param position the position * @param target the target * @param up the up vector * @return This matrix */ public Matrix4 setToLookAt (Vector3 position, Vector3 target, Vector3 up) { tmpVec.set(target).sub(position); setToLookAt(tmpVec, up); this.mul(tmpMat.setToTranslation(-position.x, -position.y, -position.z)); return this; }
/** Sets this matrix to a look at matrix with the given position, target and up vector. * * @param position the position * @param target the target * @param up the up vector * @return This matrix */ public Matrix4 setToLookAt (Vector3 position, Vector3 target, Vector3 up) { tmpVec.set(target).sub(position); setToLookAt(tmpVec, up); this.mul(tmpMat.setToTranslation(-position.x, -position.y, -position.z)); return this; }
/** Return middle point's segment * @param point0 First segment's point * @param point1 Second segment's point * @return the middle point */ private static Vector3 middlePoint (Vector3 point0, Vector3 point1) { tmpV0.set(point1).sub(point0).scl(0.5f); return tmpV1.set(point0).add(tmpV0); }
/** Sets the plane normal and distance to the origin based on the three given points which are considered to be on the plane. * The normal is calculated via a cross product between (point1-point2)x(point2-point3) * * @param point1 * @param point2 * @param point3 */ public void set (Vector3 point1, Vector3 point2, Vector3 point3) { normal.set(point1).sub(point2).crs(point2.x-point3.x, point2.y-point3.y, point2.z-point3.z).nor(); d = -point1.dot(normal); }
/** Multiplies the ray by the given matrix. Use this to transform a ray into another coordinate system. * * @param matrix The matrix * @return This ray for chaining. */ public Ray mul (Matrix4 matrix) { tmp.set(origin).add(direction); tmp.mul(matrix); origin.mul(matrix); direction.set(tmp.sub(origin)); return this; }
/** Multiplies the ray by the given matrix. Use this to transform a ray into another coordinate system. * * @param matrix The matrix * @return This ray for chaining. */ public Ray mul (Matrix4 matrix) { tmp.set(origin).add(direction); tmp.mul(matrix); origin.mul(matrix); direction.set(tmp.sub(origin)); return this; }
@Override public boolean touchDragged (int x, int y, int pointer) { camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { if (!canDrag) return false; camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); camera.update(); return false; }
@Override public boolean touchDragged (int x, int y, int pointer) { if (!canDrag) return false; camera.unproject(curr.set(x, y, 0)); if (!(last.x == -1 && last.y == -1 && last.z == -1)) { camera.unproject(delta.set(last.x, last.y, 0)); delta.sub(curr); camera.position.add(delta.x, delta.y, 0); } last.set(x, y, 0); camera.update(); return false; }
public static boolean intersectSegmentPlane (Vector3 start, Vector3 end, Plane plane, Vector3 intersection) { Vector3 dir = v0.set(end).sub(start); float denom = dir.dot(plane.getNormal()); if (denom == 0f) return false; float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0 || t > 1) return false; intersection.set(start).add(dir.scl(t)); return true; }
public static boolean intersectSegmentPlane (Vector3 start, Vector3 end, Plane plane, Vector3 intersection) { Vector3 dir = v0.set(end).sub(start); float denom = dir.dot(plane.getNormal()); if (denom == 0f) return false; float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0 || t > 1) return false; intersection.set(start).add(dir.scl(t)); return true; }