Пример #1
0
        public static void TwoMovingObjects()
        {
            Cube cube1 = new Cube();
            Cube cube2 = new Cube();
            ShaderModelRenderer sm1 = new ShaderModelRenderer(cube1);
            ShaderModelRenderer sm2 = new ShaderModelRenderer(cube2, sm1.ShaderProgram);

            using (WorldWindow game = new WorldWindow()
            {
                Title = "TwoMovingObjects"
            })
            {
                game.Camera.LookAt(new Vector3(-4, 4, -4), new Vector3());
                game.Models.Add(sm1);
                game.Models.Add(sm2);
                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time          += (float)e.Time;
                    cube1.Position = new Vector3(-1, 0.5f * (float)Math.Sin(time), 0);
                    cube1.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    cube2.Position = new Vector3(1, -0.5f * (float)Math.Sin(time), 0);
                    cube2.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);
                };
                game.Run();
            }
        }
Пример #2
0
        public static void SquareGridTest()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(-4, 4, -4);
                game.Camera.LookAt(eye, new Vector3());


                SquareGrid          grid = new SquareGrid(4, 4, 2.3f, 1.1f);
                ShaderModelRenderer sm   = new ShaderModelRenderer(grid);

                game.Models.Add(sm);


                UserInterface ui = new UserInterface(game);

                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time += (float)e.Time;
                    double fps = e.Time == 0 ? 1000 : 1.0 / e.Time;
                    ui.PrintCommonStats(e.Time);
                };

                game.Run(30);
            }
        }
Пример #3
0
 public static void EmptyWindow()
 {
     using (WorldWindow game = new WorldWindow()
     {
         Title = "EmptyWindow"
     })
         game.Run(30);
 }
Пример #4
0
        public static void ThreeShaders()
        {
            Cube cube1 = new Cube();
            Cube cube2 = new ColouredCube();
            Cube cube3 = new TexturedCube();
            ShaderModelRenderer sm1 = new ShaderModelRenderer(cube1);
            ShaderModelRenderer sm2 = new ShaderModelRenderer(cube2)
            {
                VertexShaderFilaneme = "Shaders/vs_col.glsl"
            };
            ShaderModelRenderer sm3 = new ShaderModelRenderer(cube3)
            {
                VertexShaderFilaneme   = "Shaders/vs_tex.glsl",
                FragmentShaderFilename = "Shaders/fs_tex.glsl"
            };

            using (WorldWindow game = new WorldWindow()
            {
                Title = "ThreeShaders"
            })
            {
                game.Camera.LookAt(new Vector3(-4, 4, -4), new Vector3());

                (cube3 as TexturedCube).TextureID = TextureLoader.LoadImage("Textures/opentksquare.png");

                game.Models.Add(sm1);
                game.Models.Add(sm2);
                game.Models.Add(sm3);

                UserInterface ui = new UserInterface(game);

                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time          += (float)e.Time;
                    cube1.Position = new Vector3(2, 0.05f * (float)Math.Sin(time), 0);
                    cube1.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    cube2.Position = new Vector3(0, 0.05f * (float)Math.Sin(time), 2);
                    cube2.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    cube3.Position = new Vector3(0, 0.05f * (float)Math.Sin(time), 0);
                    cube3.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);

                    ui.PrintCommonStats(e.Time);
                };
                game.Run();
            }
        }
Пример #5
0
        public static void SingleObect()
        {
            Cube cube = new Cube();
            ShaderModelRenderer sm = new ShaderModelRenderer(cube);

            using (WorldWindow game = new WorldWindow()
            {
                Title = "SingleMovingObject"
            })
            {
                game.Camera.LookAt(new Vector3(-4, 4, -4), new Vector3());
                game.Models.Add(sm);
                game.Run();
            }
        }
Пример #6
0
        public static void TextboxInterface()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(0, 2, 0);
                game.Camera.LookAt(eye, eye * 0.8f);
                UserInterface ui = new UserInterface(game);

                game.UpdateFrame += (o, e) =>
                {
                    ui.PrintCommonStats(e.Time);
                };

                game.Run(30);
            }
        }
Пример #7
0
        public static void CosineTerrainGridTest()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(-400, 400, -400);
                game.Camera.LookAt(eye, new Vector3());
                game.CameraControl.MoveSpeed = 100;

                Vector2 SouthWestLatLong = new Vector2(-37, 174);
                Vector2 NorthEastLatLong = new Vector2(-36.9f, 174.2f);
                Terrain terrain          = new Terrain();

                TiledAltitudeMapReader mapReader = new CosineAltitudeMapReader();
                Vector3[,] lla = mapReader.GetMap(SouthWestLatLong, NorthEastLatLong);


                terrain.Recreate(lla);

                ShaderModelRenderer sm = new ShaderModelRenderer(terrain)
                {
                    VertexShaderFilaneme = "Shaders/vs_norm.glsl"
                };

                game.Models.Add(sm);


                UserInterface ui = new UserInterface(game);

                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time += (float)e.Time;
                    double fps = e.Time == 0 ? 1000 : 1.0 / e.Time;
                    ui.PrintCommonStats(e.Time);
                };

                game.Run(30);
            }
        }
