예제 #1
0
파일: Example.cs 프로젝트: akav/PTSharp
        public void refraction()
        {
            var scene = new Scene();
            var glass = Material.ClearMaterial(1.5, 0);

            // add a sphere primitive
            scene.Add(Sphere.NewSphere(new Vector(-1.5, 0, 0.5), 1, glass));
            // add a mesh sphere
            var mesh = STL.Load("models/sphere.stl", glass);

            mesh.SmoothNormals();
            mesh.Transform(new Matrix().Translate(new Vector(1.5, 0, 0.5)));
            scene.Add(mesh);
            // add the floor
            scene.Add(Plane.NewPlane(new Vector(0, 0, -1), new Vector(0, 0, 1), Material.DiffuseMaterial(Colour.White)));
            // add the light
            scene.Add(Sphere.NewSphere(new Vector(0, 0, 5), 1, Material.LightMaterial(Colour.White, 15)));
            var camera  = Camera.LookAt(new Vector(0, -5, 5), new Vector(0, 0, 0), new Vector(0, 0, 1), 50);
            var sampler = DefaultSampler.NewSampler(16, 8);

            sampler.SetSpecularMode(SpecularMode.SpecularModeAll);
            var renderer = Renderer.NewRenderer(scene, camera, sampler, 960, 540, false);

            renderer.IterativeRender("refraction.png", 100);
        }
예제 #2
0
파일: Util.cs 프로젝트: akav/PTSharp
        public static Mesh CreateCubeMesh(Material material)
        {
            var mesh = STL.LoadSTLB("models/cube.stl", material);

            mesh.FitInside(new Box(new Vector(0, 0, 0), new Vector(1, 1, 1)), new Vector(0.5, 0.5, 0.5));
            return(mesh);
        }
예제 #3
0
파일: Util.cs 프로젝트: akav/PTSharp
        public static Mesh CreateMesh(Material material)
        {
            var mesh = STL.Load("cylinder.stl", material);

            mesh.FitInside(new Box(new Vector(-0.1, -0.1, 0), new Vector(1.1, 1.1, 100)), new Vector(0.5, 0.5, 0));
            mesh.SmoothNormalsThreshold(Radians(10));
            return(mesh);
        }
예제 #4
0
파일: Util.cs 프로젝트: akav/PTSharp
        public static Mesh CreateBrick(int color)
        {
            var material = Material.GlossyMaterial(Colour.HexColor(color), 1.3, Radians(20));
            var mesh     = STL.Load("models/toybrick.stl", material);

            mesh.SmoothNormalsThreshold(Radians(20));
            mesh.FitInside(new Box(new Vector(), new Vector(2, 4, 10)), new Vector(0, 0, 0));
            return(mesh);
        }
예제 #5
0
파일: Example.cs 프로젝트: akav/PTSharp
        public void hits()
        {
            var scene    = new Scene();
            var material = Material.DiffuseMaterial(new Colour(0.95, 0.95, 1));
            var light    = Material.LightMaterial(Colour.White, 300);

            scene.Add(Sphere.NewSphere(new Vector(-0.75, -0.75, 5), 0.25, light));
            scene.Add(Cube.NewCube(new Vector(-1000, -1000, -1000), new Vector(1000, 1000, 0), material));
            var mesh = STL.Load("models/hits.stl", material);

            mesh.SmoothNormalsThreshold(Util.Radians(10));
            mesh.FitInside(new Box(new Vector(-1, -1, 0), new Vector(1, 1, 2)), new Vector(0.5, 0.5, 0));
            scene.Add(mesh);
            var camera   = Camera.LookAt(new Vector(1.6, -3, 2), new Vector(-0.25, 0.5, 0.5), new Vector(0, 0, 1), 50);
            var sampler  = DefaultSampler.NewSampler(4, 4);
            var renderer = Renderer.NewRenderer(scene, camera, sampler, 960, 540, true);

            renderer.FireflySamples = 128;
            renderer.IterativeRender("hits.png", 1000);
        }
예제 #6
0
파일: Example.cs 프로젝트: akav/PTSharp
        public void love()
        {
            var scene    = new Scene();
            var material = Material.GlossyMaterial(Colour.HexColor(0xF2F2F2), 1.5, Util.Radians(20));

            scene.Add(Cube.NewCube(new Vector(-100, -1, -100), new Vector(100, 0, 100), material));
            var heart = Material.GlossyMaterial(Colour.HexColor(0xF60A20), 1.5, Util.Radians(20));
            var mesh  = STL.Load("love.stl", heart);

            mesh.FitInside(new Box(new Vector(-0.5, 0, -0.5), new Vector(0.5, 1, 0.5)), new Vector(0.5, 0, 0.5));
            scene.Add(mesh);
            scene.Add(Sphere.NewSphere(new Vector(-2, 10, 2), 1, Material.LightMaterial(Colour.White, 30)));
            scene.Add(Sphere.NewSphere(new Vector(0, 10, 2), 1, Material.LightMaterial(Colour.White, 30)));
            scene.Add(Sphere.NewSphere(new Vector(2, 10, 2), 1, Material.LightMaterial(Colour.White, 30)));
            var camera   = Camera.LookAt(new Vector(0, 1.5, 2), new Vector(0, 0.5, 0), new Vector(0, 1, 0), 35);
            var sampler  = DefaultSampler.NewSampler(4, 4);
            var renderer = Renderer.NewRenderer(scene, camera, sampler, 960, 540, true);

            renderer.IterativeRender("love.png", 1000);
        }