WeakMeshNodeResourceData MeshNodeResourceData::GetNodeByName(const std::string& childName) const { WeakMeshNodeResourceData child; unsigned int childIndex; for (childIndex = 0; childIndex < this->m_children.size(); ++childIndex) { auto currentChild = this->m_children[childIndex]; if (currentChild->GetName() == childName) child = std::dynamic_pointer_cast<MeshNodeResourceData>(currentChild); } if (child.expired()) { for (childIndex = 0; childIndex < this->m_children.size(); ++childIndex) { auto currentChild = this->m_children[childIndex]; child = currentChild->GetNodeByName(childName); } } return child; }
Node* Root::CreateNode(const std::string& name) { assert(GetNodeByName(name) == NULL); // A node with that name already exists. Node* n = new Node(name); n->SetParentNode(&mRootNode); mNodes.push_back(n); return &(mNodes.back()); }
bool MaterialGraph::LoadNode(const YamlNode * graphNode) { MaterialGraphNode * node = new MaterialGraphNode(this); node->InitFromYamlNode(graphNode); AddNode(node); usedTextureCoordsCount = Max(usedTextureCoordsCount, node->GetTextureInputIndex() + 1); if (node->GetType() == MaterialGraphNode::TYPE_SAMPLE_2D) usedTextures++; //YamlNode * const YamlNode * nameNode = graphNode->Get("name"); const YamlNode * typeNode = graphNode->Get("node"); Logger::Debug("- Read Node %s %s", typeNode->AsString().c_str(), nameNode->AsString().c_str()); // Parse inputs const MultiMap<String, YamlNode*> & map = graphNode->AsMap(); std::pair<MultiMap<String, YamlNode*>::const_iterator, MultiMap<String, YamlNode*>::const_iterator> inputs = map.equal_range("input"); uint32 count = 0; for (MultiMap<String, YamlNode*>::const_iterator it = inputs.first; it != inputs.second; ++it) { const YamlNode * inputNode = it->second; const String & inputName = inputNode->Get(0)->AsString(); const String & nodeName = inputNode->Get(1)->AsString(); const String & connectionModifier = inputNode->Get(2)->AsString(); MaterialGraphNode * connectNode = GetNodeByName(nodeName); if (connectNode) { Logger::Debug("- Read Input: %s connected:%s filter:%s", inputNode->Get(0)->AsString().c_str(), inputNode->Get(1)->AsString().c_str(), inputNode->Get(2)->AsString().c_str()); node->ConnectToNode(inputName, connectNode, connectionModifier); count++; } } SafeRelease(node); return true; }