Search in sources :

Example 1 with DirectionalLight

use of raytracer.lights.DirectionalLight in project narchy by automenta.

the class RaytracerFrame method changeScene.

/**
 * �ndert die Szene.
 *
 * @param sceneId ID der neuen Szene.
 */
public void changeScene(int sceneId) {
    Scene scene;
    switch(sceneId) {
        case // FlatShader
        0:
            final Sphere s = new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ColorShader(ColorEx.RED));
            scene = new EfficientScene() {

                final double start = System.currentTimeMillis();

                @Override
                public boolean update(double t) {
                    // add(s);
                    return false;
                }
            };
            scene.add(s);
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new ColorShader(ColorEx.GREEN)));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new ColorShader(ColorEx.BLUE)));
            scene.add(new InfinitePlane(new Vector3d(0.0, -1.0, 0.0), new Vector3d(0.0, 1.0, 0.0), new ColorShader(ColorEx.YELLOW)));
            // scene.add(new InfinitePlane(new Vector3d(0.0, -1.0, 0.0), new Vector3d(0.0, 1.0, 0.0), new WallShader(ColorEx.WHITE)));
            break;
        case // EyeLightShader
        1:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new EyeLightShader(new ColorShader(ColorEx.RED))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new EyeLightShader(new ColorShader(ColorEx.GREEN))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new EyeLightShader(new ColorShader(ColorEx.BLUE))));
            scene.add(new InfinitePlane(new Vector3d(0.0, -1.0, 0.0), new Vector3d(0.0, 1.0, 0.0), new EyeLightShader(new ColorShader(ColorEx.YELLOW))));
            break;
        case // FirstPhongShader
        2:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new InfinitePlane(new Vector3d(0.0, -1.0, 0.0), new Vector3d(0.0, 1.0, 0.0), new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            break;
        case // Dreiecke
        3:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            break;
        case // DirectionalLight
        4:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
            scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
            break;
        case // PointLight
        5:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
            scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            break;
        case // Shadow
        6:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
            scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
            scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            break;
        case // MirrorShader
        7:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new MirrorShader()));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
            scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
            scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
            scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            break;
        case // ReflectiveShader
        8:
            scene = new EfficientScene();
            scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ReflectiveShader(0.2f, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            scene.add(new Sphere(new Vector3d(1.0, -1.0, -1.0), 2.2, new ReflectiveShader(0.2f, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.0f, 0.9f, 0.0f), new Vector3f(0.0f, 0.4f, 0.2f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new ReflectiveShader(0.2f, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectiveShader(0.2f, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectiveShader(0.2f, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
            scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
            scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            break;
        case // Diamant (FirstPhongShader)
        9:
            try {
                Transformation t = new Transformation();
                t.scale(0.9, 0.9, 0.9);
                t.move(1.0, 1.0, -3.0);
                OffObject off = new OffObject("off/dodecahedron.off", new ConcatShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.3f, 0.7f, 0.4f), new Vector3f(0.4f, 1.0f, 0.5f), new Vector3f(0.0f, 0.0f, 0.0f)), 0.7f, new RefractionShader(RefractionShader.INDEX_DIAMOND, new ColorEx(0.85f, 0.99f, 0.85f))));
                off.transform(t);
                scene = new EfficientScene();
                scene.add(off);
                scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ReflectionShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
                scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectionShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectionShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Diamant
        10:
            try {
                Transformation t = new Transformation();
                t.scale(0.9, 0.9, 0.9);
                t.move(1.0, 1.0, -3.0);
                OffObject off = new OffObject("off/dodecahedron.off", new ConcatShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.3f, 0.7f, 0.4f), new Vector3f(0.4f, 1.0f, 0.5f), new Vector3f(0.0f, 0.0f, 0.0f)), 0.7f, new RefractionShader(RefractionShader.INDEX_DIAMOND, new ColorEx(0.85f, 0.99f, 0.85f))));
                off.transform(t);
                scene = new EfficientScene();
                scene.add(off);
                scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new ReflectionShader(new PhongShader(new TextureShader("texture/earth.jpg"), new Vector3f(0.2f, 0.2f, 0.2f), new Vector3f(0.6f, 0.6f, 0.6f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.0f, 0.0f, 0.0f)))));
                scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
                scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
                scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Venus
        11:
            try {
                Transformation t = new Transformation();
                t.rotate(90.0, 0.0, 1.0, 0.0);
                t.scale(2.0, 2.0, 2.0);
                t.move(2.0, 2.0, -2.0);
                OffObject off = new OffObject("off/venus.off", new ConcatShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.3f, 0.7f, 0.4f), new Vector3f(0.4f, 1.0f, 0.5f), new Vector3f(0.0f, 0.0f, 0.0f)), 0.7f, new RefractionShader(RefractionShader.INDEX_DIAMOND, new ColorEx(0.85f, 0.99f, 0.85f))));
                off.transform(t);
                scene = new EfficientScene();
                scene.add(off);
                scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.5f, 0.2f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
                scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.05f, 0.05f, 0.05f)))));
                scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
                scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
                scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(20.0f, 20.0f, 20.0f)));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Hase
        12:
            try {
                Transformation t = new Transformation();
                String texture = "texture/synth11.jpg";
                Triangle t1 = new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectionShader(new PhongShader(new TextureShader(texture), new Vector3f(0.1f, 0.1f, 0.1f), new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.0f, 0.0f, 0.0f))));
                Triangle t2 = new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectionShader(new PhongShader(new TextureShader(texture), new Vector3f(0.1f, 0.1f, 0.1f), new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.0f, 0.0f, 0.0f))));
                t1.setTextureCoords(new Vector2d(1.0, 1.0), new Vector2d(1.0, 0.0), new Vector2d(0.0, 0.0));
                t2.setTextureCoords(new Vector2d(0.0, 0.0), new Vector2d(0.0, 1.0), new Vector2d(1.0, 1.0));
                t.reset();
                t.scale(1.5, 1.5, 0.0);
                t1.transformTexture(t);
                t2.transformTexture(t);
                PlyObject ply = new PlyObject("ply/bunny.ply", new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.1f, 0.0f), new Vector3f(0.0f, 0.4f, 0.0f), new Vector3f(0.0f, 0.7f, 0.2f), new Vector3f(0.0f, 0.0f, 0.0f)));
                ply.normalize();
                t.reset();
                t.scale(3.0, 3.0, 3.0);
                t.move(2.0, 1.3, -3.5);
                ply.transform(t);
                scene = new EfficientScene();
                scene.add(new Sphere(new Vector3d(), 30.0, new TextureShader("texture/univ02.jpg")));
                scene.add(ply);
                scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ConcatShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.1f, 0.0f, 0.0f), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(1.0f, 0.4f, 0.2f), new Vector3f(0.0f, 0.0f, 0.0f)), 0.8f, new RefractionShader(RefractionShader.INDEX_GLASS, new ColorEx(0.95f, 0.85f, 0.85f)))));
                scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.05f, 0.05f, 0.05f))));
                scene.add(t1);
                scene.add(t2);
                scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
                // scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
                scene.add(new PointLight(new Vector3d(-7.0, 4.0, -7.0), new ColorEx(10.0f, 10.0f, 10.0f)));
                scene.add(new PointLight(new Vector3d(-7.0, 4.0, 7.0), new ColorEx(6.0f, 6.0f, 6.0f)));
                scene.add(new PointLight(new Vector3d(7.0, 4.0, 7.0), new ColorEx(8.0f, 8.0f, 8.0f)));
                scene.add(new PointLight(new Vector3d(7.0, 4.0, -7.0), new ColorEx(11.0f, 11.0f, 11.0f)));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Soft-Shadows
        13:
            try {
                Transformation t = new Transformation();
                t.scale(0.9, 0.9, 0.9);
                t.move(1.0, 1.0, -3.0);
                // OffObject off = new OffObject("off/cube.off", new ConcatShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(1.0f, 1.0f, 1.0f)), 1.0f, new RefractionShader(RefractionShader.INDEX_DIAMOND, new ColorEx(ColorEx.WHITE))));
                OffObject off = new OffObject("off/cube.off", new ConcatShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.3f, 0.7f, 0.4f), new Vector3f(0.4f, 0.4f, 0.4f), new Vector3f(0.0f, 0.0f, 0.0f), 5.0F), 0.0f, new RefractionShader(RefractionShader.INDEX_DIAMOND, new ColorEx(ColorEx.WHITE))));
                // OffObject off = new OffObject("off/dodecahedron.off", new ConcatShader(new FirstPhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.3f, 0.0f), new Vector3f(0.3f, 0.7f, 0.4f), new Vector3f(0.4f, 1.0f, 0.5f), new Vector3f(0.0f, 0.0f, 0.0f)), 0.7f, new RefractionShader(RefractionShader.SOL_DIAMOND, new ColorEx(0.85f, 0.99f, 0.85f))));
                off.transform(t);
                scene = new EfficientScene();
                // scene.add(off);
                scene.add(new Sphere(new Vector3d(-2.0, 1.7, 0.0), 2.0, new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.5f, 0.0f, 0.0f), new Vector3f(0.7f, 0.0f, 0.0f), new Vector3f(0.7f, 0.7f, 0.7f), new Vector3f(0.05f, 0.05f, 0.05f), 10.0F))));
                scene.add(new Sphere(new Vector3d(3.0, 0.8, 2.0), 2.0, new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.3f), new Vector3f(0.0f, 0.0f, 0.5f), new Vector3f(0.7f, 0.7f, 0.7f), new Vector3f(0.05f, 0.05f, 0.05f), 10.0F)));
                scene.add(new Triangle(new Vector3d(-7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, -7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.4f, 0.4f, 0.4f), new Vector3f(0.05f, 0.05f, 0.05f), 5.0F))));
                scene.add(new Triangle(new Vector3d(7.0, -1.0, -7.0), new Vector3d(7.0, -1.0, 7.0), new Vector3d(-7.0, -1.0, 7.0), new ReflectionShader(new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.0f, 0.0f, 0.0f), new Vector3f(0.9f, 0.9f, 0.0f), new Vector3f(0.4f, 0.4f, 0.4f), new Vector3f(0.05f, 0.05f, 0.05f), 5.0F))));
                scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
                // scene.add(new DirectionalLight(new Vector3d(1.0,-1.0,0.0), new ColorEx(0.1f, 0.1f, 0.1f)));
                // scene.add(new PointLight(new Vector3d(-7.0,4.0,-7.0), new ColorEx(10.0f, 10.0f, 10.0f)));
                // scene.add(new AreaLight(new Vector3d(0.0,8.0,0.0),new Vector3d(1.5,0.0,0.0),new Vector3d(0.0,0.0,1.5), new ColorEx(0.8f, 0.8f, 0.8f)));
                // scene.add(new Sphere(new Vector3d(1.0,2.0,0.0), 0.25 , new LightSourceShader(new ColorEx(1.0f, 1.0f, 1.0f))));
                // scene.add(new AreaLight(new Vector3d(1.0, 3.0, 0.0), new Vector3d(0.5, 0.0, 0.0), new Vector3d(0.0, 0.0, 3.0), new ColorEx(12.0f, 12.0f, 12.0f)));
                scene.add(new SphereLight(new Vector3d(1.0, 3.0, 0.0), 0.7, new ColorEx(12.0f, 12.0f, 12.0f)));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Lichtbrechungs-Test
        14:
            try {
                scene = new EfficientScene();
                Shader wallRed = new PhongShader(new ColorShader(ColorEx.RED), new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.7f, 0.7f, 0.7f));
                Shader wallBlue = new PhongShader(new ColorShader(ColorEx.BLUE), new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.7f, 0.7f, 0.7f));
                Shader wallGray = new PhongShader(new ColorShader(ColorEx.GRAY), new Vector3f(0.5f, 0.5f, 0.5f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.7f, 0.7f, 0.7f));
                // Linke Wand:
                scene.add(new Triangle(new Vector3d(-1.0, -1.0, 1.0), new Vector3d(-1.0, -1.0, -1.0), new Vector3d(-1.0, 1.0, 1.0), wallRed));
                scene.add(new Triangle(new Vector3d(-1.0, 1.0, 1.0), new Vector3d(-1.0, -1.0, -1.0), new Vector3d(-1.0, 1.0, -1.0), wallRed));
                // Rechte Wand:
                scene.add(new Triangle(new Vector3d(1.0, -1.0, -1.0), new Vector3d(1.0, -1.0, 1.0), new Vector3d(1.0, 1.0, 1.0), wallBlue));
                scene.add(new Triangle(new Vector3d(1.0, 1.0, 1.0), new Vector3d(1.0, 1.0, -1.0), new Vector3d(1.0, -1.0, -1.0), wallBlue));
                // Hintere Wand:
                scene.add(new Triangle(new Vector3d(-1.0, -1.0, -1.0), new Vector3d(1.0, -1.0, -1.0), new Vector3d(-1.0, 1.0, -1.0), wallGray));
                scene.add(new Triangle(new Vector3d(-1.0, 1.0, -1.0), new Vector3d(1.0, -1.0, -1.0), new Vector3d(1.0, 1.0, -1.0), wallGray));
                // Obere Wand:
                scene.add(new Triangle(new Vector3d(-1.0, 1.0, 1.0), new Vector3d(-1.0, 1.0, -1.0), new Vector3d(1.0, 1.0, 1.0), wallGray));
                scene.add(new Triangle(new Vector3d(1.0, 1.0, 1.0), new Vector3d(-1.0, 1.0, -1.0), new Vector3d(1.0, 1.0, -1.0), wallGray));
                // Untere Wand:
                scene.add(new Triangle(new Vector3d(-1.0, -1.0, 1.0), new Vector3d(1.0, -1.0, 1.0), new Vector3d(-1.0, -1.0, -1.0), wallGray));
                scene.add(new Triangle(new Vector3d(-1.0, -1.0, -1.0), new Vector3d(1.0, -1.0, 1.0), new Vector3d(1.0, -1.0, -1.0), wallGray));
                // Licht:
                scene.add(new AreaLight(new Vector3d(0.0, 0.999999, 0.0), new Vector3d(0.2, 0.0, 0.0), new Vector3d(0.0, 0.0, 0.2), new ColorEx(3.0f, 3.0f, 3.0f)));
                // Kugel mit Spiegelung:
                Sphere rs = new Sphere(new Vector3d(-0.5, -0.65, -0.5), 0.35, new MirrorShader());
                rs.setNormalEffect(new RoughNormalEffect(0.03f));
                scene.add(rs);
                // Kugel mit Lichtbrechung:
                rs = new Sphere(new Vector3d(0.5, -0.65, 0.0), 0.35, new RefractionShader(RefractionShader.INDEX_GLASS, new ColorEx(0.9f, 0.9f, 0.9f)));
                rs.setNormalEffect(new RoughNormalEffect(0.1f));
                scene.add(rs);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        case // Bowling-Szene
        15:
            scene = new BowlingScene();
            break;
        case // Bowling-Kugel
        16:
            try {
                Transformation t = new Transformation();
                t.scale(3.0, 3.0, 3.0);
                t.rotate(190.0, 1.0, 0.0, 0.0);
                PlyObject ply = new PlyObject("ply/bowl.ply", new PhongShader(new ColorShader(ColorEx.WHITE), new Vector3f(0.1f, 0.1f, 0.1f), new Vector3f(0.4f, 0.4f, 0.4f), new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(0.0f, 0.0f, 0.0f)), true, new RoughNormalEffect(0.2f));
                ply.center();
                ply.transform(t);
                scene = new EfficientScene();
                scene.add(ply);
                scene.setAmbientLight(new ColorEx(0.2f, 0.2f, 0.2f));
                // scene.add(new DirectionalLight(new Vector3d(1.0, -1.0, 0.0), new ColorEx(0.8f, 0.8f, 0.8f)));
                scene.add(new PointLight(new Vector3d(-7.0, 1.0, -7.0), new ColorEx(5.0f, 5.0f, 5.0f)));
                scene.add(new PointLight(new Vector3d(-7.0, 1.0, 7.0), new ColorEx(3.0f, 3.0f, 3.0f)));
                scene.add(new PointLight(new Vector3d(7.0, 1.0, 7.0), new ColorEx(4.0f, 4.0f, 4.0f)));
                scene.add(new PointLight(new Vector3d(7.0, 1.0, -7.0), new ColorEx(5.5f, 5.5f, 5.5f)));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        default:
            throw new IllegalArgumentException();
    }
    // Szene setzen:
    setCameraScene(this.camera, scene);
    this.sceneId = sceneId;
}
Also used : SphereLight(raytracer.lights.SphereLight) AreaLight(raytracer.lights.AreaLight) Vector2d(javax.vecmath.Vector2d) DirectionalLight(raytracer.lights.DirectionalLight) RoughNormalEffect(raytracer.effects.RoughNormalEffect) InvalidFormatException(raytracer.exception.InvalidFormatException) Vector3d(javax.vecmath.Vector3d) Vector3f(javax.vecmath.Vector3f) PointLight(raytracer.lights.PointLight)

Aggregations

Vector2d (javax.vecmath.Vector2d)1 Vector3d (javax.vecmath.Vector3d)1 Vector3f (javax.vecmath.Vector3f)1 RoughNormalEffect (raytracer.effects.RoughNormalEffect)1 InvalidFormatException (raytracer.exception.InvalidFormatException)1 AreaLight (raytracer.lights.AreaLight)1 DirectionalLight (raytracer.lights.DirectionalLight)1 PointLight (raytracer.lights.PointLight)1 SphereLight (raytracer.lights.SphereLight)1