//---------------------------------------------------------------
	void ExportSceneGraph::findReferencedObjects( ExportNode* exportNode )
	{
		if ( exportNode->hasControllers() )
		{
			ControllerList* controllerList = exportNode->getControllerList();

			size_t controllerCount = controllerList->getControllerCount();

			for ( size_t j = 0; j < controllerCount; ++j)
			{
				Controller* controller = controllerList->getController(j);

				if ( controller->getType() != Controller::MORPH )
					continue;

				MorphController* morphController = (MorphController*)controller;

				MorphR3* morpher = morphController->getMorph();

				size_t channelBankCount = morpher->chanBank.size();
				for ( size_t i = 0; i<channelBankCount; ++i)
				{
					morphChannel& channel = morpher->chanBank[i];

					if (!channel.mActive || channel.mNumPoints == 0) 
						continue;

					INode* targetINode = channel.mConnection;

					if ( !targetINode )
					{
						MorphControllerHelperGeometry morphControllerHelperGeometry;
						morphControllerHelperGeometry.exportNode = exportNode;
						morphControllerHelperGeometry.morphController = morphController;
						morphControllerHelperGeometry.controllerId = ControllerExporter::getControllerId(*exportNode, controllerCount - j, controllerList->getController(j)->getType());
						morphControllerHelperGeometry.channelBankindex = i;
						mMorphControllerHelperGeometryList.push_back(morphControllerHelperGeometry);
					}
					else
					{
						ExportNode* targetExportNode = getExportNode(targetINode);
						targetExportNode->setIsReferenced(true);
					}
				}

			}
		}

		size_t numberOfChildren = exportNode->getNumberOfChildren();

		for ( size_t i = 0; i < numberOfChildren; ++i )
			findReferencedObjects(exportNode->getChild(i));

	}
    //---------------------------------------------------------------
    bool ExportSceneGraph::create ( bool exportSelection )
    {
        mExportSelection = exportSelection;

        if ( mRootExportNode )
            delete mRootExportNode;

		bool isNotEmpty;
		mRootExportNode = create ( mRootNode, 0, isNotEmpty );

		findReferencedObjects(mRootExportNode);

		int xRefFileCount = mRootNode->GetXRefFileCount();

		for ( int i = 0; i < xRefFileCount; ++i)
		{
			XRefSceneGraph xRefScene;
#ifdef MAX_2010_OR_NEWER
 #ifdef UNICODE
			const char* XRefFileName = COLLADABU::StringUtils::toUTF8String(mRootNode->GetXRefFile(i).GetFileName().data()).c_str();
 #else
			const char* XRefFileName = mRootNode->GetXRefFile(i).GetFileName().data();
 #endif
#else
			const char* XRefFileName = mRootNode->GetXRefFileName(i).data();
#endif
			COLLADASW::URI uri(COLLADASW::URI::nativePathToUri(NativeString(XRefFileName)));
			xRefScene.exportFileBaseName = mXRefExportFileNames.addId(uri.getPathFileBase(), false);
			xRefScene.exportSceneGraph = new ExportSceneGraph(mRootNode->GetXRefTree(i), uri, mXRefExportFileNames);
			if ( xRefScene.exportSceneGraph->create(exportSelection) )
			{
				mXRefSceneGraphList.push_back(xRefScene);
				isNotEmpty = true;
			}
			else
			{
				delete xRefScene.exportSceneGraph;
			}
		}

        return isNotEmpty;
    }