Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeightDepthUVVertexData"/> class.
        /// </summary>
        /// <param name="data">The binary data.</param>
        /// <param name="width">The width of the vertex block.</param>
        /// <param name="height">The height of the vertex block.</param>
        public HeightDepthUVVertexData(byte[] data, byte width, byte height)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    int arrayEntryCount = (width + 1) * (height + 1);
                    for (int i = 0; i < arrayEntryCount; ++i)
                    {
                        Heightmap.Add(br.ReadSingle());
                    }

                    for (int i = 0; i < arrayEntryCount; ++i)
                    {
                        Tuple <ushort, ushort> uvEntry = new Tuple <ushort, ushort>(br.ReadUInt16(), br.ReadUInt16());
                        UVMap.Add(uvEntry);
                    }

                    for (int i = 0; i < arrayEntryCount; ++i)
                    {
                        Depthmap.Add(br.ReadByte());
                    }
                }
            }
        }
Пример #2
0
        private Heightmap CombineAll()
        {
            if (_items.Count == 0)
            {
                return(new Heightmap(2, 2));
            }

            var result = new Heightmap(_items[0].HeightmapModified.Width, _items[0].HeightmapModified.Height);

            foreach (var heightmap in _items)
            {
                if (!heightmap.IsVisible)
                {
                    continue;
                }

                if (heightmap.CurrentMode == HeightmapBrowserItem.Mode.Add)
                {
                    result.Add(heightmap.HeightmapModified);
                }
                else
                {
                    result.Substract(heightmap.HeightmapModified);
                }
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeightDepthVertexData"/> class.
        /// </summary>
        /// <param name="data">The binary data.</param>
        /// <param name="width">The width of the vertex block.</param>
        /// <param name="height">The height of the vertex block.</param>
        public HeightDepthVertexData(byte[] data, byte width, byte height)
        {
            using var ms = new MemoryStream(data);
            using var br = new BinaryReader(ms);
            var arrayEntryCount = (width + 1) * (height + 1);

            for (var i = 0; i < arrayEntryCount; ++i)
            {
                Heightmap.Add(br.ReadSingle());
            }

            for (var i = 0; i < arrayEntryCount; ++i)
            {
                Depthmap.Add(br.ReadByte());
            }
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeightUVVertexData"/> class.
        /// </summary>
        /// <param name="data">The binary data.</param>
        /// <param name="width">The width of the vertex block.</param>
        /// <param name="height">The height of the vertex block.</param>
        public HeightUVVertexData(byte[] data, byte width, byte height)
        {
            using var ms = new MemoryStream(data);
            using var br = new BinaryReader(ms);
            var arrayEntryCount = (width + 1) * (height + 1);

            for (var i = 0; i < arrayEntryCount; ++i)
            {
                Heightmap.Add(br.ReadSingle());
            }

            for (var i = 0; i < arrayEntryCount; ++i)
            {
                var uvEntry = new Tuple <ushort, ushort>(br.ReadUInt16(), br.ReadUInt16());
                UVMap.Add(uvEntry);
            }
        }