Пример #1
1
        public IDisplayData AsDisplayData(ViewPlane viewplane)
        {
            try
            {
                displayData       = new DisplayData(FileName);
                displayData.Color = Color;
                foreach (PointCyl v in this)
                {
                    switch (viewplane)
                    {
                    case ViewPlane.ZR:
                        displayData.Add(new PointF((float)v.Z, (float)v.R));
                        break;

                    case ViewPlane.THETAR:
                    default:
                        displayData.Add(new PointF((float)(v.ThetaDeg), (float)v.R));

                        break;
                    }
                }

                displayData.SortByX();

                return(displayData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_FLOAT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new AreaLighting(this);

            MultiJittered sampler = new MultiJittered(vp.NumSamples);

            AmbientOccluder occluder = new AmbientOccluder();

            occluder.Color         = ColorUtils.WHITE;
            occluder.ScaleRadiance = 1.5;
            occluder.MinAmount     = 0.4f;
            occluder.Sampler       = sampler;
            AmbientLight           = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(-0.731249, -0.199999, -0.3),
                                          new Vec3(-0.562499, -0.185185, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          0.6f, 1.0f);

            Camera = pinhole;

            CreateIllumination();
            CreateWalls();
            CreateObjects();
        }
    public override void render_scene(World w)
    {
        Color     L   = Color.black;
        ViewPlane vp  = w.vp;
        Ray       ray = new Ray();
        Vector2   pp;                           // sample point on a pixel
        int       n = (int)Mathf.Sqrt((float)vp.num_samples);

        vp.s      /= zoom;
        ray.origin = eye;

        for (int r = 0; r < vp.vres; r++)         // up
        {
            for (int c = 0; c < vp.hres; c++)     // across
            {
                L = Color.black;
                for (int p = 0; p < n; p++)                                     // up pixel
                {
                    for (int q = 0; q < n; q++)
                    {                           // across pixel
                        pp.x          = vp.s * (c - 0.5f * vp.hres + (q + 0.5f) / n);
                        pp.y          = vp.s * (r - 0.5f * vp.vres + (p + 0.5f) / n);
                        ray.direction = get_direction(pp);
                        L            += w.tracer_ptr.trace_ray(ray);
                    }
                }

                L /= vp.num_samples;
                L *= exposure_time;
                w.display_pixel(r, c, L);
            }
        }
        w.texture.Apply();
    }
Пример #4
0
        public override void RenderScene(World world)
        {
            Vector3   L;
            ViewPlane vp    = new ViewPlane(world.ViewPlane);
            Ray       ray   = new Ray();
            int       depth = 0;
            Vector2   pp    = new Vector2();

            vp.S        /= Zoom;
            ray.Position = Position;
            int n = (int)MathUtil.Sqrt((float)vp.NumSamples);

            for (int r = 0; r < vp.VRes; r++)
            {
                for (int c = 0; c < vp.HRes; c++)
                {
                    L = new Vector3(0, 0, 0);
                    for (int p = 0; p < n; p++)
                    {
                        for (int q = 0; q < n; q++)
                        {
                            pp.X          = vp.S * (c - 0.5f * vp.HRes + (q + 0.5f) / n);
                            pp.Y          = vp.S * (r - 0.5f * vp.VRes + (p + 0.5f) / n);
                            ray.Direction = GetDirection(pp);
                            L            += world.Tracer.TraceRay(ray, depth);
                        }
                    }

                    L /= ((float)vp.NumSamples);
                    L *= ExposureTime;
                    world.Screen.AddPixel(r, c, L);
                }
            }
        }
Пример #5
0
        public IList <IVector3> TrimToWindow(RectangleF r, ViewPlane viewPlane)
        {
            try
            {
                var winData = new List <IVector3>();
                var dd      = AsDisplayData(viewPlane);
                foreach (var pt in dd)
                {
                    if (r.Contains(pt))
                    {
                        switch (viewPlane)
                        {
                        case ViewPlane.XY:
                            winData.Add(new Vector3(pt.X, pt.Y, 0));
                            break;

                        case ViewPlane.XZ:
                            winData.Add(new Vector3(pt.X, 0, pt.Y));
                            break;

                        case ViewPlane.YZ:
                            winData.Add(new Vector3(0, pt.X, pt.Y));
                            break;
                        }
                    }
                }
                return(winData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
        public override Ray CaculateRay(float x, float y, ViewPlane plane)
        {
            Vector3 dir = (AspectRatio * Right * x / plane.Width + Up * y / plane.Height) * fovR + Forward;
            Ray     ray = new Ray(Position, dir);

            return(ray);
        }
Пример #7
0
        public override void RenderStereo(World world, float x, int offset)
        {
            Vector3   L     = Vector3.Zero();
            ViewPlane vp    = world.ViewPlane;
            Ray       ray   = new Ray();
            int       depth = 0;
            Vector2   pp    = new Vector2();
            Vector2   sp    = new Vector2();

            vp.S        /= Zoom;
            ray.Position = Position;
            for (int r = 0; r < vp.VRes; r++)
            {
                for (int c = 0; c < vp.HRes; c++)
                {
                    L = new Vector3(0, 0, 0);
                    for (int j = 0; j < vp.NumSamples; j++)
                    {
                        sp            = vp.Sampler.SampleUnitSquare();
                        pp.X          = vp.S * (c - 0.5f * vp.HRes + sp.X) + x;
                        pp.Y          = vp.S * (r - 0.5f * vp.VRes + sp.Y);
                        ray.Direction = GetDirection(pp);
                        L            += world.Tracer.TraceRay(ray, depth);
                    }
                    L /= vp.NumSamples;
                    L *= ExposureTime;
                    world.Screen.AddPixel(r, c + offset, L);
                }
            }
        }
Пример #8
0
        public override void RenderScene(World world)
        {
            Vector3   L;
            ViewPlane vp    = (world.ViewPlane);
            int       hres  = vp.HRes;
            int       vres  = vp.VRes;
            float     s     = vp.S;
            Ray       ray   = new Ray();
            int       depth = 0;
            Vector2   sp;                                       // sample point in [0, 1] X [0, 1]
            Vector2   pp;                                       // sample point on the pixel

            ray.Position = Position;
            for (int r = 0; r < vres; r++)              // up
            {
                for (int c = 0; c < hres; c++)
                {       // across
                    L = new Vector3(0, 0, 0);

                    for (int j = 0; j < vp.NumSamples; j++)
                    {
                        sp            = vp.Sampler.SampleUnitSquare();
                        pp            = new Vector2();
                        pp.X          = s * (c - 0.5f * hres + sp.X);
                        pp.Y          = s * (r - 0.5f * vres + sp.Y);
                        ray.Direction = ray_direction(pp, hres, vres, s);
                        L            += world.Tracer.TraceRay(ray, depth);
                    }
                    L /= vp.NumSamples;
                    L *= ExposureTime;
                    world.Screen.AddPixel(r, c, L);
                }
            }
        }
Пример #9
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1920, 1080, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 144;

            backgroundColor = ColorUtils.BLACK;
            //tracer = new RayCast(this);
            tracer = new AreaLighting(this);

            AmbientOccluder a = new AmbientOccluder(ColorUtils.WHITE,
                                                    0.4, 1.5);

            a.Sampler    = new MultiJittered(vp.NumSamples);
            AmbientLight = a;

            Pinhole c = new Pinhole(new Vec3(-702, -108, 270),
                                    new Vec3(-540, -100, 0),
                                    new Vec3(0, 1, 0),
                                    800, 1.5f);

            Camera = c;



            CreateIllumination();
            CreateWalls();
            CreateObjects();
        }
Пример #10
0
        public override Vector3 RenderRay(World world, int c, int r, int n)
        {
            Vector3 L     = Vector3.Zero();
            Vector2 pp    = new Vector2();
            var     ray   = new Ray();
            int     depth = 0;

            ray.Position = Position;
            ViewPlane vp = world.ViewPlane;

            for (int p = 0; p < n; p++)
            {
                for (int q = 0; q < n; q++)
                {
                    pp.X          = vp.S * (c - 0.5f * vp.HRes + (q + 0.5f) / n);
                    pp.Y          = vp.S * (r - 0.5f * vp.VRes + (p + 0.5f) / n);
                    ray.Direction = GetDirection(pp);
                    L            += world.Tracer.TraceRay(ray, depth);
                }
            }

            L /= ((float)vp.NumSamples);
            L *= ExposureTime;
            return(L);
        }
Пример #11
0
        public override void RenderStereo(World world, float x, int offset)
        {
            Vector3   L = Vector3.Zero();
            Ray       ray = new Ray();
            ViewPlane vp = (world.ViewPlane);
            int       depth = 0;
            Vector2   sp, pp, dp, lp;                   // sample point in [0, 1] X [0, 1]

            vp.S /= Zoom;
            for (int r = 0; r < vp.VRes; r++)                   // up
            {
                for (int c = 0; c < vp.HRes; c++)
                {               // across
                    L = Vector3.Zero();
                    for (int n = 0; n < vp.NumSamples; n++)
                    {
                        sp            = vp.Sampler.SampleUnitSquare();
                        pp            = new Vector2();
                        pp.X          = vp.S * (c - vp.HRes / 2.0f + sp.X);
                        pp.Y          = vp.S * (r - vp.VRes / 2.0f + sp.Y);
                        dp            = Sampler.SampleUnitDisk();
                        lp            = dp * Radius;
                        ray.Position  = Position + lp.X * U + lp.Y * V;
                        ray.Direction = ray_direction(pp, lp);
                        L            += world.Tracer.TraceRay(ray, depth);
                    }

                    L /= vp.NumSamples;
                    L *= ExposureTime;
                    world.Screen.AddPixel(r, c + offset, L);
                }
            }
        }
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;

        vp = new ViewPlane(texture.width, texture.height, 1.0f, 1);
        background_color = Constants.black;

        tracer_ptr = new RayCastTracer(this);


        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        set_camera(pinhole_ptr1);

        Rectangle obj = new Rectangle(new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0));

        //obj.sphereCenter = Vector3.zero;
        //obj.sphereRad = 70.0f;

        add_object(obj);

        render_scene();
    }
    public override void render_scene(World w)
    {
        Color     pixel_color;
        Ray       ray  = new Ray();
        ViewPlane vp   = w.vp;
        int       hres = vp.hres;
        int       vres = vp.vres;
        float     s    = vp.s;
        float     zw   = 100.0f;                                                        // hardwired in
        Vector2   pp;
        Vector2   sp;

        ray.direction = new Vector3(0, 0, -1);

        for (int r = 0; r < vres; r++)                  // up
        {
            for (int c = 0; c <= hres; c++)             // across
            {
                pixel_color = Color.black;
                for (int j = 0; j < vp.num_samples; j++)
                {
                    sp           = vp.sample_ptr.sample_unit_square();
                    pp.x         = vp.s * (c - (0.5f * vp.hres) + sp.x);
                    pp.y         = vp.s * (r - (0.5f * vp.vres) + sp.y);
                    ray.origin   = new Vector3(pp.x, pp.y, zw);
                    pixel_color += w.tracer_ptr.trace_ray(ray);
                }
                pixel_color /= vp.num_samples;
                w.display_pixel(r, c, pixel_color);
            }
        }
        w.texture.Apply();
    }
Пример #14
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp = new ViewPlane(texture.width, texture.height, 1.0f, 256);
        background_color = Constants.black;

        tracer_ptr = new RayCastTracer(this);

        Jittered        jit    = new Jittered(256);
        AmbientOccluder ambocl = new AmbientOccluder();

        ambocl.scale_radiance(1.0f);
        ambocl.set_color(Constants.white);
        ambocl.set_minAmount(Constants.black);
        ambocl.SetSampler(jit);
        set_ambient_light(ambocl);


        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        pinhole_ptr1.set_eye(new Vector3(0, 0, 500));
        pinhole_ptr1.set_lookat(Vector3.zero);
        pinhole_ptr1.set_view_distance(600.0f);
        pinhole_ptr1.compute_uvw();
        set_camera(pinhole_ptr1);

        Directional directional = new Directional();

        directional.set_color(new Color(1, 1, 1, 1));
        directional.set_direction(new Vector3(-1, -1, 0));
        directional.cast_shadows = true;
        directional.scale_radiance(3.0f);
        add_light(directional);

        Matte mat_ptr = new Matte();

        mat_ptr.set_ka(0.25f);
        mat_ptr.set_kd(0.65f);
        mat_ptr.set_cd(new Color(1, 1, 0, 1));

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(0, 0, 0);
        sphere.sphereRad    = 20.0f;
        sphere.set_material(mat_ptr);

        Instance sphereInst = new Instance(sphere);

        sphereInst.set_material(mat_ptr);


        add_object(sphereInst);

        sphereInst.set_identity();
        sphereInst.Shear(1.15f, 0.6f, 1.2f, 1.8f, 2.2f, 2.4f);
        render_scene();
    }
Пример #15
0
    public void build()
    {
        DestroyRenderAreaTexture();

        texture = new Texture2D(200, 200);
        GameObject.Find("ViewRectangle").GetComponent <MeshRenderer> ().material.mainTexture = texture;
        vp = new ViewPlane(texture.width, texture.height, 1.0f, 100);
        background_color = Constants.black;

        tracer_ptr = new AreaLightTracer(this);

        Ambient ambLight = new Ambient();

        ambLight.set_color(new Color(1, 1, 1, 1));
        ambLight.scale_radiance(1.0f);
        set_ambient_light(ambLight);

        PerspectiveCamera pinhole_ptr1 = new PerspectiveCamera();

        set_camera(pinhole_ptr1);

        Emissive ems = new Emissive();

        ems.scale_radiance(40.0f);
        ems.set_ce(new Color(1, 0, 0, 1));

        //Create Sky Object
        Sky sky = new Sky();

        sky.sphereCenter = new Vector3(0, 0, 0);
        sky.sphereRad    = 20000.0f;
        sky.set_material(ems);
        add_object(sky);

        //Create Environment Light
        Environment envLight = new Environment();

        envLight.set_material(ems);
        envLight.SetSampler(new Regular(100));
        add_light(envLight);


        Matte mat_ptr = new Matte();

        mat_ptr.set_ka(0.25f);
        mat_ptr.set_kd(0.65f);
        mat_ptr.set_cd(new Color(1, 1, 0, 1));

        Sphere sphere = new Sphere();

        sphere.sphereCenter = new Vector3(-20, 0, 0);
        sphere.sphereRad    = 30.0f;
        sphere.set_material(mat_ptr);


        add_object(sphere);

        render_scene();
    }
Пример #16
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 1;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 20),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          3600);

            Camera = pinhole;

            Directional l = new Directional();

            l.SetDirection(-10, 20, 20);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = false;
            AddLight(l);

            int numSpheres = 1000000;

            double volume = 0.1 / numSpheres;
            double radius = Math.Pow(0.75 * volume / Math.PI, 0.333333);

            Grid grid = new Grid();

            Rnd.SetRandSeed(15);

            for (int j = 0; j < numSpheres; j++)
            {
                Matte matte = new Matte();
                matte.SetKa(0.25f);
                matte.SetKd(0.75f);
                matte.SetColor(new Vec3(Rnd.RandDouble(),
                                        Rnd.RandDouble(),
                                        Rnd.RandDouble()));

                Sphere sphere = new Sphere();
                sphere.Radius = radius;
                sphere.SetCenter(1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble(),
                                 1.0f - 2.0f * (float)Rnd.RandDouble());
                sphere.Material = matte;
                grid.AddObject(sphere);
            }

            grid.SetupCells();

            AddObject(grid);
        }
