//---------------------------------------------------------------
	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));

	}
	//---------------------------------------------------------------
	void ControllerExporter::exportControllers( ExportNode* exportNode )
	{
		ControllerList* controllerList = exportNode->getControllerList();

		if ( !controllerList->hasControllers() )
			return;

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

			ObjectIdentifier poseAfter(controller->getDerivedObject(), (int)i);

			if ( mDocumentExporter->isExportedObject(poseAfter) )
			{
				if ( controller->getType() == Controller::SKIN )
					determineReferencedJoints(exportNode, (SkinController*)controller);
				continue;
			}

			String controllerId = getControllerId(*exportNode, controllerCount - i, controller->getType());
			String controllerSource;
			if ( i <  controllerCount - 1)
			{
				ExportNode* previousControllerExportNode = mDocumentExporter->getExportedObjectExportNode(ObjectIdentifier(controllerList->getController(i+1)->getDerivedObject(), (int)i+1));
				assert( previousControllerExportNode );
				controllerSource = '#' +  getControllerId(*previousControllerExportNode, controllerCount - i - 1, controllerList->getController(i+1)->getType());
			}
			else
			{
				ExportNode* geometryExportNode = mDocumentExporter->getExportedObjectExportNode(ObjectIdentifier(exportNode->getInitialPose()));
				assert( geometryExportNode );
				controllerSource = '#' + GeometriesExporter::getGeometryId(*geometryExportNode);
			}
			exportController(exportNode, controller, controllerId, controllerSource);
			mDocumentExporter->insertExportedObject(poseAfter, exportNode);
		}
	}