Exemplo n.º 1
0
        public aiExportFormatDesc GetExportFormatDescription(uint pIndex)
        {
            global::System.IntPtr cPtr = assimp_swigPINVOKE.Exporter_GetExportFormatDescription(swigCPtr, pIndex);
            aiExportFormatDesc    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new aiExportFormatDesc(cPtr, false);

            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Provide the list of file extensions supported by this exporter module.
        /// </summary>
        /// <returns>The list of supported extensions.</returns>
        public string[] GetSupportedExtensions()
        {
            if (extensions == null)
            {
                uint export_format_count = Exporter.GetExportFormatCount();

                extensions = new string[export_format_count];

                for (uint i = 0; i < export_format_count; i++)
                {
                    using (aiExportFormatDesc desc = Exporter.GetExportFormatDescription(i))
                    {
                        extensions[i] = desc.fileExtension.ToLower();
                    }
                }
            }

            return(extensions);
        }
Exemplo n.º 3
0
        public IEnumerator ToAssimp(Module.Export.Assimp.Context context, string filename, aiPostProcessSteps steps, Module.ExporterSuccessCallback return_callback, Module.ProgressCallback progress_callback)
        {
            bool success = false;

            string extension = System.IO.Path.GetExtension(filename).Remove(0, 1).ToLower();

            uint export_format_count = context.exporter.GetExportFormatCount();

            bool found_exporter = false;

            for (uint i = 0; i < export_format_count; i++)
            {
                using (aiExportFormatDesc desc = context.exporter.GetExportFormatDescription(i))
                {
                    if (extension == desc.fileExtension.ToLower())
                    {
                        using (aiScene scene = new aiScene())
                        {
                            InitProgress(context, progress_callback, this);

                            context.scene = scene;

                            // Export nodes
                            IResult nodes_result = context.threads.AddTask(() =>
                            {
                                using (aiNode root = root_node.ToAssimp(context, this, null))
                                {
                                    scene.mRootNode = root.Unmanaged();
                                }
                            });

                            // Export materials.
                            context.threads.AddTask(() => Material.ToAssimp(context, this));

                            // We must wait for all the nodes to be processed before exporting meshes because indexes are computed during parsing.
                            while (!nodes_result.Done)
                            {
                                context.progress.Display();

                                yield return(null);
                            }

                            // Export meshes
                            context.threads.AddTask(() => Mesh.ToAssimp(context, this));

                            // Wait for all tasks to be completed
                            IEnumerator it = context.threads.WaitForTasksCompletion();
                            while (it.MoveNext())
                            {
                                context.progress.Display();

                                yield return(it.Current);
                            }

                            // Do the final export using Assimp now that we created the complete structure in the C++ DLL.
                            Result <aiReturn> status = context.threads.AddTask(() => context.exporter.Export(scene, desc.id, filename, steps));

                            // Wait for export to complete
                            while (!status.Done)
                            {
                                context.progress.Display();

                                yield return(null);
                            }

                            if (progress_callback != null)
                            {
                                progress_callback(1f);
                            }

                            context.Clean();

                            // Check export status
                            if (status.Success && status.Value == aiReturn.aiReturn_SUCCESS)
                            {
                                success = true;
                            }
                            else
                            {
                                Debug.LogErrorFormat("Failed to export to: {0}. \nThe exporter reported the following error: {1}", filename, context.exporter.GetErrorString());
                            }
                        }

                        found_exporter = true;

                        break;
                    }
                }
            }

            if (!found_exporter)
            {
                Debug.LogErrorFormat("No exporter for format '{0}' was found in Assimp.", extension);
            }

            if (return_callback != null)
            {
                return_callback(success);
            }
        }
Exemplo n.º 4
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(aiExportFormatDesc obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemplo n.º 5
0
 public static void aiReleaseExportFormatDescription(aiExportFormatDesc desc)
 {
     assimp_swigPINVOKE.aiReleaseExportFormatDescription(aiExportFormatDesc.getCPtr(desc));
 }