Пример #17
0
        public override Ray CaculateRay(float x, float y, ViewPlane plane)
        {
            Vector3 p = new Vector3(x, y, 0);

            p /= PixelPerUnit;
            Ray ray = new Ray(p, Vector3.Forward);

            return(ray);
        }
Пример #18
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 25;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0, 0, 65),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          9000 /**24*/);

            Camera = pinhole;

            Directional light = new Directional();

            light.SetDirection(-0.25f, 0.4f, 1.0f);
            light.ScaleRadiance = 2.5f;
            AddLight(light);

            //image
            Image image = new Image();

            image.Load(PATH + "ppm/EarthLowRes.ppm");

            //mapping
            SphericalMap sphericalMap = new SphericalMap();

            //image based texture
            ImageTexture texture = new ImageTexture(image, sphericalMap);

            //textured material
            SV_Matte svMatte = new SV_Matte();

            svMatte.SetKa(0.45f);
            svMatte.SetKd(0.65f);
            svMatte.SetCd(texture);

            Sphere s = new Sphere();

            s.Material = svMatte;

            Instance earth = new Instance(s);

            earth.Material = svMatte;
            earth.RotateY(-72);
            earth.RotateX(40);
            earth.RotateZ(20);
            AddObject(earth);
        }
Пример #19
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 16;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(100, 0, 100),
                                          new Vec3(0, 1, 0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          8000);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(50, 50, 1);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.75));
            m.SetKa(0.25f);
            m.SetKd(0.8f);
            m.SetKs(0.15f);
            m.SetExp(50.0f);

            Instance ellipsoid = new Instance(new Sphere());

            ellipsoid.Material = m;
            ellipsoid.Scale(2, 3, 1);
            ellipsoid.RotateX(-45);
            ellipsoid.Translate(0, 1, 0);
            AddObject(ellipsoid);

            //Plane p = new Plane(new Vec3(0, -10, 0), new Vec3(0, 1, 0));
            //Matte pm = new Matte();
            //pm.SetKa(0.25f);
            //pm.SetKd(0.75f);
            //pm.SetColor(new Vec3(0.3));
            //p.Material = pm;

            //AddObject(p);
        }
