/** Moves the camera by the given amount on each axis. * @param x the displacement on the x-axis * @param y the displacement on the y-axis * @param z the displacement on the z-axis */ public void translate (float x, float y, float z) { position.add(x, y, z); }
/** @see Decal#translate(float, float, float) */ public void translate (Vector3 trans) { this.position.add(trans); updated = false; }
/** Moves the camera by the given vector. * @param vec the displacement vector */ public void translate (Vector3 vec) { position.add(vec); }
/** Translates by the specified amount of units * * @param x Units to move along the x axis * @param y Units to move along the y axis * @param z Units to move along the z axis */ public void translate (float x, float y, float z) { this.position.add(x, y, z); updated = false; }
/** Returns the endpoint given the distance. This is calculated as startpoint + distance * direction. * @param out The vector to set to the result * @param distance The distance from the end point to the start point. * @return The out param */ public Vector3 getEndPoint (final Vector3 out, final float distance) { return out.set(direction).scl(distance).add(origin); }
/** Returns the endpoint given the distance. This is calculated as startpoint + distance * direction. * @param out The vector to set to the result * @param distance The distance from the end point to the start point. * @return The out param */ public Vector3 getEndPoint (final Vector3 out, final float distance) { return out.set(direction).scl(distance).add(origin); }
/** Checks if entity is inside camera frustum. * * @param entity An entity * @return True if entity is inside camera frustum */ private boolean entityInFrustum (BulletEntity entity) { entity.modelInstance.transform.getTranslation(tmpV1); return frustumCam.frustum.sphereInFrustum(tmpV1.add(entity.boundingBox.getCenter(tmpV2)), entity.boundingBoxRadius); }
@Override public void drawContactPoint (Vector3 pointOnB, Vector3 normalOnB, float distance, int lifeTime, Vector3 color) { shapeRenderer.setColor(color.x, color.y, color.z, 1f); shapeRenderer.point(pointOnB.x, pointOnB.y, pointOnB.z); shapeRenderer.line(pointOnB, normalOnB.scl(distance).add(pointOnB)); }
@Override public void drawContactPoint (Vector3 pointOnB, Vector3 normalOnB, float distance, int lifeTime, Vector3 color) { shapeRenderer.setColor(color.x, color.y, color.z, 1f); shapeRenderer.point(pointOnB.x, pointOnB.y, pointOnB.z); shapeRenderer.line(pointOnB, normalOnB.scl(distance).add(pointOnB)); }
/** 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); }
/** 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); }
/** 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; }
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(); }
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; }
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 Vector3 getPositionAt (Vector3 out, int x, int y) { final float dx = (float)x / (float)(width - 1); final float dy = (float)y / (float)(height - 1); final float a = data[y * width + x]; out.set(corner00).lerp(corner10, dx).lerp(tmpV1.set(corner01).lerp(corner11, dx), dy); out.add(tmpV1.set(magnitude).scl(a)); return out; }
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; }
@Override protected void onLoaded () { super.onLoaded(); BoundingBox bounds = instances.get(0).calculateBoundingBox(new BoundingBox()); bounds.getCenter(center); radius = bounds.getDimensions(tmpV).len() * .5f; pointLight.position.set(0, radius, 0).add(transformedCenter.set(center).mul(transform)); pointLight.intensity = radius * radius; ((ColorAttribute)pLight.material.get(ColorAttribute.Diffuse)).color.set(pointLight.color); final float s = 0.2f * radius; pLight.worldTransform.setToScaling(s, s, s); }