示例#1
0
        public FbxReader(BinaryReader reader)
        {
            reader.RequireMagic(Magic);
            Version = reader.ReadInt32();
            if (Version < MinimumSupportedVersion || Version > MaximumSupportedVersion)
                throw new InvalidDataException("Unsupported FBX version " + Version + "; supported versions are " + MinimumSupportedVersion + " to " + MaximumSupportedVersion + ".");

            FbxSection section;

            while ((section = new FbxSection(reader)).IsValid) {
                switch (section.Name) {
                    case FbxHeaderExtension.FbxFileTypeName:
                        new FbxHeaderExtension(section);
                        break;

                    case "FileId": // Seems to be a GUID in raw data.
                    case "CreationTime": // Same as in header.
                    case "Creator": // Same as in header.
                    case "GlobalSettings": // Don't care right now.
                        section.SeekToEnd();
                        break;

                    case "Documents":
                    case "References":
                    case "Definitions":
                        section.SeekToEnd();
                        break;

                    default:
                        throw new InvalidDataException("Unexpected root section '" + section.Name + "'.");
                }

                section.RequireEnd();
            }
        }
        public FbxHeaderExtension(FbxSection section)
        {
            FbxSection child;

            section.RequireName(FbxFileTypeName);
            while (section.ReadChild(out child)) {
                switch (child.Name) {
                    case "FBXHeaderVersion": HeaderVersion = child.ReadInt32Value(); break;
                    case "FBXVersion": Version = child.ReadInt32Value(); break;
                    case "EncryptionType":
                        var encryptionType = child.ReadInt32Value();
                        if (encryptionType != 0)
                            throw new InvalidDataException("Unsupported encryption type " + encryptionType + ".");
                        break;

                    case "CreationTimeStamp": CreationTimeStamp = child.ReadTimeStamp(); break;

                    case "Creator": Creator = child.ReadStringValue(); break;

                    case "SceneInfo":
                        child.SeekToEnd();
                        break;
                        /*
            SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
            Type: "UserData"
            Version: 100
            MetaData:  {
            Version: 100
            Title: ""
            Subject: ""
            Author: ""
            Keywords: ""
            Revision: ""
            Comment: ""
            }
            Properties70:  {
            P: "DocumentUrl", "KString", "Url", "", "D:\f***a.FBX"
            P: "SrcDocumentUrl", "KString", "Url", "", "D:\f***a.FBX"
            P: "Original", "Compound", "", ""
            P: "Original|ApplicationVendor", "KString", "", "", "Autodesk"
            P: "Original|ApplicationName", "KString", "", "", "3ds Design"
            P: "Original|ApplicationVersion", "KString", "", "", "2013"
            P: "Original|DateTime_GMT", "DateTime", "", "", "09/04/2014 19:19:33.481"
            P: "Original|FileName", "KString", "", "", "D:\f***a.FBX"
            P: "LastSaved", "Compound", "", ""
            P: "LastSaved|ApplicationVendor", "KString", "", "", "Autodesk"
            P: "LastSaved|ApplicationName", "KString", "", "", "3ds Design"
            P: "LastSaved|ApplicationVersion", "KString", "", "", "2013"
            P: "LastSaved|DateTime_GMT", "DateTime", "", "", "09/04/2014 19:19:33.481"
            }
            }
            }*/

                    default:
                        throw new NotImplementedException();
                }

                child.RequireEnd();
            }
        }
示例#3
0
 static void ReadTimestampSet(ref int value, ref FbxSection section)
 {
     if (value != -1)
     {
         throw new InvalidOperationException("Value " + section.Name + " has already been provided.");
     }
     value = section.ReadInt32Value();
 }
