Exemplo n.º 1
0
        public void Load(BinaryReader Reader)
        {
            New();

            try
            {
                // 检查文件头
                Label tHeader = new Label(4);
                tHeader.Load(Reader);
                if (tHeader.Content != "FMM")
                    throw new FormatException("Header check failed.");
                if (Reader.ReadUInt32() != 100)
                    throw new FormatException("Version not support.");
                UInt32 tBlockCount = Reader.ReadUInt32();
                _Author.Load(Reader);
                _Description.Load(Reader);

                // 读取所有块
                Label tBlockHeader = new Label(8);
                for (UInt32 i = 0; i < tBlockCount; ++i)
                {
                    Block tBlock = null;
                    tBlockHeader.Load(Reader);
                    switch (tBlockHeader.Content)
                    {
                        case "VERTEX":
                            tBlock = new VertexBlock();
                            break;
                        case "INDEX":
                            tBlock = new IndexBlock();
                            break;
                        case "SUBSET":
                            tBlock = new SubsetBlock();
                            break;
                        case "MATERIAL":
                            tBlock = new MaterialBlock();
                            break;
                        case "BOUNDBOX":
                            tBlock = new BoundingBoxBlock();
                            break;
                        default:
                            tBlock = new UnknownBlock(tBlockHeader.Content);
                            break;
                    }

                    tBlock.Load(Reader);
                    _BlockList.Add(tBlock);
                }
            }
            catch
            {
                New();

                throw;
            }
        }
Exemplo n.º 2
0
        public void Load(BinaryReader Reader)
        {
            New();

            try
            {
                // 检查文件头
                Label tHeader = new Label(4);
                tHeader.Load(Reader);
                if (tHeader.Content != "FMM")
                {
                    throw new FormatException("Header check failed.");
                }
                if (Reader.ReadUInt32() != 100)
                {
                    throw new FormatException("Version not support.");
                }
                UInt32 tBlockCount = Reader.ReadUInt32();
                _Author.Load(Reader);
                _Description.Load(Reader);

                // 读取所有块
                Label tBlockHeader = new Label(8);
                for (UInt32 i = 0; i < tBlockCount; ++i)
                {
                    Block tBlock = null;
                    tBlockHeader.Load(Reader);
                    switch (tBlockHeader.Content)
                    {
                    case "VERTEX":
                        tBlock = new VertexBlock();
                        break;

                    case "INDEX":
                        tBlock = new IndexBlock();
                        break;

                    case "SUBSET":
                        tBlock = new SubsetBlock();
                        break;

                    case "MATERIAL":
                        tBlock = new MaterialBlock();
                        break;

                    case "BOUNDBOX":
                        tBlock = new BoundingBoxBlock();
                        break;

                    default:
                        tBlock = new UnknownBlock(tBlockHeader.Content);
                        break;
                    }

                    tBlock.Load(Reader);
                    _BlockList.Add(tBlock);
                }
            }
            catch
            {
                New();

                throw;
            }
        }