/** * <code>containsGui</code> tests a bounding volume against the ortho * bounding box of the camera. A bounding box spanning from * 0, 0 to Width, Height. Constrained by the viewport settings on the * camera. * * @param bound the bound to check for culling * @return True if the camera contains the gui element bounding volume. */ public boolean containsGui(BoundingVolume bound) { if (bound == null) { return true; } return guiBounding.intersects(bound); }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { return 1; } return 0; } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume) other) ? 1 : 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
/** * Find what terrain patches need normal recalculations and update * their normals; */ protected void fixNormals(BoundingBox affectedArea) { if (children == null) return; // go through the children and see if they collide with the affectedAreaBBox // if they do, then update their normals for (int x = children.size(); --x >= 0;) { Spatial child = children.get(x); if (child instanceof TerrainQuad) { if (affectedArea != null && affectedArea.intersects(((TerrainQuad) child).getWorldBound()) ) ((TerrainQuad) child).fixNormals(affectedArea); } else if (child instanceof TerrainPatch) { if (affectedArea != null && affectedArea.intersects(((TerrainPatch) child).getWorldBound()) ) ((TerrainPatch) child).updateNormals(); // recalculate the patch's normals } } }
@Override public int collideWith(Collidable other, CollisionResults results) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray, results); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume) other)) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
Spatial child = children.get(x); if (child instanceof TerrainQuad) { if (affectedArea != null && affectedArea.intersects(((TerrainQuad) child).getWorldBound()) ) ((TerrainQuad) child).fixNormalEdges(affectedArea); } else if (child instanceof TerrainPatch) { if (affectedArea != null && !affectedArea.intersects(((TerrainPatch) child).getWorldBound()) ) // if doesn't intersect, continue continue;
BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox); boolean intersects = splitBB.intersects(occBox); if (!intersects && occBox instanceof BoundingBox) { BoundingBox occBB = (BoundingBox) occBox; if (splitBB.intersects(occBB)) { BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox); intersects = splitBB.intersects(occBox); if (!intersects && occBox instanceof BoundingBox) { BoundingBox occBB = (BoundingBox) occBox; intersects = splitBB.intersects(occBB);
BoundingVolume recvBox = bv.transform(viewProjMatrix, vars.bbox); if (splitBB.intersects(recvBox)) {
/** * <code>containsGui</code> tests a bounding volume against the ortho * bounding box of the camera. A bounding box spanning from * 0, 0 to Width, Height. Constrained by the viewport settings on the * camera. * * @param bound the bound to check for culling * @return True if the camera contains the gui element bounding volume. */ public boolean containsGui(BoundingVolume bound) { return guiBounding.intersects(bound); }
/** * <code>containsGui</code> tests a bounding volume against the ortho * bounding box of the camera. A bounding box spanning from * 0, 0 to Width, Height. Constrained by the viewport settings on the * camera. * * @param bound the bound to check for culling * @return True if the camera contains the gui element bounding volume. */ public boolean containsGui(BoundingVolume bound) { if (bound == null) { return true; } return guiBounding.intersects(bound); }
@Override public int collideWith(Collidable other) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { return 1; } return 0; } else if (other instanceof BoundingVolume) { return intersects((BoundingVolume) other) ? 1 : 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
/** * Find what terrain patches need normal recalculations and update * their normals; */ protected void fixNormals(BoundingBox affectedArea) { if (children == null) return; // go through the children and see if they collide with the affectedAreaBBox // if they do, then update their normals for (int x = children.size(); --x >= 0;) { Spatial child = children.get(x); if (child instanceof TerrainQuad) { if (affectedArea != null && affectedArea.intersects(((TerrainQuad) child).getWorldBound()) ) ((TerrainQuad) child).fixNormals(affectedArea); } else if (child instanceof TerrainPatch) { if (affectedArea != null && affectedArea.intersects(((TerrainPatch) child).getWorldBound()) ) ((TerrainPatch) child).updateNormals(); // recalculate the patch's normals } } }
public int collideWith(Collidable other, CollisionResults results) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray, results); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
@Override public int collideWith(Collidable other, CollisionResults results) { if (other instanceof Ray) { Ray ray = (Ray) other; return collideWithRay(ray, results); } else if (other instanceof Triangle) { Triangle t = (Triangle) other; if (intersects(t.get1(), t.get2(), t.get3())) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof BoundingVolume) { if (intersects((BoundingVolume) other)) { CollisionResult r = new CollisionResult(); results.addCollision(r); return 1; } return 0; } else if (other instanceof Spatial) { return ((Spatial)other).collideWith(this, results); } else { throw new UnsupportedCollisionException("With: " + other.getClass().getSimpleName()); } }
private float getAdditionCost(BoundingBox bbox, OCTTriangle t){ if (bbox.intersects(t.get1(), t.get2(), t.get3())){ float d1 = bbox.distanceToEdge(t.get1()); float d2 = bbox.distanceToEdge(t.get2()); float d3 = bbox.distanceToEdge(t.get3()); return d1 + d2 + d3; } return Float.POSITIVE_INFINITY; }
BoundingVolume recvBox = bv.transform(viewProjMatrix, null); if (splitBB.intersects(recvBox)) { visRecvList.add(recvBox); BoundingVolume occBox = bv.transform(viewProjMatrix, null); boolean intersects = splitBB.intersects(occBox); if (!intersects && occBox instanceof BoundingBox) { BoundingBox occBB = (BoundingBox) occBox; if (splitBB.intersects(occBB)) {
Spatial child = children.get(x); if (child instanceof TerrainQuad) { if (affectedArea != null && affectedArea.intersects(((TerrainQuad) child).getWorldBound()) ) ((TerrainQuad) child).fixNormalEdges(affectedArea); } else if (child instanceof TerrainPatch) { if (affectedArea != null && !affectedArea.intersects(((TerrainPatch) child).getWorldBound()) ) // if doesn't intersect, continue continue;
BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox); boolean intersects = splitBB.intersects(occBox); if (!intersects && occBox instanceof BoundingBox) { BoundingBox occBB = (BoundingBox) occBox; if (splitBB.intersects(occBB)) { BoundingVolume occBox = bv.transform(viewProjMatrix, vars.bbox); intersects = splitBB.intersects(occBox); if (!intersects && occBox instanceof BoundingBox) { BoundingBox occBB = (BoundingBox) occBox; intersects = splitBB.intersects(occBB);
public final void intersectWhere(Ray r, Geometry[] geoms, float sceneMin, float sceneMax, CollisionResults results){ for (OCTTriangle t : tris){ float d = r.intersects(t.get1(), t.get2(), t.get3()); if (Float.isInfinite(d)) continue; Vector3f contactPoint = new Vector3f(r.getDirection()).multLocal(d).addLocal(r.getOrigin()); CollisionResult result = new CollisionResult(geoms[t.getGeometryIndex()], contactPoint, d, t.getTriangleIndex()); results.addCollision(result); } for (int i = 0; i < 8; i++){ Octnode child = children[i]; if (child == null) continue; if (child.bbox.intersects(r)){ child.intersectWhere(r, geoms, sceneMin, sceneMax, results); } } }
BoundingVolume recvBox = bv.transform(viewProjMatrix, vars.bbox); if (splitBB.intersects(recvBox)) {