コード例 #1
0
ファイル: FbxIOSettings.cs プロジェクト: tank90fc/fbx_wrapper
        public new static FbxIOSettings Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxIOSettings_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            return(ret);
        }
コード例 #2
0
ファイル: FbxIOSettings.cs プロジェクト: zwiglm/NeoAxisEngine
        public new static FbxIOSettings Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxIOSettings_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            return(ret);
        }
コード例 #3
0
ファイル: FbxExporter.cs プロジェクト: zwiglm/NeoAxisEngine
        public FbxIOSettings GetIOSettings()
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxExporter_GetIOSettings(swigCPtr);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            return(ret);
        }
コード例 #4
0
        public void Init()
        {
            SdkManager = FbxManager.Create();
            FbxIOSettings ios = FbxIOSettings.Create(SdkManager, "IOSRoot");

            SdkManager.SetIOSettings(ios);
        }
コード例 #5
0
ファイル: FbxReader.cs プロジェクト: yeluo-vinager/FbxWrapper
        public virtual FbxIOSettings GetIOSettings()
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxReader_GetIOSettings(swigCPtr);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            return(ret);
        }
コード例 #6
0
ファイル: MyExport.cs プロジェクト: tank90fc/fbx_wrapper
    public void WriteToFile(string Filename)
    {
        int  Major, Minor, Revision;
        bool Status = true;

        int  FileFormat  = -1;
        bool bEmbedMedia = false;

        // Create an exporter.
        FbxExporter Exporter = FbxExporter.Create(SdkManager, "");

        // set file format
        // Write in fall back format if pEmbedMedia is true
        FileFormat = SdkManager.GetIOPluginRegistry().GetNativeWriterFormat();
        FbxIOSettings IOS_REF = SdkManager.GetIOSettings();

        // Set the export states. By default, the export states are always set to
        // true except for the option eEXPORT_TEXTURE_AS_EMBEDDED. The code below
        // shows how to change these states.


        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_MATERIAL, true);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_TEXTURE, true);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_EMBEDDED, bEmbedMedia);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_SHAPE, true);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_GOBO, true);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_ANIMATION, true);
        IOS_REF.SetBoolProp(fbx_wrapper.EXP_FBX_GLOBAL_SETTINGS, true);

        string CompatibilitySetting = fbx_wrapper.FBX_2013_00_COMPATIBLE;

        if (!Exporter.SetFileExportVersion(new FbxString(CompatibilitySetting), FbxSceneRenamer.ERenamingMode.eNone))
        {
            Debug.LogWarning("Call to KFbxExporter::SetFileExportVersion(FBX_2013_00_COMPATIBLE) to export 2013 fbx file format failed.\n");
        }

        //// Initialize the exporter by providing a filename.
        if (!Exporter.Initialize(Filename, FileFormat, SdkManager.GetIOSettings()))
        {
            Debug.LogWarning("Call to KFbxExporter::Initialize() failed.\n");
            string errorString = Exporter.GetStatus().GetErrorString();
            Debug.LogWarning("Error returned:" + errorString);
            return;
        }

        //FbxManager.GetFileFormatVersion(Major, Minor, Revision);

        // Export the scene.
        Status = Exporter.Export(Scene);

        if (!Status)
        {
            string errorString = Exporter.GetStatus().GetErrorString();
            Debug.LogWarning("Error returned:" + errorString);
        }
        Clear();

        return;
    }
