//--------------------------------------------------------------- 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); } }
void CBaseManager::Validate(BuildingGUID nGUID) { ControllerList ValidateList; ControllerList::iterator itBuilding = m_ControllerList.begin(); if (GUID_INVALID != nGUID) { // Find it itBuilding = m_ControllerList.find(nGUID); // Check if it is ready to be validated if (true == itBuilding->second->BeforeValidate()) ValidateList[itBuilding->first] = itBuilding->second; } else { // Check all of them for (itBuilding; itBuilding != m_ControllerList.end(); itBuilding++) { if (true == itBuilding->second->BeforeValidate()) ValidateList.insert(ControllerList::value_type(itBuilding->first,itBuilding->second)); } } if (true == ValidateList.empty()) return; // Must have something to continue with // Look for new interfaces and tell them they now represent me IEntity *pEntity = NULL; IEntitySystem *pES = gEnv->pEntitySystem; IEntityItPtr pIt = pES->GetEntityIterator(); while (false == pIt->IsEnd()) { if (NULL != (pEntity = pIt->Next())) { // Check if it has a CNCBuilding property table and that it is // interfacing this particular one IScriptTable *pTable; if (NULL != pEntity && NULL != (pTable = pEntity->GetScriptTable())) { // Get property table SmartScriptTable props, cncbuilding; if (true == pTable->GetValue("Properties", props) && true == props->GetValue("CNCBuilding", cncbuilding)) { // Extract and build GUID char const* szTeam = 0; char const* szClass = 0; cncbuilding->GetValue("Team", szTeam); cncbuilding->GetValue("Class", szClass); BuildingGUID GUID = g_D6Core->pBaseManager->GenerateGUID(szTeam, szClass); itBuilding = ValidateList.find(GUID); if (itBuilding != ValidateList.end()) itBuilding->second->AddInterface(pEntity); } } } } // And finally, validate them all for (itBuilding = ValidateList.begin(); itBuilding != ValidateList.end(); itBuilding++) { itBuilding->second->Validate(); } }