add overloaded constructor to Box

main
jbb01 6 months ago
parent ed9e50b8f2
commit c0dccbbd0c

@ -162,13 +162,14 @@ public class Examples {
return new Example( return new Example(
new Scene(List.of( new Scene(List.of(
new Box( new Box(new Vec3(0, 0, 0), new Vec3(555, 555, 555), white, white, red, green, white, null),
new AABB(new Vec3(0, 0, 0), new Vec3(555, 555, 555)),
white, white, red, green, white, null
),
new Parallelogram(new Vec3(343, 554, 332), new Vec3(-130, 0, 0), new Vec3(0, 0, -105), light), new Parallelogram(new Vec3(343, 554, 332), new Vec3(-130, 0, 0), new Vec3(0, 0, -105), light),
new Box(new Vec3(0, 0, 0), new Vec3(165, 330, 165), white).rotateY(Math.toRadians(15)).translate(new Vec3(265, 0, 295)), new Box(new Vec3(0, 0, 0), new Vec3(165, 330, 165), white)
new Box(new Vec3(0, 0, 0), new Vec3(165, 165, 165), white).rotateY(Math.toRadians(-18)).translate(new Vec3(130, 0, 65)) .rotateY(Math.toRadians(15))
.translate(new Vec3(265, 0, 295)),
new Box(new Vec3(0, 0, 0), new Vec3(165, 165, 165), white)
.rotateY(Math.toRadians(-18))
.translate(new Vec3(130, 0, 65))
)), )),
SimpleCamera.builder() SimpleCamera.builder()
.withImage(height, height) .withImage(height, height)
@ -188,17 +189,18 @@ public class Examples {
return new Example( return new Example(
new Scene(List.of( new Scene(List.of(
new Box( new Box(new Vec3(0, 0, 0), new Vec3(555, 555, 555), white, white, red, green, white, null),
new AABB(new Vec3(0, 0, 0), new Vec3(555, 555, 555)),
white, white, red, green, white, null
),
new Parallelogram(new Vec3(113, 554, 127), new Vec3(330, 0, 0), new Vec3(0, 0, 305), light), new Parallelogram(new Vec3(113, 554, 127), new Vec3(330, 0, 0), new Vec3(0, 0, 305), light),
new ConstantMedium( new ConstantMedium(
new Box(new Vec3(0, 0, 0), new Vec3(165, 330, 165), white).rotateY(Math.toRadians(15)).translate(new Vec3(265, 0, 295)), new Box(new Vec3(0, 0, 0), new Vec3(165, 330, 165), white)
.rotateY(Math.toRadians(15))
.translate(new Vec3(265, 0, 295)),
0.01, new IsotropicMaterial(Color.BLACK) 0.01, new IsotropicMaterial(Color.BLACK)
), ),
new ConstantMedium( new ConstantMedium(
new Box(new Vec3(0, 0, 0), new Vec3(165, 165, 165), white).rotateY(Math.toRadians(-18)).translate(new Vec3(130, 0, 65)), new Box(new Vec3(0, 0, 0), new Vec3(165, 165, 165), white)
.rotateY(Math.toRadians(-18))
.translate(new Vec3(130, 0, 65)),
0.01, new IsotropicMaterial(Color.WHITE) 0.01, new IsotropicMaterial(Color.WHITE)
) )
)), )),
@ -218,18 +220,13 @@ public class Examples {
var white = new LambertianMaterial(new Color(.73, .73, .73)); var white = new LambertianMaterial(new Color(.73, .73, .73));
var green = new LambertianMaterial(new Color(.12, .45, .15)); var green = new LambertianMaterial(new Color(.12, .45, .15));
var light = new DiffuseLight(new Color(7.0, 7.0, 7.0)); var light = new DiffuseLight(new Color(7.0, 7.0, 7.0));
var aluminum = new MetallicMaterial(new Color(0.8, 0.85, 0.88));
var glass = new DielectricMaterial(1.5); var glass = new DielectricMaterial(1.5);
var room = new Box( var room = new Box(new Vec3(0, 0, 0), new Vec3(555, 555, 555), white, white, red, green, white, null);
new AABB(new Vec3(0, 0, 0), new Vec3(555, 555, 555)),
white, white, red, green, white, null
);
var lamp = new Parallelogram(new Vec3(343, 554, 332), new Vec3(-130, 0, 0), new Vec3(0, 0, -105), light); var lamp = new Parallelogram(new Vec3(343, 554, 332), new Vec3(-130, 0, 0), new Vec3(0, 0, -105), light);
var box = new Box( var box = new Box(new Vec3(0, 0, 0), new Vec3(165, 330, 165), white)
new AABB(new Vec3(0, 0, 0), new Vec3(165, 330, 165)), .rotateY(Math.toRadians(15))
white, white, white, white, white, aluminum .translate(new Vec3(265, 0, 295));
).rotateY(Math.toRadians(15)).translate(new Vec3(265, 0, 295));
var sphere = new Sphere(new Vec3(190, 90, 190), 90, glass); var sphere = new Sphere(new Vec3(190, 90, 190), 90, glass);
return new Example( return new Example(

@ -28,6 +28,15 @@ public final class Box implements Hittable, Target {
this(box, Objects.requireNonNull(material, "material"), material, material, material, material, material); this(box, Objects.requireNonNull(material, "material"), material, material, material, material, material);
} }
public Box(
@NotNull Vec3 a, @NotNull Vec3 b,
@Nullable Material top, @Nullable Material bottom,
@Nullable Material left, @Nullable Material right,
@Nullable Material front, @Nullable Material back
) {
this(new AABB(a, b), top, bottom, left, right, front, back);
}
public Box( public Box(
@NotNull AABB box, @NotNull AABB box,
@Nullable Material top, @Nullable Material bottom, @Nullable Material top, @Nullable Material bottom,

Loading…
Cancel
Save