Search in sources :

Example 6 with BoundingBox

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);
}
Also used : BoundingBox(org.sunflow.math.BoundingBox)

Example 7 with BoundingBox

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;
}
Also used : BoundingBox(org.sunflow.math.BoundingBox)

Example 8 with BoundingBox

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;
}
Also used : BoundingBox(org.sunflow.math.BoundingBox)

Example 9 with BoundingBox

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);
}
Also used : BoundingBox(org.sunflow.math.BoundingBox)

Example 10 with BoundingBox

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;
}
Also used : BoundingBox(org.sunflow.math.BoundingBox)

Aggregations

BoundingBox (org.sunflow.math.BoundingBox)14 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 FloatParameter (org.sunflow.core.ParameterList.FloatParameter)1 Color (org.sunflow.image.Color)1 Point3 (org.sunflow.math.Point3)1 Vector3 (org.sunflow.math.Vector3)1 Timer (org.sunflow.system.Timer)1 IntArray (org.sunflow.util.IntArray)1