use of org.sunflow.math.BoundingBox in project joons-renderer by joonhyublee.
the class CornellBox method updateGeometry.
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);
}
use of org.sunflow.math.BoundingBox in project joons-renderer by joonhyublee.
the class Torus method getWorldBounds.
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;
}
use of org.sunflow.math.BoundingBox in project joons-renderer by joonhyublee.
the class BezierMesh method getWorldBounds.
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;
}
use of org.sunflow.math.BoundingBox in project joons-renderer by joonhyublee.
the class Box method getWorldBounds.
@Override
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);
}
use of org.sunflow.math.BoundingBox in project joons-renderer by joonhyublee.
the class TriangleMesh method getWorldBounds.
@Override
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;
}
Aggregations