Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/app/cycles_xml.cpp
| Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | if(attr) { | ||||
| } | } | ||||
| else | else | ||||
| fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name); | fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static bool xml_read_enum_value(int *value, ShaderEnum& enm, pugi::xml_node node, const char *name) | |||||
| { | |||||
| pugi::xml_attribute attr = node.attribute(name); | |||||
| if(attr) { | |||||
| ustring ustr(attr.value()); | |||||
| if(enm.exists(ustr)) { | |||||
| *value = enm[ustr]; | |||||
| return true; | |||||
| } | |||||
| else | |||||
| fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *name) | static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *name) | ||||
| { | { | ||||
| pugi::xml_attribute attr = node.attribute(name); | pugi::xml_attribute attr = node.attribute(name); | ||||
| if(attr) { | if(attr) { | ||||
| string value = attr.value(); | string value = attr.value(); | ||||
| if(string_iequals(value, "float")) | if(string_iequals(value, "float")) | ||||
| return SHADER_SOCKET_FLOAT; | return SHADER_SOCKET_FLOAT; | ||||
| ▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | else if(string_iequals(node.name(), "normal")) { | ||||
| snode = normal; | snode = normal; | ||||
| } | } | ||||
| else if(string_iequals(node.name(), "bump")) { | else if(string_iequals(node.name(), "bump")) { | ||||
| BumpNode *bump = new BumpNode(); | BumpNode *bump = new BumpNode(); | ||||
| xml_read_bool(&bump->invert, node, "invert"); | xml_read_bool(&bump->invert, node, "invert"); | ||||
| snode = bump; | snode = bump; | ||||
| } | } | ||||
| else if(string_iequals(node.name(), "mapping")) { | else if(string_iequals(node.name(), "mapping")) { | ||||
| snode = new MappingNode(); | MappingNode *map = new MappingNode(); | ||||
| TextureMapping *texmap = &map->tex_mapping; | |||||
| xml_read_enum_value((int*) &texmap->type, TextureMapping::type_enum, node, "type"); | |||||
| xml_read_enum_value((int*) &texmap->projection, TextureMapping::projection_enum, node, "projection"); | |||||
| xml_read_enum_value((int*) &texmap->x_mapping, TextureMapping::mapping_enum, node, "x_mapping"); | |||||
| xml_read_enum_value((int*) &texmap->y_mapping, TextureMapping::mapping_enum, node, "y_mapping"); | |||||
| xml_read_enum_value((int*) &texmap->z_mapping, TextureMapping::mapping_enum, node, "z_mapping"); | |||||
| xml_read_bool(&texmap->use_minmax, node, "use_minmax"); | |||||
| if(texmap->use_minmax) { | |||||
| xml_read_float3(&texmap->min, node, "min"); | |||||
| xml_read_float3(&texmap->max, node, "max"); | |||||
| } | |||||
| xml_read_float3(&texmap->translation, node, "translation"); | |||||
| xml_read_float3(&texmap->rotation, node, "rotation"); | |||||
| xml_read_float3(&texmap->scale, node, "scale"); | |||||
| snode = map; | |||||
| } | } | ||||
| else if(string_iequals(node.name(), "anisotropic_bsdf")) { | else if(string_iequals(node.name(), "anisotropic_bsdf")) { | ||||
| AnisotropicBsdfNode *aniso = new AnisotropicBsdfNode(); | AnisotropicBsdfNode *aniso = new AnisotropicBsdfNode(); | ||||
| xml_read_enum(&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution"); | xml_read_enum(&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution"); | ||||
| snode = aniso; | snode = aniso; | ||||
| } | } | ||||
| else if(string_iequals(node.name(), "diffuse_bsdf")) { | else if(string_iequals(node.name(), "diffuse_bsdf")) { | ||||
| snode = new DiffuseBsdfNode(); | snode = new DiffuseBsdfNode(); | ||||
| ▲ Show 20 Lines • Show All 752 Lines • Show Last 20 Lines | |||||