コード例 #7
0
ファイル: FbxManager.cs プロジェクト: zwiglm/NeoAxisEngine
 public void FillIOSettingsForWritersRegistered(FbxIOSettings pIOS)
 {
     FbxWrapperNativePINVOKE.FbxManager_FillIOSettingsForWritersRegistered(swigCPtr, FbxIOSettings.getCPtr(pIOS));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #8
0
 public void SetModes(bool pExporting, FbxIOSettings pIOS)
 {
     FbxWrapperNativePINVOKE.FbxAnimCurveFilterConstantKeyReducer_SetModes(swigCPtr, pExporting, FbxIOSettings.getCPtr(pIOS));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #9
0
 public bool Equals(FbxIOSettings other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }
コード例 #10
0
 public void UpdateScaleCompensate(FbxNode pNode, FbxIOSettings pIOS)
 {
     FbxWrapperNativePINVOKE.FbxScene_UpdateScaleCompensate(swigCPtr, FbxNode.getCPtr(pNode), FbxIOSettings.getCPtr(pIOS));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #11
0
 public void FillIOSettingsForReadersRegistered(FbxIOSettings pIOS)
 {
     fbx_wrapperPINVOKE.FbxManager_FillIOSettingsForReadersRegistered(swigCPtr, FbxIOSettings.getCPtr(pIOS));
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #12
0
ファイル: FbxManager.cs プロジェクト: koriandrei/ds2fbx
 public virtual void SetIOSettings(FbxIOSettings pIOSettings)
 {
     NativeMethods.FbxManager_SetIOSettings(swigCPtr, FbxIOSettings.getCPtr(pIOSettings));
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
コード例 #13
0
ファイル: FbxManager.cs プロジェクト: zwiglm/NeoAxisEngine
 public void FillCommonIOSettings(FbxIOSettings pIOS, bool pImport)
 {
     FbxWrapperNativePINVOKE.FbxManager_FillCommonIOSettings(swigCPtr, FbxIOSettings.getCPtr(pIOS), pImport);
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #14
0
    void TaskOnClick()
    {
        // Build the fbx scene file path
        // (player/player_data/emptySceneFromRuntime.fbx)
        string fbxFilePath = Application.dataPath;

        fbxFilePath = Path.Combine(fbxFilePath, "emptySceneFromRuntime.fbx");
        fbxFilePath = Path.GetFullPath(fbxFilePath);

        Debug.Log(string.Format("The file that will be written is {0}", fbxFilePath));

        using (var fbxManager = FbxManager.Create())
        {
            FbxIOSettings fbxIOSettings = FbxIOSettings.Create(fbxManager, Globals.IOSROOT);

            // Configure the IO settings.
            fbxManager.SetIOSettings(fbxIOSettings);

            // Create the exporter
            var fbxExporter = FbxExporter.Create(fbxManager, "Exporter");

            // Initialize the exporter.
            int fileFormat = fbxManager.GetIOPluginRegistry().FindWriterIDByDescription("FBX ascii (*.fbx)");

            bool status = fbxExporter.Initialize(fbxFilePath, fileFormat, fbxIOSettings);
            // Check that initialization of the fbxExporter was successful
            if (!status)
            {
                Debug.LogError(string.Format("failed to initialize exporter, reason: {0}",
                                             fbxExporter.GetStatus().GetErrorString()));
                return;
            }

            // Create a scene
            var fbxScene = FbxScene.Create(fbxManager, "Scene");

            // create scene info
            FbxDocumentInfo fbxSceneInfo = FbxDocumentInfo.Create(fbxManager, "SceneInfo");

            // set some scene info values
            fbxSceneInfo.mTitle    = "fromRuntime";
            fbxSceneInfo.mSubject  = "Exported from a Unity runtime";
            fbxSceneInfo.mAuthor   = "Unity Technologies";
            fbxSceneInfo.mRevision = "1.0";
            fbxSceneInfo.mKeywords = "export runtime";
            fbxSceneInfo.mComment  = "This is to demonstrate the capability of exporting from a Unity runtime, using the FBX SDK C# bindings";

            fbxScene.SetSceneInfo(fbxSceneInfo);

            // Export the scene to the file.
            status = fbxExporter.Export(fbxScene);

            // cleanup
            fbxScene.Destroy();
            fbxExporter.Destroy();
        }
    }
コード例 #15
0
        public virtual bool Apply(SWIGTYPE_p_p_FbxAnimCurve pCurve, int pCount, FbxIOSettings pIOS, FbxStatus pStatus)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxAnimCurveFilterScaleCompensate_Apply__SWIG_8(swigCPtr, SWIGTYPE_p_p_FbxAnimCurve.getCPtr(pCurve), pCount, FbxIOSettings.getCPtr(pIOS), FbxStatus.getCPtr(pStatus));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #16
0
        public virtual bool Apply(SWIGTYPE_p_p_FbxAnimCurve pCurve, int pCount, FbxIOSettings pIOS)
        {
            bool ret = fbx_wrapperPINVOKE.FbxAnimCurveFilterScaleCompensate_Apply__SWIG_9(swigCPtr, SWIGTYPE_p_p_FbxAnimCurve.getCPtr(pCurve), pCount, FbxIOSettings.getCPtr(pIOS));

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #17
0
        public virtual bool Initialize(string pFileName, int pFileFormat, FbxIOSettings pIOSettings)
        {
            bool ret = NativeMethods.FbxIOBase_Initialize__SWIG_0(swigCPtr, pFileName, pFileFormat, FbxIOSettings.getCPtr(pIOSettings));

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #18
0
            /// <summary>
            /// Export all the objects in the set.
            /// Return the number of objects in the set that we exported.
            /// </summary>
            public int ExportAll(IEnumerable <UnityEngine.Object> unityExportSet)
            {
                // Create the FBX manager
                using (var fbxManager = FbxManager.Create())
                {
                    FbxIOSettings fbxIOSettings = FbxIOSettings.Create(fbxManager, Globals.IOSROOT);

                    // Configure the IO settings.
                    fbxManager.SetIOSettings(fbxIOSettings);

                    // Create the exporter
                    var fbxExporter = FbxExporter.Create(fbxManager, "Exporter");

                    // Initialize the exporter.
                    int fileFormat = fbxManager.GetIOPluginRegistry().FindWriterIDByDescription("FBX ascii (*.fbx)");

                    bool status = fbxExporter.Initialize(LastFilePath, fileFormat, fbxIOSettings);
                    // Check that initialization of the fbxExporter was successful
                    if (!status)
                    {
                        Debug.LogError(string.Format("failed to initialize exporter, reason:D {0}",
                                                     fbxExporter.GetStatus().GetErrorString()));
                        return(0);
                    }

                    // By default, FBX exports in its most recent version. You might want to specify
                    // an older version for compatibility with other applications.
                    fbxExporter.SetFileExportVersion("FBX201400");

                    // Create a scene
                    var fbxScene = FbxScene.Create(fbxManager, "Scene");

                    // create scene info
                    FbxDocumentInfo fbxSceneInfo = FbxDocumentInfo.Create(fbxManager, "SceneInfo");

                    // set some scene info values
                    fbxSceneInfo.mTitle    = Title;
                    fbxSceneInfo.mSubject  = Subject;
                    fbxSceneInfo.mAuthor   = "Unity Technologies";
                    fbxSceneInfo.mRevision = "1.0";
                    fbxSceneInfo.mKeywords = Keywords;
                    fbxSceneInfo.mComment  = Comments;

                    fbxScene.SetSceneInfo(fbxSceneInfo);

                    // Export the scene to the file.
                    status = fbxExporter.Export(fbxScene);

                    // cleanup
                    fbxScene.Destroy();
                    fbxExporter.Destroy();

                    return(status == true ? NumNodes : 0);
                }
            }
コード例 #19
0
        public void EmptyExportImportTest()
        {
            int  N     = 10;
            long total = 0;

            for (int i = 0; i < N; i++)
            {
                m_stopwatch.Reset();
                m_stopwatch.Start();

                FbxIOSettings ioSettings = FbxIOSettings.Create(m_fbxManager, Globals.IOSROOT);
                m_fbxManager.SetIOSettings(ioSettings);

                FbxExporter exporter = FbxExporter.Create(m_fbxManager, "");

                string filename = "test.fbx";

                bool exportStatus = exporter.Initialize(filename, -1, m_fbxManager.GetIOSettings());

                // Check that export status is True
                Assert.IsTrue(exportStatus);

                // Create an empty scene to export
                FbxScene scene = FbxScene.Create(m_fbxManager, "myScene");

                // Export the scene to the file.
                exporter.Export(scene);

                exporter.Destroy();

                // Import to make sure file is valid

                FbxImporter importer = FbxImporter.Create(m_fbxManager, "");

                bool importStatus = importer.Initialize(filename, -1, m_fbxManager.GetIOSettings());

                Assert.IsTrue(importStatus);

                // Create a new scene so it can be populated
                FbxScene newScene = FbxScene.Create(m_fbxManager, "myScene2");

                importer.Import(newScene);

                importer.Destroy();

                m_stopwatch.Stop();

                total += m_stopwatch.ElapsedMilliseconds;

                // Delete the file once the test is complete
                File.Delete(filename);
            }

            CheckAgainstNative("EmptyExportImport", total / (float)N, N, 4);
        }
コード例 #20
0
ファイル: FbxManager.cs プロジェクト: koriandrei/ds2fbx
        public virtual FbxIOSettings GetIOSettings()
        {
            global::System.IntPtr cPtr = NativeMethods.FbxManager_GetIOSettings(swigCPtr);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #21
0
        public void TestInitializeInvalidIOSettings()
        {
            string filename = GetRandomFilename(m_testFolder);

            // Initialize the exporter. Pass it zombie IO settings.
            var ioSettings = FbxIOSettings.Create(Manager, "");

            ioSettings.Destroy();

            Assert.That(() => { m_exporter.Initialize(filename, -1, ioSettings); }, Throws.Exception.TypeOf <System.ArgumentNullException>());
        }
コード例 #22
0
        public new static FbxIOSettings Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxIOSettings_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxIOSettings         ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxIOSettings(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
コード例 #23
0
        public virtual void Init ()
        {
            foreach (string file in Directory.GetFiles (this.filePath, MakeFileName("*"))) {
                File.Delete (file);
            }

            // create fbx manager.
            m_fbxManager = FbxManager.Create ();

            // configure IO settings.
            m_fbxManager.SetIOSettings (FbxIOSettings.Create (m_fbxManager, Globals.IOSROOT));
        }
コード例 #24
0
 public FbxExportGlobals(string outputFile)
 {
     m_outputFile        = outputFile;
     m_sanitizedFileName = System.Text.RegularExpressions.Regex.Replace(
         Path.GetFileNameWithoutExtension(m_outputFile),
         @"[^a-zA-Z0-9_]", "_");
     m_outputDir  = Path.GetDirectoryName(outputFile);
     m_manager    = FbxManager.Create();
     m_ioSettings = FbxIOSettings.Create(m_manager, Globals.IOSROOT);
     m_manager.SetIOSettings(m_ioSettings);
     m_exporter = FbxExporter.Create(m_manager, "");
 }
コード例 #25
0
ファイル: MyExport.cs プロジェクト: tank90fc/fbx_wrapper
    void Init()
    {
        SdkManager = FbxManager.Create();
        FbxIOSettings ios = FbxIOSettings.Create(SdkManager, "IOSRoot");

        SdkManager.SetIOSettings(ios);
        //    EXP_FBX = "Material";
        //public string EXP_ADV_OPT_GRP = "Material";
        //public string IOSN_EXPORT = "Export";
        //public string IOSN_FBX = "Fbx";
        //public string IOSN_MATERIAL = "Material";
        //public string EXP_FBX_MATERIAL = EXP_FBX + " | " + IOSN_MATERIAL;
    }
コード例 #26
0
        public void TestIOSettings()
        {
            FbxIOSettings ioSettings = m_fbxManager.GetIOSettings();

            Assert.IsNull(ioSettings);

            using (FbxIOSettings ioSettings1 = FbxIOSettings.Create(m_fbxManager, "")) {
                m_fbxManager.SetIOSettings(ioSettings1);

                FbxIOSettings ioSettings2 = m_fbxManager.GetIOSettings();
                Assert.IsNotNull(ioSettings2);
            }
        }
コード例 #27
0
 public void Dispose()
 {
     if (m_exporter != null)
     {
         m_exporter.Destroy(); m_exporter = null;
     }
     if (m_ioSettings != null)
     {
         m_ioSettings.Destroy(); m_ioSettings = null;
     }
     if (m_manager != null)
     {
         m_manager.Destroy(); m_manager = null;
     }
 }
コード例 #28
0
        public (GameObject, List <string> warnings, ImportMaterialCollector) Import()
        {
            FbxManager    fbxManager = FbxManager.Create();
            FbxIOSettings ioSettings = FbxIOSettings.Create(fbxManager, Globals.IOSROOT);

            fbxManager.SetIOSettings(ioSettings);
            FbxImporter fbxImporter = FbxImporter.Create(fbxManager, "");

            if (!fbxImporter.Initialize(m_path, -1, ioSettings))
            {
                warnings.Add("Failed to initialize FBX importer");
                return(null, warnings, null);
            }
            FbxScene scene = FbxScene.Create(fbxManager, "scene");

            fbxImporter.Import(scene);

            FbxNode root = scene.GetRootNode();

            SetPivots(root);
            root.ConvertPivotAnimationRecursive(null, FbxNode.EPivotSet.eDestinationPivot, 30);
            long totalVerts     = GetTotalVerts(root);
            long completedVerts = 0;

            float fbxUnitToTiltUnit; {
                var unit = scene.GetGlobalSettings().GetSystemUnit();
                if (Path.GetExtension(m_path).ToLower() == ".obj")
                {
                    // Obj doesn't specify units. We'd rather assume m, but fbx assumes cm.
                    unit = FbxSystemUnit.m;
                }
                fbxUnitToTiltUnit = (float)unit.GetConversionFactorTo(FbxSystemUnit.m)
                                    * App.METERS_TO_UNITS;
            }

            GameObject go = ImportNodes(
                root, fbxUnitToTiltUnit, ref completedVerts, totalVerts);

            Debug.Assert(completedVerts == totalVerts);
            fbxImporter.Destroy();
            ioSettings.Destroy();
            fbxManager.Destroy();

            return(go, warnings.Distinct().ToList(), m_collector);
        }
コード例 #29
0
        private void FbxImportAndTestBlendshapes(string fbxPath)
        {
            // Create the FBX manager
            using (var fbxManager = FbxManager.Create())
            {
                FbxIOSettings fbxIOSettings = FbxIOSettings.Create(fbxManager, Globals.IOSROOT);

                // Configure the IO settings.
                fbxManager.SetIOSettings(fbxIOSettings);

                // Create the importer
                var fbxImporter = FbxImporter.Create(fbxManager, "Importer");

                // Initialize the importer.
                int fileFormat = -1;

                bool      status    = fbxImporter.Initialize(fbxPath, fileFormat, fbxIOSettings);
                FbxStatus fbxStatus = fbxImporter.GetStatus();

                Assert.That(status, Is.True, fbxStatus.GetErrorString());
                Assert.That(fbxImporter.IsFBX(), "file does not contain FBX data");

                // Import options. Determine what kind of data is to be imported.
                // The default is true, but here we set the options explictly.
                fbxIOSettings.SetBoolProp(Globals.IMP_FBX_MATERIAL, false);
                fbxIOSettings.SetBoolProp(Globals.IMP_FBX_TEXTURE, false);
                fbxIOSettings.SetBoolProp(Globals.IMP_FBX_ANIMATION, false);
                fbxIOSettings.SetBoolProp(Globals.IMP_FBX_EXTRACT_EMBEDDED_DATA, false);
                fbxIOSettings.SetBoolProp(Globals.IMP_FBX_GLOBAL_SETTINGS, true);

                // Create a scene
                var fbxScene = FbxScene.Create(fbxManager, "Scene");

                // Import the scene to the file.
                status    = fbxImporter.Import(fbxScene);
                fbxStatus = fbxImporter.GetStatus();
                Assert.That(status, Is.True, fbxStatus.GetErrorString());

                // Get blendshapes and check that the FbxShapes all have names
                var rootNode = fbxScene.GetRootNode();
                TestFbxShapeNamesNotEmpty(rootNode);
            }
        }
コード例 #30
0
        // Export scene sample
        protected void ExportScene(string fileName)
        {
            using (FbxManager fbxManager = FbxManager.Create())
            {
                // configure IO settings.
                fbxManager.SetIOSettings(FbxIOSettings.Create(fbxManager, Globals.IOSROOT));

                // Export the scene
                using (Autodesk.Fbx.FbxExporter exporter = Autodesk.Fbx.FbxExporter.Create(fbxManager, "myExporter"))
                {
                    // Initialize the exporter.
                    bool status = exporter.Initialize(fileName, -1, fbxManager.GetIOSettings());

                    // Create a new scene to export
                    FbxScene scene = FbxScene.Create(fbxManager, "myScene");

                    // Export the scene to the file.
                    exporter.Export(scene);
                }
            }
        }