コード例 #1
0
        public Model(ReadStream input)
        {
            var vertexCount    = input.ReadByte();
            var primitiveCount = input.ReadByte();

            PaintJobCount = input.ReadByte();
            input.Skip(1);

            Vertices = new Vector3[vertexCount];
            for (int i = 0; i < vertexCount; i++)
            {
                Vertices[i] = input.ReadVertex();
            }

            input.Skip(8 * primitiveCount);

            Primitives = new Primitive[primitiveCount];
            for (int i = 0; i < primitiveCount; i++)
            {
                Primitives[i] = new Primitive(PaintJobCount, input);
            }
        }
コード例 #2
0
        public static Dictionary <string, byte[]> ReadResourceMap(byte[] rawResource)
        {
            var result = new Dictionary <string, byte[]>();
            var input  = new ReadStream(rawResource);

            input.Skip(4);
            var resourceCount = input.ReadShort();

            var ids = new string[resourceCount];

            for (int i = 0; i < resourceCount; i++)
            {
                ids[i] = input.ReadFixedLengthString(4);
            }

            var sortedIds = new SortedDictionary <int, string>();

            for (int i = 0; i < resourceCount; i++)
            {
                sortedIds[input.ReadInt()] = ids[i];
            }

            var data          = new ReadBuffer(rawResource).Drop(6 + 8 * resourceCount);
            var sortedOffsets = new List <int>(sortedIds.Keys);

            sortedOffsets.Add(data.Length);

            for (int i = 0; i < resourceCount; i++)
            {
                var startOffset = sortedOffsets[i];
                var endOffset   = sortedOffsets[i + 1];
                result[sortedIds[startOffset]] = data.Slice(startOffset, endOffset - startOffset).ToArray();
            }

            return(result);
        }