public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); for (int i = 0, i3 = 0; i < n; i++, i3 += 3) bounds.include(particles[i3], particles[i3 + 1], particles[i3 + 2]); bounds.include(bounds.getMinimum().x - r, bounds.getMinimum().y - r, bounds.getMinimum().z - r); bounds.include(bounds.getMaximum().x + r, bounds.getMaximum().y + r, bounds.getMaximum().z + r); return o2w == null ? bounds : o2w.transform(bounds); }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); foreach (Instance i in instances) bounds.include(i.getBounds()); foreach (Instance i in lights) bounds.include(i.getBounds()); return bounds; }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); if (o2w == null) { for (int i = 0; i < patches.Length; i++) { float[] patch = patches[i]; for (int j = 0; j < patch.Length; j += 3) bounds.include(patch[j], patch[j + 1], patch[j + 2]); } } else { // transform vertices first for (int i = 0; i < patches.Length; i++) { float[] patch = patches[i]; for (int j = 0; j < patch.Length; j += 3) { float x = patch[j]; float y = patch[j + 1]; float z = patch[j + 2]; float wx = o2w.transformPX(x, y, z); float wy = o2w.transformPY(x, y, z); float wz = o2w.transformPZ(x, y, z); bounds.include(wx, wy, wz); } } } return bounds; }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(minX, minY, minZ); bounds.include(maxX, maxY, maxZ); if (o2w == null) return bounds; return o2w.transform(bounds); }
/** * Transforms each corner of the specified axis-aligned bounding box and * returns a new bounding box which incloses the transformed corners. * * @param b original bounding box * @return a new BoundingBox object which encloses the transform version of * b */ public BoundingBox transform(BoundingBox b) { if (b.isEmpty()) { return(new BoundingBox()); } // special case extreme corners BoundingBox rb = new BoundingBox(transformP(b.getMinimum())); rb.include(transformP(b.getMaximum())); // do internal corners for (int i = 1; i < 7; i++) { rb.include(transformP(b.getCorner(i))); } return(rb); }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(-ro - ri, -ro - ri, -ri); bounds.include(ro + ri, ro + ri, ri); if (o2w != null) bounds = o2w.transform(bounds); return bounds; }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); if (o2w == null) { for (int i = 0; i < points.Length; i += 3) bounds.include(points[i], points[i + 1], points[i + 2]); } else { // transform vertices first for (int i = 0; i < points.Length; i += 3) { float x = points[i]; float y = points[i + 1]; float z = points[i + 2]; float wx = o2w.transformPX(x, y, z); float wy = o2w.transformPY(x, y, z); float wz = o2w.transformPZ(x, y, z); bounds.include(wx, wy, wz); } } return bounds; }
public bool update(ParameterList pl, SunflowAPI api) { ParameterList.FloatParameter pts = pl.getPointArray("points"); if (pts != null) { BoundingBox bounds = new BoundingBox(); for (int i = 0; i < pts.data.Length; i += 3) bounds.include(pts.data[i], pts.data[i + 1], pts.data[i + 2]); // cube extents minX = bounds.getMinimum().x; minY = bounds.getMinimum().y; minZ = bounds.getMinimum().z; maxX = bounds.getMaximum().x; maxY = bounds.getMaximum().y; maxZ = bounds.getMaximum().z; } return true; }
/** * Recompute world space bounding box of this instance. */ public void updateBounds() { bounds = geometry.getWorldBounds(o2w.getData(0)); for (int i = 1; i < o2w.numSegments(); i++) bounds.include(geometry.getWorldBounds(o2w.getData(i))); }
private void updateGeometry(Point3 c0, Point3 c1) { // figure out cube extents lightBounds = new BoundingBox(c0); lightBounds.include(c1); // cube extents minX = lightBounds.getMinimum().x; minY = lightBounds.getMinimum().y; minZ = lightBounds.getMinimum().z; maxX = lightBounds.getMaximum().x; maxY = lightBounds.getMaximum().y; maxZ = lightBounds.getMaximum().z; // work around epsilon problems for light test lightBounds.enlargeUlps(); // light source geometry lxmin = maxX / 3 + 2 * minX / 3; lxmax = minX / 3 + 2 * maxX / 3; lymin = maxY / 3 + 2 * minY / 3; lymax = minY / 3 + 2 * maxY / 3; area = (lxmax - lxmin) * (lymax - lymin); }
public bool intersects(BoundingBox box) { // this could be optimized BoundingBox b = new BoundingBox(); b.include(new Point3(minX, minY, minZ)); b.include(new Point3(maxX, maxY, maxZ)); if (b.intersects(box)) { // the box is overlapping or enclosed if (!b.contains(new Point3(box.getMinimum().x, box.getMinimum().y, box.getMinimum().z))) return true; if (!b.contains(new Point3(box.getMinimum().x, box.getMinimum().y, box.getMaximum().z))) return true; if (!b.contains(new Point3(box.getMinimum().x, box.getMaximum().y, box.getMinimum().z))) return true; if (!b.contains(new Point3(box.getMinimum().x, box.getMaximum().y, box.getMaximum().z))) return true; if (!b.contains(new Point3(box.getMaximum().x, box.getMinimum().y, box.getMinimum().z))) return true; if (!b.contains(new Point3(box.getMaximum().x, box.getMinimum().y, box.getMaximum().z))) return true; if (!b.contains(new Point3(box.getMaximum().x, box.getMaximum().y, box.getMinimum().z))) return true; if (!b.contains(new Point3(box.getMaximum().x, box.getMaximum().y, box.getMaximum().z))) return true; // all vertices of the box are inside - the surface of the box is // not intersected } return false; }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); if (o2w == null) { for (int i = 0; i < triangleMesh.uvs.data.Length; i += 2) bounds.include(triangleMesh.uvs.data[i], triangleMesh.uvs.data[i + 1], 0); } else { // transform vertices first for (int i = 0; i < triangleMesh.uvs.data.Length; i += 2) { float x = triangleMesh.uvs.data[i]; float y = triangleMesh.uvs.data[i + 1]; float wx = o2w.transformPX(x, y, 0); float wy = o2w.transformPY(x, y, 0); float wz = o2w.transformPZ(x, y, 0); bounds.include(wx, wy, wz); } } return bounds; }
public BoundingBox getWorldBounds(Matrix4 o2w) { BoundingBox bounds = new BoundingBox(); for (int i = 0, j = 0; i < points.Length; i += 3, j++) { float w = 0.5f * getWidth(j); bounds.include(points[i] - w, points[i + 1] - w, points[i + 2] - w); bounds.include(points[i] + w, points[i + 1] + w, points[i + 2] + w); } if (o2w != null) bounds = o2w.transform(bounds); return bounds; }
/** * Transforms each corner of the specified axis-aligned bounding box and * returns a new bounding box which incloses the transformed corners. * * @param b original bounding box * @return a new BoundingBox object which encloses the transform version of * b */ public BoundingBox transform(BoundingBox b) { if (b.isEmpty()) return new BoundingBox(); // special case extreme corners BoundingBox rb = new BoundingBox(transformP(b.getMinimum())); rb.include(transformP(b.getMaximum())); // do internal corners for (int i = 1; i < 7; i++) rb.include(transformP(b.getCorner(i))); return rb; }