Пример #8
0
        public static void FlatTerrainGridTest()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(-4000, 4000, -4000);
                game.Camera.LookAt(eye, new Vector3());
                game.CameraControl.MoveSpeed = 1000;

                Terrain     terrain = new Terrain();
                int         rows    = 80;
                int         cols    = 100;
                TerrainInfo info    = new TerrainInfo()
                {
                    SouthWestLatLong         = new Vector2(-37, 174),
                    NorthEastLatLong         = new Vector2(-36.9f, 174.1f),
                    DegreesLatitudePerPixel  = 0.2 / (double)rows,
                    DegreesLongitudePerPixel = 0.2 / (double)cols
                };
                float[,] altInMetres = info.CreateFlatAltitudes(rows, cols);
                terrain.Recreate(info, altInMetres);

                ShaderModelRenderer sm = new ShaderModelRenderer(terrain);

                game.Models.Add(sm);


                UserInterface ui = new UserInterface(game);

                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time += (float)e.Time;
                    double fps = e.Time == 0 ? 1000 : 1.0 / e.Time;
                    ui.PrintCommonStats(e.Time);
                };

                game.Run(30);
            }
        }
Пример #9
0
        public static void AucklandTerrainGridTest()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(-1000, 4000, -1000);
                game.Camera.LookAt(eye, new Vector3());
                game.CameraControl.MoveSpeed = 1000;
                game.SetZRange(100, 100000);

                Vector2 SouthWestLatLong = new Vector2(-37, 174);
                Vector2 NorthEastLatLong = new Vector2(-36, 175);
                Terrain terrain          = new Terrain();

                TiledAltitudeMapReader mapReader = new Srtm3Reader()
                {
                    AltitudeScale = 10
                };
                Vector3[,] lla = mapReader.GetMap(SouthWestLatLong, NorthEastLatLong);


                Vector2 auckland = new Vector2(-36.8468f, 174.7908f);
                terrain.Recreate(lla, auckland);

                ShaderModelRenderer sm = new ShaderModelRenderer(terrain)
                {
                    VertexShaderFilaneme = "Shaders/vs_norm.glsl"
                };

                game.Models.Add(sm);


                UserInterface ui = new UserInterface(game);

                game.RenderFrame += (o, e) => ui.PrintCommonStats(e.Time);


                game.Run(30);
            }
        }
Пример #10
0
        public static void TextboxInterfaceWithObject()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(0, 0, -4);
                game.Camera.LookAt(eye, eye * 0.8f);
                UserInterfaceSimpleTextbox ui = new UserInterfaceSimpleTextbox();
                ui.BoxBackground = Color.FromArgb(40, 0, 0, 0);
                ShaderModelRenderer ui_sm = new ShaderModelRenderer(ui)
                {
                    VertexShaderFilaneme   = "Shaders/vs_tex.glsl",
                    FragmentShaderFilename = "Shaders/fs_tex.glsl",
                };

                ColouredCube        cube = new ColouredCube();
                ShaderModelRenderer sm2  = new ShaderModelRenderer(cube)
                {
                    VertexShaderFilaneme   = "Shaders/vs_col.glsl",
                    FragmentShaderFilename = "Shaders/fs.glsl",
                };
                game.Models.Add(sm2);
                game.Models.Insert(0, ui_sm);
                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time += (float)e.Time;
                    double fps = e.Time == 0 ? 1000 : 1.0 / e.Time;

                    ui.Text = "Fps: " + fps.ToString("N1") + " Time: " + time.ToString("N2") + "\nnewline" + "\nnewline1" + "\nnewline2" + "\nnewline3";

                    cube.Position = new Vector3(-1, 0.5f * (float)Math.Sin(time), 0);
                    cube.Rotation = new Vector3(0.3f * time, 0.1f * time, 0);
                };

                game.Run(30);
            }
        }
Пример #11
0
        public static void ManyCubes()
        {
            using (WorldWindow game = new WorldWindow())
            {
                Vector3 eye = new Vector3(-4, 4, -4);
                game.Camera.LookAt(eye, eye * 0.8f);
                int       texID      = TextureLoader.LoadImage("Textures/opentksquare.png");
                Vector3[] posOffsets = GenerateRandomCubes(game, texID);

                UserInterface ui = new UserInterface(game);


                float time = 0;
                game.UpdateFrame += (o, e) =>
                {
                    time += (float)e.Time;
                    ui.PrintCommonStats(e.Time);


                    MoveModels(game, time, posOffsets);
                };
                game.Run(60.0);
            }
        }