Beispiel #1
0
        public void Load()
        {
            Foam = TextureFactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.foam.jpg"), TextureWrapMode.Repeat);

            LoadWaveNumbersModerate();
            DataTexture.LoadData(SizedInternalFormat.Rgba16f, WaveNumbers);

            Texture3 = Foam;
            Texture4 = DataTexture;
            Texture5 = TextureFactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.IKT4l.jpg"), TextureWrapMode.Repeat);


            for (int i = 0; i < Width; i += 1)
            {
                for (int j = 0; j < Height; j += 1)
                {
                    Vertices[i + j * Width] = new Vbo
                    {
                        Position = new Vector3((float)i, (float)1, (float)j),
                        TexCoord = new Vector2((float)i / Width, (float)j / Height),
                        Normal   = new Vector3(0, 1, 0),
                    };
                }
            }

            for (int i = 0; i < Width - 1; i++)
            {
                for (int j = 0; j < Height - 1; j++)
                {
                    Indices.Add(j * Width + i);
                    Indices.Add(j * Width + i + 1);
                    Indices.Add((j + 1) * Width + i);
                    Indices.Add((j + 1) * Width + i + 1);
                    Indices.Add((j + 1) * Width + i);
                    Indices.Add(j * Width + i + 1);
                }
            }
            indice = Indices.ToArray();

            Refraction = FramBufferOBjectFactory.Create(Width, Height);
            Refraction.Load();

            Reflection = FramBufferOBjectFactory.Create(Width, Height);
            Reflection.Load();

            InitWaterShader();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var gameWindow = new GameWindow(WindowWidth, WindowHeight, new GraphicsMode(32, 24, 0, 8), "Ocean sim (Grestner waves) and terrain", GameWindowFlags.Default, DisplayDevice.AvailableDisplays.Last());

            gameWindow.MakeCurrent();
            gameWindow.Context.LoadAll();

            Utils.Utils.GLRenderProperties(WindowWidth, WindowHeight);

            _camera = Factory <Camera.Camera> .Create(_cameraPosition0, LookAt0, new Vector3(0, 1, 0));


            _light = LightFactory.Create(new Vector3(-350.0f, 300.0f, 0.0f), new Color4(255, 255, 255, 1), new Color4(255, 255, 255, 1), new Color4(252, 252, 252, 1), LightName.Light0);
            _light.Load();



            _terrain = Terrainfactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.TOPOMAP1.GIF"),
                                             Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Dirt.jpg"),
                                             Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.sand.jpg"),
                                             Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Grass.png"),
                                             Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Rock.png"));
            _terrain.Load();


            _cubeMap = CubeMapFactory.Create(2500, false, new Vector3(256, 0, 256),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_back.jpg"),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_front.jpg"),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_top.jpg"),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_left.jpg"),
                                             Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.Desert.Desert_right.jpg")
                                             );
            _cubeMap.Load();

            _woodenChest = CubeMapFactory.Create(100, true, new Vector3(256, 150, 256), Utils.Utils.GetImageResource <ICubeMap>("EnvironmentMap.Textures.plank.jpg"));
            _woodenChest.Load();

            _water = new Water(WaterWidth, WaterHeight);
            _water.Load();

            _seaBed = PlaneFactory.Create(true, new Vbo()
            {
                Position = new Vector3(0, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 0)
            },
                                          new Vbo()
            {
                Position = new Vector3(0, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(0, 1)
            },
                                          new Vbo()
            {
                Position = new Vector3(WaterWidth, -70, WaterHeight), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 1)
            },
                                          new Vbo()
            {
                Position = new Vector3(WaterWidth, -70, 0), Normal = new Vector3(0, 1, 0), TexCoord = new Vector2(1, 0)
            },
                                          Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.seabed.jpg"), TextureWrapMode.ClampToEdge);
            _seaBed.Load();

            _birdTexture = FramBufferOBjectFactory.Create(512, 512);
            _birdTexture.Load();

            gameWindow.RenderFrame += gameWindow_RenderFrame;
            gameWindow.UpdateFrame += gameWindow_UpdateFrame;

            gameWindow.Keyboard.KeyDown += Keyboard_KeyDown;
            gameWindow.Run(60.0, 30.0);
        }