Пример #20
0
        public override void Build()
        {
            vp              = ViewPlane.Create(200, 200, SystemOfCoordinates.SSC_FLOAT);
            vp.Gama         = 1.0f;
            backgroundColor = ColorUtils.BLACK;
            tracer          = new Tracers.SingleSphere(this);

            Sphere sphere = new Sphere(new Vec3(0.0), 0.85);

            sphere.Color = new Vec3(0.8, 0.0, 0.8);
            AddObject(sphere);
        }
Пример #21
0
        public CameraBase(Vector3 pos, Vector3 forward, Vector3 up, ViewPlane plane)
        {
            Position = pos;
            Forward  = forward;
            Right    = Forward.Cross(up);
            Up       = Forward.Cross(Right);

            AspectRatio = plane.Width * 1.0f / plane.Height;

            Forward = Forward.Nor();
            Right   = Right.Nor();
            Up      = Up.Nor();
        }
Пример #22
0
        public IDisplayData AsDisplayData(ViewPlane viewplane)
        {
            try
            {
                BuildDisplayData(viewplane);

                return(displayData);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #23
0
        public override void RenderScene(World world)
        {
            //Stopwatch sw = Stopwatch.StartNew();
            //while (true)
            //{
            //    sw.Restart();
            RGBColor L = new RGBColor();

            ViewPlane viewPlane = (ViewPlane)world.ViewPlane.Clone();

            Ray     ray         = new Ray();
            int     depth       = 0;
            Point2d samplePoint = new Point2d();
            Point2d pixelPoint  = new Point2d();

            viewPlane.PixelSize /= zoom;
            ray.Origin           = Eye;

            Bitmap bitmap = new Bitmap(viewPlane.HRes, viewPlane.VRes);

            for (int r = 0; r < viewPlane.VRes; r++)
            {
                for (int c = 0; c < viewPlane.HRes; c++)
                {
                    L = new RGBColor(0, 0, 0);
                    for (int i = 0; i < viewPlane.Sampler.NumSamples; i++)
                    {
                        samplePoint = viewPlane.Sampler.SampleUnitSquare();

                        pixelPoint.X = viewPlane.PixelSize * (c - 0.5 * viewPlane.HRes + samplePoint.X);
                        pixelPoint.Y = viewPlane.PixelSize * (r - 0.5 * viewPlane.VRes + samplePoint.Y);

                        ray.Direction = GetRayDirection(pixelPoint);
                        L            += world.Tracer.TraceRay(ray, depth);
                    }

                    L /= viewPlane.Sampler.NumSamples;
                    L *= eposureTime;

                    L.MaxToOne();
                    bitmap.SetPixel(c, viewPlane.VRes - r - 1,
                                    Color.FromArgb((int)(L.R * 255),
                                                   (int)(L.G * 255),
                                                   (int)(L.B * 255)));
                }
                Console.Out.WriteLine("r = {0}", r);
            }

            bitmap.Save("TracedImage.bmp", ImageFormat.Bmp);
            //Console.Out.WriteLine("sw = {0}", sw.ElapsedMilliseconds);
        }
        public override void Build()
        {
            int numSamples = 4;

            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = numSamples;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            MultiJittered sampler = new MultiJittered(numSamples);

            sampler.Generate();

            AmbientOccluder occluder = new AmbientOccluder();

            occluder.ScaleRadiance = 1.0;
            occluder.Color         = ColorUtils.WHITE;
            occluder.MinAmount     = 0.0;
            occluder.Sampler       = sampler;
            AmbientLight           = occluder;

            Pinhole pinhole = new Pinhole(new Vec3(25.0, 20.0, 45.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          5000.0f);

            pinhole.ComputeUVW();
            Camera = pinhole;

            Matte matte = new Matte();

            matte.SetKa(0.75f);
            matte.SetKd(0.0f);
            matte.SetColor(1.0f, 0.7f, 0.0f);

            Sphere s = new Sphere(new Vec3(0, 1, 0), 1);

            s.Material = matte;
            AddObject(s);

            matte = new Matte();
            matte.SetKa(0.75f);
            matte.SetKd(0.0f);
            matte.SetColor(ColorUtils.WHITE);

            Plane p = new Plane(new Vec3(0, 0, 0), new Vec3(0, 1, 0));

            p.Material = matte;
            AddObject(p);
        }
Пример #25
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(0.2f, 0.5f, 0.4f);
            m.SetKa(0.25f);
            m.SetKd(0.75f);
            m.SetKs(0.2f);
            m.SetExp(20.0f);

            Grid sphere = new Grid();

            //sphere.TessellateFlatSphere(200, 100);
            sphere.TessellateSmoothSphere(100, 50);
            sphere.Material = m;
            sphere.SetupCells();

            Instance i = new Instance(sphere);

            i.Scale(60.0f);

            AddObject(i);
        }
Пример #26
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(new Vec3(0.35f));
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            float t = 20;
            float b = -80;
            float r = 50;

            //BeveledCylinder bc = new BeveledCylinder(b, t, r, 6);
            //bc.Material = m;
            Cylinder c = Cylinder.Create(b, t, r, 3);

            c.Material = m;

            AddObject(c);
        }
Пример #27
0
        private Vector3 GetCaretPositionInWorldSpace(uint x, uint y)
        {
            float xRatio = (float)(x) / m_View.Width;
            float yRatio = 1 - (float)(y) / m_View.Height;

            Bounds  bounds        = gameObject.collider.bounds;
            Vector3 extents       = bounds.extents;
            Vector3 caretPosition = bounds.center - extents;

            ViewPlane planeOrientation = GetViewPlaneOrientation();

            switch (planeOrientation)
            {
            case ViewPlane.VP_XpositiveYpositive:
                caretPosition.x += xRatio * bounds.size.x;
                caretPosition.y += yRatio * bounds.size.y;
                break;

            case ViewPlane.VP_YpositiveZpositive:
                caretPosition.y += yRatio * bounds.size.y;
                caretPosition.z += xRatio * bounds.size.z;
                break;

            case ViewPlane.VP_XnegativeZnegative:
                caretPosition.x += (1 - xRatio) * bounds.size.x;
                caretPosition.z += (1 - yRatio) * bounds.size.z;
                break;

            case ViewPlane.VP_XnegativeYpositive:
                caretPosition.x += (1 - xRatio) * bounds.size.x;
                caretPosition.y += yRatio * bounds.size.y;
                break;

            case ViewPlane.VP_YpositiveZnegative:
                caretPosition.y += yRatio * bounds.size.y;
                caretPosition.z += (1 - xRatio) * bounds.size.z;
                break;

            case ViewPlane.VP_XnegativeZpositive:
                caretPosition.x += (1 - xRatio) * bounds.size.x;
                caretPosition.z += yRatio * bounds.size.z;
                break;
            }
            return(caretPosition);
        }
Пример #28
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 80.0, 210),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          500);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(100, 100, 200);
            l.ScaleRadiance = 3.0f;
            l.Shadows       = true;
            AddLight(l);

            Phong m = new Phong();

            m.SetColor(ColorUtils.BLUE);
            m.SetKa(0.2f);
            m.SetKd(0.65f);
            m.SetKs(0.4f);
            m.SetExp(64.0f);

            Annulus an = new Annulus(new Vec3(),
                                     new Vec3(0, 1, 0), 55, 80);

            an.Material = m;

            AddObject(an);
        }
        public override void Build()
        {
            vp = ViewPlane.Create(200, 200, SystemOfCoordinates.SSC_INT);
            backgroundColor = ColorUtils.BLACK;
            tracer          = new MultipleObjects(this);

            Sphere sphere = new Sphere(new Vec3(0.0, -25.0, 0.0), 80.0);

            sphere.Color = new Vec3(1.0, 0.0, 0.0);
            AddObject(sphere);

            sphere       = new Sphere(new Vec3(0.0, 30.0, 0.0), 60.0);
            sphere.Color = new Vec3(1.0, 1.0, 0.0);
            AddObject(sphere);

            //Plane plane = new Plane(new Vec3(0.0), new Vec3(0.0, 1.0, 1.0));
            //plane.Color = new Vec3(0.0, 0.3, 0.0);
            //AddObject(plane);
        }
