def testPrimitiveVariables( self ) : s = IECore.SpherePrimitive() s["v"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, IECore.V3f( 1, 2, 3 ) ) s["c"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, IECore.Color3f( 1, 2, 3 ) ) s["s"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, "test" ) s["i"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, 11 ) s["b"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, True ) s["f"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, 2.5 ) s["m"] = IECore.PrimitiveVariable( IECore.PrimitiveVariable.Interpolation.Constant, IECore.M44f( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) ) with IECoreArnold.UniverseBlock( writable = True ) : n = IECoreArnold.NodeAlgo.convert( s, "testSphere" ) self.assertEqual( arnold.AiNodeGetVec( n, "v" ), arnold.AtVector( 1, 2, 3 ) ) self.assertEqual( arnold.AiNodeGetRGB( n, "c" ), arnold.AtRGB( 1, 2, 3 ) ) self.assertEqual( arnold.AiNodeGetStr( n, "s" ), "test" ) self.assertEqual( arnold.AiNodeGetInt( n, "i" ), 11 ) self.assertEqual( arnold.AiNodeGetBool( n, "b" ), True ) self.assertEqual( arnold.AiNodeGetFlt( n, "f" ), 2.5 ) m = arnold.AiNodeGetMatrix( n, "m" ) self.assertEqual( [ list( i ) for i in m.data ], [ [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16] ], )
def testBlindData(self): flat = IECoreScene.Shader("flat") flat.blindData().update({ "user:testInt": IECore.IntData(1), "user:testFloat": IECore.FloatData(2.5), "user:testV3f": IECore.V3fData(imath.V3f(1, 2, 3)), "user:testColor3f": IECore.Color3fData(imath.Color3f(4, 5, 6)), "user:testString": IECore.StringData("we're all doomed"), }) network = IECoreScene.ShaderNetwork(shaders={ "noiseHandle": IECoreScene.Shader("noise"), "flatHandle": flat, }, connections=[ (("noiseHandle", ""), ("flatHandle", "color")), ], output="flatHandle") with IECoreArnold.UniverseBlock(writable=True) as universe: nodes = IECoreArnoldPreview.ShaderNetworkAlgo.convert( network, universe, "test") self.assertEqual(len(nodes), 2) self.assertEqual( arnold.AiNodeEntryGetName(arnold.AiNodeGetNodeEntry(nodes[0])), "noise") self.assertEqual( arnold.AiNodeEntryGetName(arnold.AiNodeGetNodeEntry(nodes[1])), "flat") self.assertEqual(arnold.AiNodeGetName(nodes[0]), "test:noiseHandle") self.assertEqual(arnold.AiNodeGetName(nodes[1]), "test") self.assertEqual(arnold.AiNodeGetInt(nodes[1], "user:testInt"), 1) self.assertEqual(arnold.AiNodeGetFlt(nodes[1], "user:testFloat"), 2.5) self.assertEqual(arnold.AiNodeGetVec(nodes[1], "user:testV3f"), arnold.AtVector(1, 2, 3)) self.assertEqual(arnold.AiNodeGetRGB(nodes[1], "user:testColor3f"), arnold.AtRGB(4, 5, 6)) self.assertEqual(arnold.AiNodeGetStr(nodes[1], "user:testString"), "we're all doomed")
def Init(procName): proc = arnold.AiNodeLookUpByName(procName) if not proc: print("No such procedural: %s" % procName) return (0, None) attrs = {} it = arnold.AiNodeGetUserParamIterator(proc) while not arnold.AiUserParamIteratorFinished(it): param = arnold.AiUserParamIteratorGetNext(it) pname = arnold.AiUserParamGetName(param) pcat = arnold.AiUserParamGetCategory(param) if pcat == arnold.AI_USERDEF_CONSTANT: ptype = arnold.AiUserParamGetType(param) pval = None if ptype == arnold.AI_TYPE_BOOLEAN: pval = arnold.AiNodeGetBool(proc, pname) elif ptype == arnold.AI_TYPE_INT: pval = arnold.AiNodeGetInt(proc, pname) elif ptype == arnold.AI_TYPE_UINT: pval = arnold.AiNodeGetUInt(proc, pname) elif ptype == arnold.AI_TYPE_FLOAT: pval = arnold.AiNodeGetFlt(proc, pname) elif ptype == arnold.AI_TYPE_POINT: pval = arnold.AiNodeGetPnt(proc, pname) elif ptype == arnold.AI_TYPE_POINT2: pval = arnold.AiNodeGetPnt2(proc, pname) elif ptype == arnold.AI_TYPE_VECTOR: pval = arnold.AiNodeGetVec(proc, pname) elif ptype == arnold.AI_TYPE_RGB: pval = arnold.AiNodeGetRGB(proc, pname) elif ptype == arnold.AI_TYPE_RGBA: pval = arnold.AiNodeGetRGBA(proc, pname) elif ptype == arnold.AI_TYPE_STRING: pval = arnold.AiNodeGetStr(proc, pname) if pval != None: attrs[pname] = (ptype, pval) else: print("Unsupported type (%d) for parameter \"%s\"" % (ptype, pname)) else: print("Ignore non constant parameter \"%s\"" % pname) arnold.AiUserParamIteratorFinished(it) return (1, attrs)