//--------------------------------------------------------------- void DocumentExporter::exportMaxScene() { mStreamWriter.startDocument(); createExporters(); exportAsset(); exportEffects(); exportMaterials(); exportGeometries(); exportControllers(); exportCameras(); exportLights(); exportImages(); exportVisualScenes(); if ( mOptions.getExportAnimations() ) exportAnimations(); exportScene(); deleteExporters(); mStreamWriter.endDocument(); const ExportSceneGraph::XRefSceneGraphList& sceneGraphList = mExportSceneGraph->getXRefSceneGraphList(); for ( ExportSceneGraph::XRefSceneGraphList::const_iterator it = sceneGraphList.begin(); it!=sceneGraphList.end(); ++it ) { NativeString outputFileName(NativeString(getXRefOutputPath(*it))); DocumentExporter document(mMaxInterface, it->exportSceneGraph, outputFileName, mOptions, mExportOnlySelected); document.exportMaxScene(); } }
//--------------------------------------------------------------- void DocumentExporter::exportCurrentScene ( bool selectionOnly ) { mIsImport = false; // Create the import/export library helpers. createLibraries(); mStreamWriter.startDocument(); // Build the scene graph if ( mSceneGraph->create ( selectionOnly ) ) { // Export the asset of the document. exportAsset(); if ( !ExportOptions::exportMaterialsOnly () ) { // Start by caching the expressions that will be sampled mSceneGraph->sampleAnimationExpressions(); if (!ExportOptions::exportAnimations() || ExportOptions::exportPolygonMeshes()) { // Export the lights. mLightExporter->exportLights(); // Export the cameras. mCameraExporter->exportCameras(); // Export the material URLs and get the material list MaterialMap* materialMap = mMaterialExporter->exportMaterials(); // Export the effects (materials) const ImageMap* imageMap = mEffectExporter->exportEffects(materialMap); // Export the images mImageExporter->exportImages(imageMap); } // Export the controllers. Must be done before the geometries, to decide, which // geometries have to be exported (for example, if the controller need an invisible // geometry, we also have to export it). mControllerExporter->exportControllers(); // Don't export Physics if required PhysX plugin is not loaded if (ExportOptions::exportPhysics() && !PhysXExporter::CheckPhysXPluginVersion()) { MGlobal::displayError(MString("Physics not exported. Minimum PhysX plugin version: ") + PhysXExporter::GetRequiredPhysXPluginVersion()); MGlobal::displayError(MString("Installed version: ") + PhysXExporter::GetInstalledPhysXPluginVersion()); ExportOptions::setExportPhysics(false); } // Export PhysX to XML before exporting geometries if (ExportOptions::exportPhysics() && !mPhysXExporter->generatePhysXXML()) { // Don't try to export Physics if xml export has failed ExportOptions::setExportPhysics(false); MGlobal::displayError(MString("Error while exporting PhysX scene to XML. Physics not exported.")); } // Export the geometries mGeometryExporter->exportGeometries(); // Export the LOD mLODExporter->exportLODs(mVisualSceneExporter); bool physicsSceneExported = false; if (ExportOptions::exportPhysics()) { // Export PhysX physicsSceneExported = mPhysXExporter->exportPhysicsLibraries(); } saveParamClip(); // Export the visual scene bool visualSceneExported = mVisualSceneExporter->exportVisualScenes(); // Export the animations if (ExportOptions::exportAnimations()) { const AnimationClipList* animationClips = mAnimationExporter->exportAnimations(); // Export the animation clips mAnimationClipExporter->exportAnimationClips(animationClips); } restoreParamClip(); // Export the scene exportScene(visualSceneExported, physicsSceneExported); // Export the light probes. mLightProbeExporter->exportLightProbes(); } else { // Export the material URLs and get the material list MaterialMap* materialMap = mMaterialExporter->exportMaterials(); // Export the effects (materials) const ImageMap* imageMap = mEffectExporter->exportEffects ( materialMap ); // Export the images mImageExporter->exportImages ( imageMap ); } } mStreamWriter.endDocument(); }