//--------------------------------------------------------------- void LightExporter::doExport( ExportNode* exportNode ) { if ( exportNode->getType() == ExportNode::LIGHT ) exportLight(exportNode); size_t numberOfChildren = exportNode->getNumberOfChildren(); for ( size_t i = 0; i < numberOfChildren; ++i ) doExport( exportNode->getChild ( i ) ); }
//--------------------------------------------------------------- void LightExporter::exportLights ( SceneElement* sceneElement ) { // If we have a external reference, we don't need to export the data here. if ( !sceneElement->getIsLocal() ) return; if ( !sceneElement->getIsExportNode () ) return; // Check if it is a light. SceneElement::Type sceneElementType = sceneElement->getType(); if ( sceneElementType == SceneElement::LIGHT ) { // Get the current dag path MDagPath dagPath = sceneElement->getPath(); // Check if the current scene element isn't already exported. SceneGraph* sceneGraph = mDocumentExporter->getSceneGraph(); if ( sceneGraph->findExportedElement ( dagPath ) ) return; // Check if the current element is an instance. // We don't need to export instances, because we export the original instanced element. bool isInstance = ( dagPath.isInstanced() && dagPath.instanceNumber() > 0 ); // If the original instanced element isn't already exported, we have to export it now. if ( isInstance ) { // Get the original instanced element. MDagPath instancedPath; dagPath.getPath ( instancedPath, 0 ); // Check if the original instanced element is already exported. SceneGraph* sceneGraph = mDocumentExporter->getSceneGraph(); SceneElement* exportedElement = sceneGraph->findExportedElement ( instancedPath ); if (exportedElement == 0) { // Export the original instanced element and push it in the exported scene graph. if (exportLight(instancedPath)) { SceneElement* instancedSceneElement = sceneGraph->findElement(instancedPath); SceneGraph* sceneGraph = mDocumentExporter->getSceneGraph(); sceneGraph->addExportedElement(instancedSceneElement); } } } else { // Export the element and push it in the exported scene graph. if ( exportLight ( dagPath ) ) { SceneGraph* sceneGraph = mDocumentExporter->getSceneGraph(); sceneGraph->addExportedElement( sceneElement ); } } } // Recursive call for all the child elements for ( uint i=0; i<sceneElement->getChildCount(); ++i ) { SceneElement* childElement = sceneElement->getChild ( i ); exportLights ( childElement ); } }