예제 #1
0
        protected override void OnLoad()
        {
            // Called just after OpenGL is initialised
            //DebugText.CanWrite = true;

            // Initialise Game

            //BlockMesh.Generate();
            //ChunkMeshGenerator.Initialise();

            Player = new EntityPlayerCamera();
            Worlds = new List <World>();

            World earth = new World();

            earth.SetMainPlayer(Player);
            Player.MoveTo(new Vector3(0, 5, 0));

            // Top    1
            // Front  1
            // Left   1
            // Bottom 1
            // Right  1
            // Back   1

            // Top    2
            // Front  2
            // Left   2
            // Bottom 2
            // Right  2
            // Back   2

            //BlockFace topp = BlockFace.GenerateFace(FaceDirection.Top);
            //BlockFace fron = BlockFace.GenerateFace(FaceDirection.Front);
            //BlockFace left = BlockFace.GenerateFace(FaceDirection.Left);
            //BlockFace bott = BlockFace.GenerateFace(FaceDirection.Bottom);
            //BlockFace righ = BlockFace.GenerateFace(FaceDirection.Right);
            //BlockFace back = BlockFace.GenerateFace(FaceDirection.Back);
            //
            //topp.Face1.WriteVertices(vertices);
            //fron.Face1.WriteVertices(vertices);
            //left.Face1.WriteVertices(vertices);
            //bott.Face1.WriteVertices(vertices);
            //righ.Face1.WriteVertices(vertices);
            //back.Face1.WriteVertices(vertices);
            //topp.Face2.WriteVertices(vertices);
            //fron.Face2.WriteVertices(vertices);
            //left.Face2.WriteVertices(vertices);
            //bott.Face2.WriteVertices(vertices);
            //righ.Face2.WriteVertices(vertices);
            //back.Face2.WriteVertices(vertices);
            //
            //topp.Face1.WriteTextureCoordinates(uvs);
            //fron.Face1.WriteTextureCoordinates(uvs);
            //left.Face1.WriteTextureCoordinates(uvs);
            //bott.Face1.WriteTextureCoordinates(uvs);
            //righ.Face1.WriteTextureCoordinates(uvs);
            //back.Face1.WriteTextureCoordinates(uvs);
            //topp.Face2.WriteTextureCoordinates(uvs);
            //fron.Face2.WriteTextureCoordinates(uvs);
            //left.Face2.WriteTextureCoordinates(uvs);
            //bott.Face2.WriteTextureCoordinates(uvs);
            //righ.Face2.WriteTextureCoordinates(uvs);
            //back.Face2.WriteTextureCoordinates(uvs);

            //mesh = new Mesh(vertices, uvs);
            //obj = new GameObject()
            //{
            //    Mesh = mesh,
            //    Position = new Vector3(2.0f, 5.0f, 1.0f),
            //    Shader = GraphicsLoader.TextureShader,
            //    Texture = BlockTextureLinker.TextureMap[BlockTextureLinker.GetTextureNameFromID(4)]
            //};
            //Tesselator.Generate();
            //mesh = Tesselator.GenerateChunk(chunk1);

            //Chunk chunk1 = ChunkGenerator.GenerateFlat(earth, new ChunkLocation(-1, -1), 4);
            //Chunk chunk2 = ChunkGenerator.GenerateFlat(earth, new ChunkLocation(-1,  0), 3);
            //Chunk chunk3 = ChunkGenerator.GenerateFlat(earth, new ChunkLocation( 0, -1), 2);
            //Chunk chunk4 = ChunkGenerator.GenerateFlat(earth, new ChunkLocation( 0,  0), 1);

            /*
             *
             *
             *          Chunk block generators
             *          generates blocks... in a chunk :)))
             *          you could manually do them too
             *
             *
             */
            for (int x = -1; x <= 1; x++)
            {
                for (int z = -1, total = 1; z <= 1; z++, total++)
                {
                    Chunk chunk = ChunkGenerator.GenerateFlatGaps(earth, new ChunkLocation(x, z), 8, x + 3, z + 3);
                    //Chunk chunk = ChunkGenerator.GenerateFlat(earth, new ChunkLocation(x, z), 1);
                    BlockMeshGenerator.GenerateChunk(chunk);
                    earth.Chunks.Add(chunk.Location, chunk);
                }
            }

            Worlds.Add(earth);

            Inputs.Keyboard = KeyboardState;
            Inputs.Mouse    = MouseState;

            CursorVisible = false;
            CursorGrabbed = true;

            base.OnLoad();
        }