public static void main(String[] args){ Ray r = new Ray(Vector3f.ZERO, Vector3f.UNIT_X); BoundingBox bbox = new BoundingBox(new Vector3f(5, 0, 0), 1, 1, 1); CollisionResults res = new CollisionResults(); bbox.collideWith(r, res); System.out.println("Bounding:" +bbox); System.out.println("Ray: "+r); System.out.println("Num collisions: "+res.size()); for (int i = 0; i < res.size(); i++){ System.out.println("--- Collision #"+i+" ---"); float dist = res.getCollision(i).getDistance(); Vector3f pt = res.getCollision(i).getContactPoint(); System.out.println("distance: "+dist); System.out.println("point: "+pt); } }
if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(topRight.x, topRight.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(bottomLeft.x, bottomLeft.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(bottomRight.x, bottomRight.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; continue; t = getTriangle(x,z); if (t != null && bbox.collideWith(t, results) > 0) return 1;
public void intersect(Ray r, float farPlane, Geometry[] geoms, CollisionResults results){ boundResults.clear(); bbox.collideWith(r, boundResults); if (boundResults.size() > 0){ float tMin = boundResults.getClosestCollision().getDistance(); float tMax = boundResults.getFarthestCollision().getDistance(); tMin = Math.max(tMin, 0); tMax = Math.min(tMax, farPlane); root.intersectWhere(r, geoms, tMin, tMax, results); } } }
if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(topRight.x, topRight.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(bottomLeft.x, bottomLeft.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; t = getTriangle(bottomRight.x, bottomRight.z); if (t != null && bbox.collideWith(t, results) > 0) return 1; continue; t = getTriangle(x,z); if (t != null && bbox.collideWith(t, results) > 0) return 1;