Beispiel #1
0
        /// <summary>
        /// Exports a scene to the specified format and writes it to a data blob.
        /// </summary>
        /// <param name="scene">Scene containing the model to export.</param>
        /// <param name="exportFormatId">FormatID representing the format to export to.</param>
        /// <param name="preProcessing">Preprocessing flags to apply to the model before it is exported.</param>
        /// <returns>The resulting data blob, or null if the export failed.</returns>
        /// <exception cref="ArgumentNullException">Thrown if the scene is null.</exception>
        /// <exception cref="System.ObjectDisposedException">Thrown if the context has already been disposed of.</exception>
        public ExportDataBlob ExportToBlob(Scene scene, String exportFormatId, PostProcessSteps preProcessing)
        {
            CheckDisposed();

            IntPtr fileIO   = IntPtr.Zero;
            IntPtr scenePtr = IntPtr.Zero;

            if (scene == null)
            {
                throw new ArgumentNullException("scene", "Scene must exist.");
            }

            try
            {
                scenePtr = Scene.ToUnmanagedScene(scene);

                return(AssimpLibrary.Instance.ExportSceneToBlob(scenePtr, exportFormatId, preProcessing));
            }
            finally
            {
                if (scenePtr != IntPtr.Zero)
                {
                    Scene.FreeUnmanagedScene(scenePtr);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Exports a scene to the specified format and writes it to a file.
        /// </summary>
        /// <param name="scene">Scene containing the model to export.</param>
        /// <param name="fileName">Path to the file.</param>
        /// <param name="exportFormatId">FormatID representing the format to export to.</param>
        /// <param name="preProcessing">Preprocessing flags to apply to the model before it is exported.</param>
        /// <returns>True if the scene was exported successfully, false otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown if the scene is null.</exception>
        /// <exception cref="System.ObjectDisposedException">Thrown if the context has already been disposed of.</exception>
        public bool ExportFile(Scene scene, String fileName, String exportFormatId, PostProcessSteps preProcessing)
        {
            CheckDisposed();

            IntPtr fileIO   = IntPtr.Zero;
            IntPtr scenePtr = IntPtr.Zero;

            if (scene == null)
            {
                throw new ArgumentNullException("scene", "Scene must exist.");
            }

            try
            {
                scenePtr = Scene.ToUnmanagedScene(scene);

                ReturnCode status = AssimpLibrary.Instance.ExportScene(scenePtr, exportFormatId, fileName, fileIO, preProcessing);

                return(status == ReturnCode.Success);
            }
            finally
            {
                if (scenePtr != IntPtr.Zero)
                {
                    Scene.FreeUnmanagedScene(scenePtr);
                }
            }
        }