Esempio n. 1
0
            private void buildCornellBox()
            {
                // camera
                parameter("eye", new Point3(0, 0, -600));
                parameter("target", new Point3(0, 0, 0));
                parameter("up", new Vector3(0, 1, 0));
                parameter("fov", 45.0f);
                camera("main_camera", new PinholeLens());
                parameter("camera", "main_camera");
                options(SunflowAPI.DEFAULT_OPTIONS);
                // cornell box
                Color gray = new Color(0.70f, 0.70f, 0.70f);
                Color blue = new Color(0.25f, 0.25f, 0.80f);
                Color red = new Color(0.80f, 0.25f, 0.25f);
                Color emit = new Color(15, 15, 15);

                float minX = -200;
                float maxX = 200;
                float minY = -160;
                float maxY = minY + 400;
                float minZ = -250;
                float maxZ = 200;

                float[] verts = new float[] { minX, minY, minZ, maxX, minY, minZ,
                    maxX, minY, maxZ, minX, minY, maxZ, minX, maxY, minZ, maxX,
                    maxY, minZ, maxX, maxY, maxZ, minX, maxY, maxZ, };
                int[] indices = new int[] { 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, 1,
                    2, 5, 5, 6, 2, 2, 3, 6, 6, 7, 3, 0, 3, 4, 4, 7, 3 };

                parameter("diffuse", gray);
                shader("gray_shader", new DiffuseShader());
                parameter("diffuse", red);
                shader("red_shader", new DiffuseShader());
                parameter("diffuse", blue);
                shader("blue_shader", new DiffuseShader());

                // build walls
                parameter("triangles", indices);
                parameter("points", "point", "vertex", verts);
                parameter("faceshaders", new int[] { 0, 0, 0, 0, 1, 1, 0, 0, 2, 2 });
                geometry("walls", new TriangleMesh());

                // instance walls
                parameter("shaders", new string[] { "gray_shader", "red_shader",
                    "blue_shader" });
                instance("walls.instance", "walls");

                // create mesh light
                parameter("points", "point", "vertex", new float[] { -50, maxY - 1,
                    -50, 50, maxY - 1, -50, 50, maxY - 1, 50, -50, maxY - 1, 50 });
                parameter("triangles", new int[] { 0, 1, 2, 2, 3, 0 });
                parameter("radiance", emit);
                parameter("samples", 8);
                TriangleMeshLight light = new TriangleMeshLight();
                light.init("light", this);

                // spheres
                parameter("eta", 1.6f);
                shader("Glass", new GlassShader());
                sphere("glass_sphere", "Glass", -120, minY + 55, -150, 50);
                parameter("color", new Color(0.70f, 0.70f, 0.70f));
                shader("Mirror", new MirrorShader());
                sphere("mirror_sphere", "Mirror", 100, minY + 60, -50, 50);

                // scanned model
                geometry("teapot", (ITesselatable)new Teapot());
                parameter("transform", Matrix4.translation(80, -50, 100).multiply(Matrix4.rotateX((float)-Math.PI / 6)).multiply(Matrix4.rotateY((float)Math.PI / 4)).multiply(Matrix4.rotateX((float)-Math.PI / 2).multiply(Matrix4.scale(1.2f))));
                parameter("shaders", "gray_shader");
                instance("teapot.instance1", "teapot");
                parameter("transform", Matrix4.translation(-80, -160, 50).multiply(Matrix4.rotateY((float)Math.PI / 4)).multiply(Matrix4.rotateX((float)-Math.PI / 2).multiply(Matrix4.scale(1.2f))));
                parameter("shaders", "gray_shader");
                instance("teapot.instance2", "teapot");
            }
Esempio n. 2
0
            private void buildCornellBox()
            {
                // camera
                parameter("eye", new Point3(0, 0, -600));
                parameter("target", new Point3(0, 0, 0));
                parameter("up", new Vector3(0, 1, 0));
                parameter("fov", 45.0f);
                camera("main_camera", new PinholeLens());
                parameter("camera", "main_camera");
                options(SunflowAPI.DEFAULT_OPTIONS);
                // cornell box
                Color gray = new Color(0.70f, 0.70f, 0.70f);
                Color blue = new Color(0.25f, 0.25f, 0.80f);
                Color red  = new Color(0.80f, 0.25f, 0.25f);
                Color emit = new Color(15, 15, 15);

                float minX = -200;
                float maxX = 200;
                float minY = -160;
                float maxY = minY + 400;
                float minZ = -250;
                float maxZ = 200;

                float[] verts = new float[] { minX, minY, minZ, maxX, minY, minZ,
                                              maxX, minY, maxZ, minX, minY, maxZ, minX, maxY, minZ, maxX,
                                              maxY, minZ, maxX, maxY, maxZ, minX, maxY, maxZ, };
                int[] indices = new int[] { 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, 1,
                                            2, 5, 5, 6, 2, 2, 3, 6, 6, 7, 3, 0, 3, 4, 4, 7, 3 };

                parameter("diffuse", gray);
                shader("gray_shader", new DiffuseShader());
                parameter("diffuse", red);
                shader("red_shader", new DiffuseShader());
                parameter("diffuse", blue);
                shader("blue_shader", new DiffuseShader());

                // build walls
                parameter("triangles", indices);
                parameter("points", "point", "vertex", verts);
                parameter("faceshaders", new int[] { 0, 0, 0, 0, 1, 1, 0, 0, 2, 2 });
                geometry("walls", new TriangleMesh());

                // instance walls
                parameter("shaders", new string[] { "gray_shader", "red_shader",
                                                    "blue_shader" });
                instance("walls.instance", "walls");

                // create mesh light
                parameter("points", "point", "vertex", new float[] { -50, maxY - 1,
                                                                     -50, 50, maxY - 1, -50, 50, maxY - 1, 50, -50, maxY - 1, 50 });
                parameter("triangles", new int[] { 0, 1, 2, 2, 3, 0 });
                parameter("radiance", emit);
                parameter("samples", 8);
                TriangleMeshLight light = new TriangleMeshLight();

                light.init("light", this);

                // spheres
                parameter("eta", 1.6f);
                shader("Glass", new GlassShader());
                sphere("glass_sphere", "Glass", -120, minY + 55, -150, 50);
                parameter("color", new Color(0.70f, 0.70f, 0.70f));
                shader("Mirror", new MirrorShader());
                sphere("mirror_sphere", "Mirror", 100, minY + 60, -50, 50);

                // scanned model
                geometry("teapot", (ITesselatable) new Teapot());
                parameter("transform", Matrix4.translation(80, -50, 100).multiply(Matrix4.rotateX((float)-Math.PI / 6)).multiply(Matrix4.rotateY((float)Math.PI / 4)).multiply(Matrix4.rotateX((float)-Math.PI / 2).multiply(Matrix4.scale(1.2f))));
                parameter("shaders", "gray_shader");
                instance("teapot.instance1", "teapot");
                parameter("transform", Matrix4.translation(-80, -160, 50).multiply(Matrix4.rotateY((float)Math.PI / 4)).multiply(Matrix4.rotateX((float)-Math.PI / 2).multiply(Matrix4.scale(1.2f))));
                parameter("shaders", "gray_shader");
                instance("teapot.instance2", "teapot");
            }