Ejemplo n.º 1
0
        void AddMesh(int x, int y, int z, ref Color color, MeshPart source, ChunkVertices destination)
        {
            foreach (var index in source.Indices)
            {
                destination.AddIndex(index);
            }

            var vertices = source.Vertices;

            for (int i = 0; i < vertices.Length; i++)
            {
                var sourceVertex = vertices[i];

                var vertex = new VertexPositionNormalColorTexture
                {
                    Position          = sourceVertex.Position,
                    Normal            = sourceVertex.Normal,
                    Color             = color,
                    TextureCoordinate = sourceVertex.TextureCoordinate
                };

                // ブロック位置へ移動。
                vertex.Position.X += x;
                vertex.Position.Y += y;
                vertex.Position.Z += z;

                // ブロックの MeshPart はその中心に原点があるため、半ブロック移動。
                vertex.Position += blockMeshOffset;

                // チャンク メッシュはメッシュの中心位置を原点とするため、半メッシュ移動。
                vertex.Position -= meshManager.MeshOffset;

                destination.AddVertex(ref vertex);
            }
        }
Ejemplo n.º 2
0
        void AddMesh(int x, int y, int z, ref Color color, MeshPart source, ChunkVertices destination)
        {
            foreach (var index in source.Indices)
                destination.AddIndex(index);

            var vertices = source.Vertices;
            for (int i = 0; i < vertices.Length; i++)
            {
                var sourceVertex = vertices[i];

                var vertex = new VertexPositionNormalColorTexture
                {
                    Position = sourceVertex.Position,
                    Normal = sourceVertex.Normal,
                    Color = color,
                    TextureCoordinate = sourceVertex.TextureCoordinate
                };

                // ブロック位置へ移動。
                vertex.Position.X += x;
                vertex.Position.Y += y;
                vertex.Position.Z += z;

                // ブロックの MeshPart はその中心に原点があるため、半ブロック移動。
                vertex.Position += blockMeshOffset;

                // チャンク メッシュはメッシュの中心位置を原点とするため、半メッシュ移動。
                vertex.Position -= meshManager.MeshOffset;

                destination.AddVertex(ref vertex);
            }
        }