Exemple #1
0
 protected override void OnLoad(EventArgs e)
 {
     try
     {
         generateEntities();
         generateTerrains();
         camera    = new FollowingCamera(new Vector3(0, 50, 40), 40, 0, 0, trolley);
         renderer  = new MainRenderer("Flat");
         reflector = lights[1];
         stopwatch.Start();
     }
     catch (Exception ef)
     {
         Console.WriteLine(ef.Message);
     }
 }
Exemple #2
0
        protected override void OnKeyDown(KeyboardKeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.C:
            {
                if (camera is CCTVCamera)
                {
                    camera = new FollowingCamera(new Vector3(0, 50, 40), 40, 0, 0, trolley);
                }
                else if (camera is FollowingCamera)
                {
                    camera = new GoProCamera(new Vector3(0, 0, 0), 70, 0, 0, mouse, trolley);
                }
                else
                {
                    camera = new CCTVCamera(new Vector3(0, 50, 40), 40, 0, 0);
                }
                break;
            }

            case Key.M:
            {
                if (ShadingMode == "Flat")
                {
                    ShadingMode = "Phong";
                }
                else if (ShadingMode == "Phong")
                {
                    ShadingMode = "Gouraud";
                }
                else
                {
                    ShadingMode = "Flat";
                }
                renderer.CleanUp();
                renderer = new MainRenderer(ShadingMode);
                break;
            }

            case Key.KeypadPlus:
            {
                foreach (var light in lights)
                {
                    float dx = 0, dy = 0, dz = 0;
                    if (light.Attenuation.X <= 0.99)
                    {
                        dx = 0.001f;
                    }
                    if (light.Attenuation.Y <= 0.99)
                    {
                        dy = 0.001f;
                    }
                    if (light.Attenuation.Z <= 0.99)
                    {
                        dz = 0.001f;
                    }
                    light.Attenuation = light.Attenuation + new Vector3(dx, dy, dz);
                }
                break;
            }

            case Key.KeypadMinus:
            {
                foreach (var light in lights)
                {
                    float dx = 0, dy = 0, dz = 0;
                    if (light.Attenuation.X > 0)
                    {
                        dx = 0.001f;
                    }
                    if (light.Attenuation.Y > 0)
                    {
                        dy = 0.001f;
                    }
                    if (light.Attenuation.Z > 0)
                    {
                        dz = 0.001f;
                    }
                    light.Attenuation = light.Attenuation - new Vector3(dx, dy, dz);
                }
                break;
            }

            case Key.N:
            {
                break;
            }

            case Key.E:
            {
                Close();
                break;
            }
            }
            keyboard.KeyPressed(e, true);
        }