private void setGuiBounding() { float sx = width * viewPortLeft; float ex = width * viewPortRight; float sy = height * viewPortBottom; float ey = height * viewPortTop; float xExtent = Math.max(0f, (ex - sx) / 2f); float yExtent = Math.max(0f, (ey - sy) / 2f); guiBounding.setCenter(sx + xExtent, sy + yExtent, 0); guiBounding.setXExtent(xExtent); guiBounding.setYExtent(yExtent); guiBounding.setZExtent(Float.MAX_VALUE); }
@Test public void testBoxBoxCollision() { BoundingBox box1 = new BoundingBox(Vector3f.ZERO, 1, 1, 1); BoundingBox box2 = new BoundingBox(Vector3f.ZERO, 1, 1, 1); checkCollision(box1, box2, 1); // Put it at the very edge - should still intersect. box2.setCenter(new Vector3f(2f, 0f, 0f)); checkCollision(box1, box2, 1); // Put it a wee bit farther - no intersection expected box2.setCenter(new Vector3f(2f + FastMath.ZERO_TOLERANCE, 0, 0)); checkCollision(box1, box2, 0); // Check the corners. box2.setCenter(new Vector3f(2f, 2f, 2f)); checkCollision(box1, box2, 1); box2.setCenter(new Vector3f(2f, 2f, 2f + FastMath.ZERO_TOLERANCE)); checkCollision(box1, box2, 0); }
@Test public void testBoxTriangleCollision() { BoundingBox box = new BoundingBox(Vector3f.ZERO, 1, 1, 1); Geometry geom = new Geometry("geom", new Quad(1, 1)); checkCollision(box, geom, 2); // Both triangles intersect // The box touches the edges of the triangles. box.setCenter(new Vector3f(-1f, 0, 0)); checkCollision(box, geom, 2); // Move it slightly farther.. box.setCenter(new Vector3f(-1f - FastMath.ZERO_TOLERANCE, 0, 0)); checkCollision(box, geom, 0); // Parallel triangle / box side, touching box.setCenter(new Vector3f(0, 0, -1f)); checkCollision(box, geom, 2); // Not touching box.setCenter(new Vector3f(0, 0, -1f - FastMath.ZERO_TOLERANCE)); checkCollision(box, geom, 0); // Test collisions only against one of the triangles box.setCenter(new Vector3f(-1f, 1.5f, 0f)); checkCollision(box, geom, 1); box.setCenter(new Vector3f(1.5f, -1f, 0f)); checkCollision(box, geom, 1); }
this.guiBounding.setYExtent(cam.guiBounding.getYExtent()); this.guiBounding.setZExtent(cam.guiBounding.getZExtent()); this.guiBounding.setCenter(cam.guiBounding.getCenter()); this.guiBounding.setCheckPlane(cam.guiBounding.getCheckPlane());
frustumCam.setFrustumFar(25); makeCamFrustum(); aabb.setCenter(20, 10, -60); aabb.setXExtent(10); aabb.setYExtent(5);
private void setGuiBounding() { float sx = width * viewPortLeft; float ex = width * viewPortRight; float sy = height * viewPortBottom; float ey = height * viewPortTop; float xExtent = Math.max(0f, (ex - sx) / 2f); float yExtent = Math.max(0f, (ey - sy) / 2f); guiBounding.setCenter(sx + xExtent, sy + yExtent, 0); guiBounding.setXExtent(xExtent); guiBounding.setYExtent(yExtent); guiBounding.setZExtent(Float.MAX_VALUE); }
private void setGuiBounding() { float sx = width * viewPortLeft; float ex = width * viewPortRight; float sy = height * viewPortBottom; float ey = height * viewPortTop; float xExtent = Math.max(0f, (ex - sx) / 2f); float yExtent = Math.max(0f, (ey - sy) / 2f); guiBounding.setCenter(new Vector3f(sx + xExtent, sy + yExtent, 0)); guiBounding.setXExtent(xExtent); guiBounding.setYExtent(yExtent); guiBounding.setZExtent(Float.MAX_VALUE); }
public void generateRenderSet(Geometry[] globalGeomList, Set<Geometry> renderSet, Camera cam, BoundingBox parentBox, boolean isRoot){ tempBox.setCenter(parentBox.getCenter()); tempBox.setXExtent(parentBox.getXExtent()); tempBox.setYExtent(parentBox.getYExtent());
this.guiBounding.setYExtent(cam.guiBounding.getYExtent()); this.guiBounding.setZExtent(cam.guiBounding.getZExtent()); this.guiBounding.setCenter(cam.guiBounding.getCenter()); this.guiBounding.setCheckPlane(cam.guiBounding.getCheckPlane());
this.guiBounding.setYExtent(cam.guiBounding.getYExtent()); this.guiBounding.setZExtent(cam.guiBounding.getZExtent()); this.guiBounding.setCenter(cam.guiBounding.getCenter()); this.guiBounding.setCheckPlane(cam.guiBounding.getCheckPlane());