/// <summary> /// Reads a chunk ID and chunk size. /// </summary> /// <returns>The chunk ID at the current location.</returns> protected short ReadFileChunk(BinaryMemoryReader reader) { // get the chunk id short id = reader.ReadInt16(); // read the length for this chunk currentChunkLength = reader.ReadInt32(); return(id); }
/// <summary> /// Reads a specified number of shorts and copies them into the destination pointer. /// </summary> /// <param name="count">Number of values to read.</param> /// <param name="dest">Pointer to copy the values into.</param> protected void ReadShorts(BinaryMemoryReader reader, int count, IntPtr dest) { // blast the data into the buffer unsafe { short *pointer = (short *)dest.ToPointer(); for (int i = 0; i < count; i++) { pointer[i] = reader.ReadInt16(); } } }
/// <summary> /// Reads a file header and checks the version string. /// </summary> protected void ReadFileHeader(BinaryMemoryReader reader) { short headerID = 0; // read the header ID headerID = reader.ReadInt16(); // better hope this is the header if (headerID == (short)MeshChunkID.Header) { string fileVersion = ReadString(reader); // read the version string if (version != fileVersion) { throw new AxiomException("Invalid file: version incompatible, file reports {0}, Serializer is version {1}", fileVersion, version); } } else { throw new AxiomException("Invalid file: no header found."); } }
protected short ReadShort(BinaryMemoryReader reader) { return(reader.ReadInt16()); }