Пример #30
0
        public override void Build()
        {
            vp            = ViewPlane.Create(1024, 768, SystemOfCoordinates.SSC_INT);
            vp.NumSamples = 4;

            backgroundColor = ColorUtils.BLACK;
            tracer          = new RayCast(this);

            Ambient a = new Ambient();

            a.ScaleRadiance = 1.0f;
            AmbientLight    = a;

            Pinhole pinhole = new Pinhole(new Vec3(0.0, 0.0, 500.0),
                                          new Vec3(0.0, 0.0, 0.0),
                                          new Vec3(0.0, 1.0, 0.0),
                                          2000.0f);

            Camera = pinhole;

            PointLight l = new PointLight();

            l.Color = ColorUtils.WHITE;
            l.SetLocation(0, 100, -20);
            l.ScaleRadiance = 20.0f;
            l.Shadows       = false;
            AddLight(l);

            Triangle t = new Triangle(new Vec3(0, 50, 0),
                                      new Vec3(-50, -50, 0),
                                      new Vec3(50, -50, 0));
            Matte matte = new Matte();

            matte.SetKa(0.2f);
            matte.SetKd(0.5f);
            matte.SetColor(new Vec3(0.8, 0.6, 0.2));

            t.Material = matte;
            t.Shadows  = false;

            AddObject(t);
        }