void setParameter( AtNode *node, const AtParamEntry *parameter, const IECore::Data *value ) { bool isArray = false; int type = AiParamGetType( parameter ); if( type == AI_TYPE_ARRAY ) { type = AiParamGetDefault( parameter )->ARRAY->type; isArray = true; } setParameterInternal( node, AiParamGetName( parameter ), type, isArray, value ); }
void ApplyOverrides(std::string name, AtNode* node, std::vector<std::string> tags, ProcArgs & args) { bool foundInPath = false; for(std::vector<std::string>::iterator it=args.overrides.begin(); it!=args.overrides.end(); ++it) { Json::Value overrides; if(it->find("/") != std::string::npos) // Based on path { if(name.find(*it) != std::string::npos) { overrides = args.overrideRoot[*it]; foundInPath = true; } } else if(matchPattern(name,*it)) // based on wildcard expression { overrides = args.overrideRoot[*it]; foundInPath = true; } else if(foundInPath == false) { if (std::find(tags.begin(), tags.end(), *it) != tags.end()) { overrides = args.overrideRoot[*it]; } } if(overrides.size() > 0) { for( Json::ValueIterator itr = overrides.begin() ; itr != overrides.end() ; itr++ ) { std::string attribute = itr.key().asString(); const AtNodeEntry* nodeEntry = AiNodeGetNodeEntry(node); const AtParamEntry* paramEntry = AiNodeEntryLookUpParameter(nodeEntry, attribute.c_str()); if ( paramEntry != NULL && attribute!="invert_normals" || attribute == "matte") { Json::Value val = args.overrideRoot[*it][itr.key().asString()]; if( val.isString() ) AiNodeSetStr(node, attribute.c_str(), val.asCString()); else if( val.isBool() ) { if(attribute == "matte") { AiMsgDebug("[ABC] adding enable_matte to %s", AiNodeGetName(node)); AddUserGeomParams(node,"enable_matte",AI_TYPE_BOOLEAN); AiNodeSetBool(node,"enable_matte", val.asBool()); } else { AiNodeSetBool(node, attribute.c_str(), val.asBool()); } } else if( val.isInt() ) { //make the difference between Byte & int! int typeEntry = AiParamGetType(paramEntry); if(typeEntry == AI_TYPE_BYTE) { if(attribute=="visibility") { AtByte attrViz = val.asInt(); // special case, we must determine it against the general viz. AtByte procViz = AiNodeGetByte( args.proceduralNode, "visibility" ); AtByte compViz = AI_RAY_ALL; { compViz &= ~AI_RAY_GLOSSY; if(procViz > compViz) procViz &= ~AI_RAY_GLOSSY; else attrViz &= ~AI_RAY_GLOSSY; compViz &= ~AI_RAY_DIFFUSE; if(procViz > compViz) procViz &= ~AI_RAY_DIFFUSE; else attrViz &= ~AI_RAY_DIFFUSE; compViz &= ~AI_RAY_REFRACTED; if(procViz > compViz) procViz &= ~AI_RAY_REFRACTED; else attrViz &= ~AI_RAY_REFRACTED; compViz &= ~AI_RAY_REFLECTED; if(procViz > compViz) procViz &= ~AI_RAY_REFLECTED; else attrViz &= ~AI_RAY_REFLECTED; compViz &= ~AI_RAY_SHADOW; if(procViz > compViz) procViz &= ~AI_RAY_SHADOW; else attrViz &= ~AI_RAY_SHADOW; compViz &= ~AI_RAY_CAMERA; if(procViz > compViz) procViz &= ~AI_RAY_CAMERA; else attrViz &= ~AI_RAY_CAMERA; } AiNodeSetByte(node, attribute.c_str(), attrViz); } else AiNodeSetByte(node, attribute.c_str(), val.asInt()); } else AiNodeSetInt(node, attribute.c_str(), val.asInt()); } else if( val.isUInt() ) AiNodeSetUInt(node, attribute.c_str(), val.asUInt()); else if( val.isDouble() ) AiNodeSetFlt(node, attribute.c_str(), val.asDouble()); } } } } }
IECore::DataPtr getParameter( AtNode *node, const AtParamEntry *parameter ) { return getParameterInternal( node, AiParamGetName( parameter ), AiParamGetType( parameter ) ); }