示例#4
0
文件: Fbx.cs 项目: layshua/Alexandria
        public FbxReader(BinaryReader reader)
        {
            reader.RequireMagic(Magic);
            Version = reader.ReadInt32();
            if (Version < MinimumSupportedVersion || Version > MaximumSupportedVersion)
            {
                throw new InvalidDataException("Unsupported FBX version " + Version + "; supported versions are " + MinimumSupportedVersion + " to " + MaximumSupportedVersion + ".");
            }

            FbxSection section;

            while ((section = new FbxSection(reader)).IsValid)
            {
                switch (section.Name)
                {
                case FbxHeaderExtension.FbxFileTypeName:
                    new FbxHeaderExtension(section);
                    break;

                case "FileId":                         // Seems to be a GUID in raw data.
                case "CreationTime":                   // Same as in header.
                case "Creator":                        // Same as in header.
                case "GlobalSettings":                 // Don't care right now.
                    section.SeekToEnd();
                    break;

                case "Documents":
                case "References":
                case "Definitions":
                    section.SeekToEnd();
                    break;


                default:
                    throw new InvalidDataException("Unexpected root section '" + section.Name + "'.");
                }

                section.RequireEnd();
            }
        }
示例#5
0
        public FbxHeaderExtension(FbxSection section)
        {
            FbxSection child;

            section.RequireName(FbxFileTypeName);
            while (section.ReadChild(out child))
            {
                switch (child.Name)
                {
                case "FBXHeaderVersion": HeaderVersion = child.ReadInt32Value(); break;

                case "FBXVersion": Version = child.ReadInt32Value(); break;

                case "EncryptionType":
                    var encryptionType = child.ReadInt32Value();
                    if (encryptionType != 0)
                    {
                        throw new InvalidDataException("Unsupported encryption type " + encryptionType + ".");
                    }
                    break;

                case "CreationTimeStamp": CreationTimeStamp = child.ReadTimeStamp(); break;

                case "Creator": Creator = child.ReadStringValue(); break;

                case "SceneInfo":
                    child.SeekToEnd();
                    break;

                /*
                 * SceneInfo: "SceneInfo::GlobalInfo", "UserData" {
                 * Type: "UserData"
                 * Version: 100
                 * MetaData:  {
                 *      Version: 100
                 *      Title: ""
                 *      Subject: ""
                 *      Author: ""
                 *      Keywords: ""
                 *      Revision: ""
                 *      Comment: ""
                 * }
                 * Properties70:  {
                 *      P: "DocumentUrl", "KString", "Url", "", "D:\f***a.FBX"
                 *      P: "SrcDocumentUrl", "KString", "Url", "", "D:\f***a.FBX"
                 *      P: "Original", "Compound", "", ""
                 *      P: "Original|ApplicationVendor", "KString", "", "", "Autodesk"
                 *      P: "Original|ApplicationName", "KString", "", "", "3ds Design"
                 *      P: "Original|ApplicationVersion", "KString", "", "", "2013"
                 *      P: "Original|DateTime_GMT", "DateTime", "", "", "09/04/2014 19:19:33.481"
                 *      P: "Original|FileName", "KString", "", "", "D:\f***a.FBX"
                 *      P: "LastSaved", "Compound", "", ""
                 *      P: "LastSaved|ApplicationVendor", "KString", "", "", "Autodesk"
                 *      P: "LastSaved|ApplicationName", "KString", "", "", "3ds Design"
                 *      P: "LastSaved|ApplicationVersion", "KString", "", "", "2013"
                 *      P: "LastSaved|DateTime_GMT", "DateTime", "", "", "09/04/2014 19:19:33.481"
                 * }
                 * }
                 * }*/

                default:
                    throw new NotImplementedException();
                }

                child.RequireEnd();
            }
        }
示例#6
0
 public bool ReadChild(out FbxSection child, string requiredName = null)
 {
     child = ReadChild(requiredName);
     return(child.IsValid);
 }
示例#7
0
 static void ReadTimestampSet(ref int value, ref FbxSection section)
 {
     if(value != -1)
         throw new InvalidOperationException("Value " + section.Name + " has already been provided.");
     value = section.ReadInt32Value();
 }
示例#8
0
 public bool ReadChild(out FbxSection child, string requiredName = null)
 {
     child = ReadChild(requiredName);
     return child.IsValid;
 }