Exemplo n.º 1
0
        // public static void CreateThorScene(Enviroment enviroment, Camera bindingCamera, Camera original)
        // {
        //     var thor = new Function(Vector3.Zero, (x, y) => (float)(Math.Sin(x) * x * Math.Cos(y) * y), 0, 0, 1000, 1000, 10);
        //     var ps = new PhongModelShader(new Light() { Pos = original.Pivot.Center, Intensivity = 10f });
        //     var sm = new ShadowMappingShader(enviroment, new Rasterizer(bindingCamera), 3f);
        //     thor.Shaders = new IShader[] { ps, sm};
        //     thor.Scale(10f);
        //     enviroment.AddPrimitive(thor);
        // }

        public static void StartKitchenScene(Enviroment enviroment, Camera bindingCamera, Camera original)
        {
            var ps = new PhongModelShader(new Light()
            {
                Pos = original.Pivot.Center, Intensivity = 3
            });
            var sm    = new ShadowMappingShader(10f, bindingCamera, enviroment);
            var model = ObjParser.FromObjFile(@"F:\c#\DevilRender\DevilRender\Models\Lancer_Evolution_model.obj",
                                              null);

            model.Scale(40f);
            enviroment.AddPrimitive(model);
            var devilRender = new RenderApplication(
                enviroment,
                800,
                600,
                new List <Camera>
            {
                original,
                bindingCamera
            },
                new List <IFragmentShader>()
            {
                sm, ps
            });

            devilRender.Start();
        }
Exemplo n.º 2
0
        public static void StartWeaponScene()
        {
            var enviroment   = new Enviroment(10000);
            var originCam    = new Camera(new Vector3(0, 0, -500), 100, (float)(Math.PI / 2), 800, 600);
            var shadowMapCam = new Camera(new Vector3(0, 0, -500), 100, (float)(Math.PI / 2), 800, 600);
            var model        = ObjParser.FromObjFile(@"C:\Users\Dato\Desktop\DevilRender\Models\Cyborg_Weapon.obj",
                                                     @"C:\Users\Dato\Desktop\DevilRender\Models\Cyborg-Weapon textures.png");
            var sm = new ShadowMappingShader(2, shadowMapCam, enviroment);
            var ps = new PhongModelShader(new Light(new Vector3(0, 0, -1000), 2));

            model.Scale(1000f);
            model.Rotate(1.57f, Axis.Y);
            enviroment.AddPrimitive(model);

            //var devilRender = new RenderApplication(
            //    enviroment,
            //    800,
            //    600,
            //    new List<Camera>
            //    {
            //        originCam,
            //        shadowMapCam
            //    },
            //    new List<IFragmentShader>() {sm, ps});
            //devilRender.Start();

            var r = new RasterizerService(new List <IFragmentShader> {
                sm, ps
            });

            while (true)
            {
                var sw = new Stopwatch();
                sw.Start();
                r.GetSnapshot(enviroment, originCam).Wait();
                sw.Stop();
                Console.WriteLine($"{sw.ElapsedMilliseconds}");
            }
        }