@Override public Vector3 limit2 (float limit2) { float len2 = len2(); if (len2 > limit2) { scl((float)Math.sqrt(limit2 / len2)); } return this; }
@Override public Vector3 setLength2 (float len2) { float oldLen2 = len2(); return (oldLen2 == 0 || oldLen2 == len2) ? this : scl((float)Math.sqrt(len2 / oldLen2)); }
/** 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); }
@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)); }
private void endpart () { if (part != null) { bounds.getCenter(part.center); bounds.getDimensions(part.halfExtents).scl(0.5f); part.radius = part.halfExtents.len(); bounds.inf(); part.offset = istart; part.size = indices.size - istart; istart = indices.size; part = null; } }
@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); }
/** Calculates and updates the {@link #center}, {@link #halfExtents} and {@link #radius} values. This is considered a costly * operation and should not be called frequently. All vertices (points) of the shape are traversed to calculate the maximum and * minimum x, y and z coordinate of the shape. Note that MeshPart is not aware of any transformation that might be applied when * rendering. It calculates the untransformed (not moved, not scaled, not rotated) values. */ public void update () { mesh.calculateBoundingBox(bounds, offset, size); bounds.getCenter(center); bounds.getDimensions(halfExtents).scl(0.5f); radius = halfExtents.len(); }
/** 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); }
/** Calculates and updates the {@link #center}, {@link #halfExtents} and {@link #radius} values. This is considered a costly * operation and should not be called frequently. All vertices (points) of the shape are traversed to calculate the maximum and * minimum x, y and z coordinate of the shape. Note that MeshPart is not aware of any transformation that might be applied when * rendering. It calculates the untransformed (not moved, not scaled, not rotated) values. */ public void update () { mesh.calculateBoundingBox(bounds, offset, size); bounds.getCenter(center); bounds.getDimensions(halfExtents).scl(0.5f); radius = halfExtents.len(); }
private void endpart () { if (part != null) { bounds.getCenter(part.center); bounds.getDimensions(part.halfExtents).scl(0.5f); part.radius = part.halfExtents.len(); bounds.inf(); part.offset = istart; part.size = indices.size - istart; istart = indices.size; part = null; } }
@Override public boolean touchDragged (int screenX, int screenY, int pointer) { boolean result = false; if (pickConstraint != null) { Ray ray = camera.getPickRay(screenX, screenY); tmpV1.set(ray.direction).scl(pickDistance).add(camera.position); pickConstraint.setPivotB(tmpV1); result = true; } return result ? result : super.touchDragged(screenX, screenY, pointer); }
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(); }
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 Matrix4 setToWorld (Vector3 position, Vector3 forward, Vector3 up) { tmpForward.set(forward).nor(); right.set(tmpForward).crs(up).nor(); tmpUp.set(right).crs(tmpForward).nor(); this.set(right, tmpUp, tmpForward.scl(-1), position); return this; }
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; }