Ejemplo n.º 1
0
def __aiMetadataGetRGB(nodeEntry, paramName, name, defaultValue=None):

    value = arnold.AtRGB()
    if arnold.AiMetaDataGetRGB(nodeEntry, paramName, name, value):
        return imath.Color3f(value.r, value.g, value.b)

    return defaultValue
Ejemplo n.º 2
0
	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] ],
			)
Ejemplo n.º 3
0
    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")