private void parseHeader() { switch (headerType) { case HeaderType.Traditional: tHeader.DateTime = sHelper.ReadString(8); tHeader.Padding = sHelper.ReadBytes(120); tHeader.RowCount = sHelper.ReadInt32; break; case HeaderType.Defined: Row row = new Row(dHeader_Template); populateRow(ref row, SenderType.PARSE_HEADER); dHeader = row; break; } }
public Scene Read() { //The 12-byte header consists of three 4-byte entries: _header = new GlbHeader(); //magic equals 0x46546C67. It is ASCII string glTF, and can be used to identify data as Binary glTF. _header.Magic = _stream.ReadUInt <LittleEndianConverter>(); //version indicates the version of the Binary glTF container format. This specification defines version 2. _header.Version = _stream.ReadUInt <LittleEndianConverter>(); //length is the total length of the Binary glTF, including Header and all Chunks, in bytes. _header.Length = _stream.ReadUInt <LittleEndianConverter>(); if (_header.Version != 2) { throw new NotImplementedException($"Version {_header.Version} not implemented"); } //Chunk 0 Json uint jsonChunkLength = _stream.ReadUInt <LittleEndianConverter>(); string jsonChunkType = _stream.ReadString(4); if (jsonChunkType != "JSON") { throw new GltfReaderException("Chunk type does not match", _stream.Position); } _root = JsonConvert.DeserializeObject <GltfRoot>(_stream.ReadString((int)jsonChunkLength)); //Chunk 1 bin uint binChunkLength = _stream.ReadUInt <LittleEndianConverter>(); string binChunkType = _stream.ReadString(4); //Check the chunk type if (binChunkType != "BIN\0") { throw new GltfReaderException("Chunk type does not match", _stream.Position); } byte[] binChunk = _stream.ReadBytes((int)binChunkLength); _binaryStream = new StreamIO(binChunk); return(GltfBinaryReaderBase.GetBynaryReader((int)_header.Version, _root, binChunk).Read()); }