Exemple #1
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            VertexElementCount = reader.ReadUInt32();
            uint vertexStreamCount = reader.ReadUInt32();

            IsStreaming = reader.ReadBooleanStrict();

            Streams = new VertexStream[vertexStreamCount];

            for (int i = 0; i < Streams.Length; i++)
            {
                var stream = new VertexStream();
                Streams[i] = stream;

                stream.Flags = reader.ReadUInt32();
                uint vertexByteStride = reader.ReadUInt32();
                stream.UnknownData = new byte[reader.ReadUInt32()][];

                for (uint j = 0; j < stream.UnknownData.Length; j++)
                {
                    // 4 bytes read separately
                    stream.UnknownData[j] = reader.ReadBytesStrict(4);
                }

                stream.GUID   = GGUUID.FromData(reader);
                stream.Buffer = HwBuffer.FromVertexData(reader, IsStreaming, vertexByteStride, VertexElementCount);
            }
        }
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint vertexElementCount = reader.ReadUInt32();
            uint vertexStreamCount  = reader.ReadUInt32();
            bool isStreaming        = reader.ReadBooleanStrict();

            ResourceGUIDs = new GGUUID[vertexStreamCount];
            Buffers       = new HwBuffer[vertexStreamCount];

            for (uint i = 0; i < Buffers.Length; i++)
            {
                uint unknownFlags     = reader.ReadUInt32();
                uint vertexByteStride = reader.ReadUInt32();
                uint unknownCounter   = reader.ReadUInt32();

                for (uint j = 0; j < unknownCounter; j++)
                {
                    // 4 bytes read separately
                    var packedData = reader.ReadBytesStrict(4);
                }

                ResourceGUIDs[i] = GGUUID.FromData(reader);
                Buffers[i]       = HwBuffer.FromVertexData(reader, isStreaming, vertexByteStride, vertexElementCount);
            }
        }
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint indexElementCount = reader.ReadUInt32();

            if (indexElementCount > 0)
            {
                Flags = reader.ReadUInt32();
                var  format      = (EIndexFormat)reader.ReadUInt32();
                uint isStreaming = reader.ReadUInt32();

                if (isStreaming != 0 && isStreaming != 1)
                {
                    throw new InvalidDataException("Must be true or false");
                }

                ResourceGUID = GGUUID.FromData(reader);
                Buffer       = HwBuffer.FromIndexData(reader, format, isStreaming != 0, indexElementCount);
            }
        }
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint bufferElementCount = reader.ReadUInt32();

            if (bufferElementCount > 0)
            {
                uint isStreaming = reader.ReadUInt32();
                Flags = reader.ReadUInt32();
                var format = (EDataBufferFormat)reader.ReadUInt32();
                uint bufferStride = reader.ReadUInt32();

                if (isStreaming != 0 && isStreaming != 1)
                    throw new InvalidDataException("Must be true or false");

                if (format != EDataBufferFormat.Structured)
                    bufferStride = HwBuffer.GetStrideForFormat(format);

                Buffer = HwBuffer.FromData(reader, format, isStreaming != 0, bufferStride, bufferElementCount);
            }
        }
Exemple #5
0
        public static HwBuffer FromData(BinaryReader reader, EDataBufferFormat format, bool streaming, uint byteStride, uint elementCount)
        {
            var buffer = new HwBuffer
            {
                Format        = format,
                ElementStride = byteStride,
                ElementCount  = elementCount,
            };

            if (streaming)
            {
                buffer.StreamInfo = StreamHandle.FromData(reader);
            }
            else
            {
                buffer.Data = reader.ReadBytesStrict(elementCount * byteStride);
            }

            return(buffer);
        }