MCPcopy Create free account
hub / github.com/RenderKit/embree / loadMaterial

Method loadMaterial

tutorials/common/scenegraph/xml_loader.cpp:891–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

889 }
890
891 Ref<SceneGraph::MaterialNode> XMLLoader::loadMaterial(const Ref<XML>& xml)
892 {
893 const std::string id = xml->parm("id");
894 if (id != "" && state.materialMap.find(id) != state.materialMap.end())
895 return state.materialMap[id];
896
897 if (!xml->hasChild("parameters")) {
898 std::cout << "Warning: material " << id << " is not defined" << std::endl;
899 return new MatteMaterial(Vec3fa(0.5f,0.0f,0.0f));
900 }
901 Ref<XML> parameters = xml->child("parameters");
902 if (state.materialCache.find(parameters) != state.materialCache.end()) {
903 return state.materialMap[id] = state.materialCache[parameters];
904 }
905
906 std::string type = load<std::string>(xml->child("code")).c_str();
907 Parms parms = loadMaterialParms(parameters);
908 Ref<SceneGraph::MaterialNode> material = addMaterial(type,parms);
909 state.materialCache[parameters] = material;
910 return state.materialMap[id] = material;
911 }
912
913 Ref<SceneGraph::MaterialNode> XMLLoader::addMaterial(const std::string& type, const Parms& parms)
914 {

Callers

nothing calls this directly

Calls 7

parmMethod · 0.80
hasChildMethod · 0.80
Vec3faClass · 0.50
findMethod · 0.45
endMethod · 0.45
childMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected