Ejemplo n.º 1
0
        List <Vertex> CreateCubeVertices(int x, int y, int z)
        {
            var block = GetBlock(x, y, z);

            if (!block.render())
            {
                return(new List <Vertex>());
            }

            var cubeMesh = new CubeMesh
            {
                TextureCoordinates = _textureAtlas.GetTextureCoordinates(block.texture()),
                Position           = (_chunkPosition + new WorldPosition(x, y, z)).AsVector3()
            };

            // Only Render faces when they are visible
            cubeMesh.IncludeFaces.Top    = !GetBlock(x, y + 1, z).render();
            cubeMesh.IncludeFaces.Bottom = !GetBlock(x, y - 1, z).render();
            cubeMesh.IncludeFaces.Front  = !GetBlock(x, y, z - 1).render();
            cubeMesh.IncludeFaces.Back   = !GetBlock(x, y, z + 1).render();
            cubeMesh.IncludeFaces.Right  = !GetBlock(x + 1, y, z).render();
            cubeMesh.IncludeFaces.Left   = !GetBlock(x - 1, y, z).render();

            var vertices = cubeMesh.CreateMesh();

            return(vertices);
        }
Ejemplo n.º 2
0
        private void CreateMesh()
        {
            var scale = new Vector3
            {
                X = _max.X - _min.X,
                Y = _max.Y - _min.Y,
                Z = _max.Z - _min.Z
            };

            var cubeMesh = new CubeMesh
            {
                Position = _min,
                Scale    = scale,
                Color    = Color
            };

            var cubeVertices = cubeMesh.CreateMesh();

            _renderObject = new RenderObject(cubeVertices.ToArray());
        }