예제 #1
0
 public static void UpdateLevel(OpenGlRenderer renderer, List <GameObject>[] level)
 {
     //Console.WriteLine(renderer.level.Length);
     Modell combined = CombineModells.Combine(CombineModells.GameObjectToModellArray(Init.ChunksToGameObjects(Init.NearChunck(level.ToArray(), renderer.player_pos, 50)).ToArray()));
     //Console.WriteLine(combined.vertices.Length);
     //Console.WriteLine(combined.uv.Length);
     //Console.WriteLine(combined.normal.Length);
     //renderer.UpdateBuffers(combined.vertices, combined.uv, combined.normal);
 }
예제 #2
0
        void loaded(object o, EventArgs e)
        {
            input.lastPos = new Vector2(Mouse.GetCursorState().X, Mouse.GetCursorState().Y);
            //texture = LoadResources.ReadTexture(Directory.GetCurrentDirectory() + @"\Mods\Default\Textures\earth.jpg");
            //Change clear color
            GL.ClearColor(Color.Black);
            //Render polygons in a correct order
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.TextureCoordArray);
            //Setup buffers

            //Vertex buffer

            VEB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, VEB);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * vertexBuffer.Length),
                                    vertexBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            //Uv buffer

            UVB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, UVB);
            GL.BufferData <Vector2>(BufferTarget.ArrayBuffer, (IntPtr)(Vector2.SizeInBytes * uvBuffer.Length),
                                    uvBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            //Normal buffer

            NOB = GL.GenBuffer();
            GL.BindBuffer(BufferTarget.ArrayBuffer, UVB);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * normalBuffer.Length),
                                    normalBuffer, BufferUsageHint.DynamicDraw);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

            level = LevelGenerator.GenerateTerrain3D(20, 20, 20, .05f, 0, .5f);
            //Console.WriteLine(renderer.level.Length);
            Modell combined = CombineModells.Combine(CombineModells.GameObjectToModellArray(Init.ChunksToGameObjects(Init.NearChunck(level.ToArray(), player_pos, 9999)).ToArray()));

            //Console.WriteLine(combined.vertices.Length);
            //Console.WriteLine(combined.uv.Length);
            //Console.WriteLine(combined.normal.Length);

            UpdateBuffers(combined.vertices, combined.uv, combined.normal, combined.textures, combined.colors);
        }