Exemplo n.º 1
0
        private static void ReadHeader(ref BinaryReader rb, out DXMHeader header)
        {
            header.nameCharacter0 = rb.ReadByte();
            header.nameCharacter1 = rb.ReadByte();
            header.nameCharacter2 = rb.ReadByte();
            header.nameCharacter3 = rb.ReadByte();
            header.majorVersion   = rb.ReadByte();
            header.minorVersion   = rb.ReadByte();
            header.encoding       = rb.ReadByte();
            header.compression    = rb.ReadByte();

            header.vertexCount            = rb.ReadUInt64();
            header.vertexCompositionFlags = rb.ReadUInt32();

            header.groupCount     = rb.ReadUInt16();
            header.indexFormat    = rb.ReadByte();
            header.indexByteCount = rb.ReadByte();

            header.vertexTableAddr = rb.ReadUInt64();
            header.indexTableAddr  = rb.ReadUInt64();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks if the file headers matches this DXM loader pattern.
        /// </summary>
        /// <param name="header">The header to checks.</param>
        /// <param name="flagMesh">A reference to the mesh vertex composition flag.</param>
        /// <param name="flagPC">A reference to the point cloud vertex composition flag.</param>
        private static void ValidateHeader(DXMHeader header, ref int flagMesh, ref int flagPC)
        {
            flagMesh |= (int)DXMVertexFlag.Vertex_3_F32;
            flagMesh |= (int)DXMVertexFlag.Normal_3_F32;
            flagMesh |= (int)DXMVertexFlag.Texcoord_2_F32;

            flagPC |= (int)DXMVertexFlag.Vertex_3_F32;
            flagPC |= (int)DXMVertexFlag.Color_4_U8;

            string ident = "" +
                           Convert.ToChar(header.nameCharacter0) +
                           Convert.ToChar(header.nameCharacter1) +
                           Convert.ToChar(header.nameCharacter2) +
                           Convert.ToChar(header.nameCharacter3);

            if (ident != "DXM1")
            {
                throw new Exception("Invalid file format of type: " + ident);
            }
            if ((header.majorVersion * 256 + header.minorVersion) < (2 * 256 + 2))
            {
                throw new Exception("Outdated loader.");
            }
            if (header.encoding != (int)DXMEncoding.DeInterleaved)
            {
                throw new Exception("Unsupported encoding.");
            }
            if (header.compression != (int)DXMCompression.NoCompression)
            {
                throw new Exception("Unsupported compression.");
            }
            if (header.vertexCompositionFlags != flagMesh && header.vertexCompositionFlags != flagPC)
            {
                throw new Exception("Unsupported vertex format.");
            }
        }