예제 #1
0
파일: Water.cs 프로젝트: mainblade/OpentK3D
        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();
        }