int selectTransformNodes(SceneNodePtr root) { ESS_PROFILE_FUNC(); std::list<SelectChildrenStackElement> sceneStack; sceneStack.push_back(SelectChildrenStackElement(root, false)); int nSelectionCount = 0; while( !sceneStack.empty() ) { SelectChildrenStackElement sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); if(eNode->type == SceneNode::NAMESPACE_TRANSFORM || eNode->type == SceneNode::ETRANSFORM || eNode->type == SceneNode::ITRANSFORM){ eNode->selected = true; nSelectionCount++; } for( std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); it++){ sceneStack.push_back(SelectChildrenStackElement(*it, false)); } } root->selected = true; return nSelectionCount; }
int renameConflictingNodes(SceneNodePtr root, bool bValidate) { ESS_PROFILE_FUNC(); clearIdentifierMap(); std::list<SelectChildrenStackElement> sceneStack; sceneStack.push_back(SelectChildrenStackElement(root, false)); int nRenameCount = 0; while (!sceneStack.empty()) { SelectChildrenStackElement sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); if (eNode->type == SceneNode::ETRANSFORM || eNode->type == SceneNode::ITRANSFORM) { std::string parent; if (eNode->parent) { parent = eNode->parent->dccIdentifier; } bool bRenamed = false; eNode->name = getUniqueName(parent, eNode->name, bValidate, bRenamed); if (bRenamed) { nRenameCount++; } } for (std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); it++) { sceneStack.push_back(SelectChildrenStackElement(*it, false)); } } clearIdentifierMap(); return nRenameCount; }
int selectPolyMeshShapeNodes(SceneNodePtr root) { ESS_PROFILE_FUNC(); std::list<SelectChildrenStackElement> sceneStack; sceneStack.push_back(SelectChildrenStackElement(root, false)); int nSelectionCount = 0; while( !sceneStack.empty() ) { SelectChildrenStackElement sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); if(eNode->type == SceneNode::POLYMESH){ eNode->selected = true; nSelectionCount++; SceneNode* currNode = eNode->parent; while(currNode){ if(!currNode->selected) nSelectionCount++; currNode->selected = true; currNode = currNode->parent; } } for( std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); it++){ sceneStack.push_back(SelectChildrenStackElement(*it, false)); } } root->selected = true; return nSelectionCount; }
int refineSelection(SceneNodePtr root, bool bSelectParents, bool bChildren, bool bSelectShapeNodes) { ESS_PROFILE_FUNC(); std::list<SelectChildrenStackElement> sceneStack; sceneStack.push_back(SelectChildrenStackElement(root, false)); int nSelectionCount = 0; while( !sceneStack.empty() ) { SelectChildrenStackElement sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); bool bSelected = false; //check if the node matches a full path if(eNode->type == SceneNode::ETRANSFORM || eNode->type == SceneNode::ITRANSFORM || eNode->type == SceneNode::NAMESPACE_TRANSFORM) { if(eNode->dccSelected){ //this node's name matches one of the names from the selection map, so select it if(!eNode->selected) nSelectionCount++; eNode->selected = true; if(eNode->type == SceneNode::ETRANSFORM && bSelectShapeNodes) { //Select the shape nodes first for(std::list<SceneNodePtr>::iterator it=eNode->children.begin(); it != eNode->children.end(); it++) { if(::isShapeNode((*it)->type)){ if(!(*it)->selected) nSelectionCount++; (*it)->selected = true; break; } } } //then select the parents if(bSelectParents){// select all parent nodes SceneNode* currNode = eNode->parent; while(currNode){ if(!currNode->selected) nSelectionCount++; currNode->selected = true; currNode = currNode->parent; } } if(bChildren){// select the children bSelected = true; } } } if(sElement.bSelectChildren){ bSelected = true; if(!eNode->selected) nSelectionCount++; eNode->selected = true; } for( std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); it++){ sceneStack.push_back(SelectChildrenStackElement(*it, bSelected)); } } root->selected = true; return nSelectionCount; }
int selectNodes(SceneNodePtr root, SceneNode::SelectionT& selectionMap, bool bSelectParents, bool bChildren, bool bSelectShapeNodes, bool isMaya) { ESS_PROFILE_FUNC(); SceneNode::SelectionT::iterator selectionEnd = selectionMap.end(); std::list<SelectChildrenStackElement> sceneStack; sceneStack.push_back(SelectChildrenStackElement(root, false)); int nSelectionCount = 0; while( !sceneStack.empty() ) { SelectChildrenStackElement sElement = sceneStack.back(); SceneNodePtr eNode = sElement.eNode; sceneStack.pop_back(); bool bSelected = false; //check if the node matches a full path if(eNode->type == SceneNode::ETRANSFORM || eNode->type == SceneNode::ITRANSFORM || eNode->type == SceneNode::NAMESPACE_TRANSFORM || eNode->type == SceneNode::HAIR)// removed to be able to export hair properly in Maya! { SceneNode::SelectionT::iterator selectionIt = selectionMap.find(eNode->dccIdentifier); if(selectionIt != selectionEnd){ //to keep track which ones resolved selectionMap[eNode->dccIdentifier] = true; } //otherwise, check if the node names match if(selectionIt == selectionEnd){ std::string nodeName = removeXfoSuffix(eNode->name); selectionIt = selectionMap.find(nodeName); if(selectionIt != selectionEnd){ //to keep track which ones resolved selectionMap[nodeName] = true; } } if(selectionIt != selectionEnd){ //this node's name matches one of the names from the selection map, so select it if(!eNode->selected) nSelectionCount++; eNode->selected = true; if(eNode->type == SceneNode::ETRANSFORM && bSelectShapeNodes) { //Select the shape nodes first if (isMaya) { for(std::list<SceneNodePtr>::reverse_iterator it=eNode->children.rbegin(); it != eNode->children.rend(); ++it) { if(::isShapeNode((*it)->type))//MergedPolyMesh node should work here... { if(!(*it)->selected) nSelectionCount++; (*it)->selected = true; break; } } } else { for(std::list<SceneNodePtr>::iterator it=eNode->children.begin(); it != eNode->children.end(); it++) { if(::isShapeNode((*it)->type)){ if(!(*it)->selected) nSelectionCount++; (*it)->selected = true; break; } } } } //then select the parents if(bSelectParents){// select all parent nodes SceneNode* currNode = eNode->parent; while(currNode){ if(!currNode->selected) nSelectionCount++; currNode->selected = true; currNode = currNode->parent; } } if(bChildren){// select the children bSelected = true; } } // if(selectionIt != } // if(eNode->type == if(sElement.bSelectChildren){ bSelected = true; if(!eNode->selected) nSelectionCount++; eNode->selected = true; } for( std::list<SceneNodePtr>::iterator it = eNode->children.begin(); it != eNode->children.end(); it++){ sceneStack.push_back(SelectChildrenStackElement(*it, bSelected)); } } root->selected = true; return nSelectionCount; }