package geometry.scene; import basics.math.algebra.Ray; import basics.math.algebra.Vector; import optics.light.Color; import optics.light.Directional; import optics.light.LightSource; import optics.light.Point; import raytracing.BasicMaterial; import renderer.mesh.BasicMesh; import renderer.mesh.Mesh; import renderer.primitive.Plane; import renderer.primitive.Sphere; import java.util.ArrayList; import java.util.List; import java.util.Optional; public class Scene { private AccelerationStructure structure; private List lights; public Scene(AccelerationStructure structure) { this.structure = structure; this.lights = new ArrayList<>(); } public static Scene generateExampleScene() { Scene scene = new Scene(new LinearList()); scene.addMesh(new BasicMesh(new BasicMaterial(new Color(0.8, 0.4, 0.2), 1.0, new Color(1,0.4,0.1)), new Sphere(new Vector(2,0,0), 1.0))); scene.addMesh(new BasicMesh(new BasicMaterial(new Color(0.8, 0.4, 0.2), 0.0, new Color(1,0.4,0.1)), new Sphere(Vector.origin(), 1.0))); scene.addMesh(new BasicMesh(new BasicMaterial(new Color(1, 1, 1), 0.2, new Color(1.0)), new Plane(new Vector(1, 0, 0), 1.0))); scene.addMesh(new BasicMesh(new BasicMaterial(new Color(1, 1, 1), 0.0, new Color(1.0)), new Plane(new Vector(0, 1, 0), 1.0))); scene.addLight(new Point(new Color(0.9, 0, 0), new Vector(8,3,-2))); scene.addLight(new Point(new Color(0,0.8,0), new Vector(4,3,2))); //scene.addLight(new Directional(new Color(1), new Vector(1, 1, 0).normalize())); return scene; } public void addLight(LightSource light) { this.lights.add(light); } public void addMesh(Mesh mesh) { this.structure.addMesh(mesh); } public Optional intersect(Ray ray) { return this.structure.intersect(ray); } public List getLights() { return lights; } }