コード例 #1
0
ファイル: Renderer.cs プロジェクト: sandygk/Rendering
        /// <summary>
        /// Crea un renderer para visualizar imagenes de determinado tamanno.
        /// </summary>
        public Renderer(int width, int height)
        {
            if (width <= 0 || height <= 0)
                throw new ArgumentOutOfRangeException();

            Scene = new Scene();
            this.Width = width;
            this.Height = height;
        }
コード例 #2
0
ファイル: Form.cs プロジェクト: sandygk/Rendering
        public void BuildScene(Scene scene)
        {
            

            scene.Camera = new PerspectiveCamera()
            {
                Position = new vec3(0, 5, -10),
                Direction = new vec3(0, -5, 10),
                FieldOfView = (float)Math.PI / 4,
                NearPlaneDistance = 0.1f,
                FarPlaneDistance = 1000f,
                Normal = new vec3(0, 1, 0)
            };

            IImage floor = Images.From(@"Textures\square.bmp");
            IImage face = Images.From(@"Textures\wood.jpg");
            IImage facen = Images.From(@"Textures\wodn.bmp");

            scene.Graphics.Add(Model.Sphere.AsLight(Color.FromArgb(10, 10, 10, 10).ToVec4()).At(0, 10, 10));

            scene.AmbientLight = Color.FromArgb(255, 221, 227, 170).ToVec4();
            float incZ = -6;
            //scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Translucent(Color.Blue.ToVec4(), 0, 0f,1f,1f)).At(3, 1, 0 + incZ));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Translucent(Color.DarkOrchid.ToVec4(), 0, 0f, 1f, 1f)).At(0, 1, 0 + incZ));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Translucent(Color.HotPink.ToVec4(), 0, 0f, 1f, 1f)).At(-3, 1, 0 + incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.Red.ToVec4(), 7, 1f)).At(3, 1, 3+ incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.FromArgb(255, 4, 100, 27).ToVec4(), 7, 1f)).At(0, 1, 3+ incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.Black.ToVec4(), 7, 1f)).At(-3, 1, 3+ incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.FromArgb(255, 238, 238, 238).ToVec4(), 7, 1f)).At(3, 1, 6+ incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.SaddleBrown.ToVec4(), 7, 1f)).At(0, 1, 6+ incZ));
            scene.Graphics.Add(Model.Sphere.AsGraphic(Material.Glossy(Color.Salmon.ToVec4(), 7, 1f)).At(-3, 1, 6+ incZ));

            scene.Graphics.Add(Model.Plane.AsGraphic(Material.Glossy(face, 10, 0.5f)).Sized(13f, 1, 13f).At(0, 0, 0));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(0, 3.5f, -1));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(-.5f, 2.7f, -1));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(.5f, 2.7f, -1));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(-.7f, 1.8f, -1));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(.7f, 1.8f, -1));
            //scene.Graphics.Add(Model.Sphere.AsGraphic(EmissiveMaterial.Emissive(Color.Red.ToVec4())).Sized(.15f, .15f, .15f).At(0, 1.8f, -1));
            //scene.Graphics.Add(Model.Cone.AsGraphic(Material.Rough(Color.FromArgb(255, 200, 255, 34).ToVec4())).RotatedX((float)Math.PI).At(0, 4f, 0).Sized(1f, 1f, 1f));
            //scene.Graphics.Add(Model.Cone.AsGraphic(Material.Rough(Color.FromArgb(255, 200, 255, 34).ToVec4())).RotatedX((float)Math.PI).At(0, 2.75f, 0).Sized(1.3f, 1.3f, 1.3f));
            //scene.Graphics.Add(Model.Cone.AsGraphic(Material.Rough(Color.FromArgb(255, 200, 255, 34).ToVec4())).RotatedX((float)Math.PI).At(0, 2f, 0).Sized(1.5f, 1.5f, 1.5f));
            //scene.Graphics.Add(Model.Cylinder.AsGraphic(Material.Rough(face)).Sized(0.5f,1.3f,0.5f));
            //scene.Graphics.Add(Model.Plane.AsGraphic(Material.Glossy(face, 10, 0.5f)).Sized(13f, 1, 13f).At(0, 0, 0));
        }