Пример #1
0
def createArnoldClass(entryName,
                      parentClass,
                      paramList,
                      nentry,
                      parentParamList=None,
                      isAPI=False,
                      isInstantiable=True):

    schemaName = 'Arnold{}'.format(makeCamelCase(entryName))
    attrScope = ''

    if isAPI:
        file.write('class "{}API"(\n'.format(schemaName))
        attrScope = 'primvars:arnold:'  # need to primvars with the arnold namespace for USD-native nodes
    elif isInstantiable:
        file.write('class {} "{}"(\n'.format(schemaName, schemaName))
    else:
        file.write('class "{}"(\n'.format(schemaName))

    file.write('    inherits = [</{}>]\n'.format(parentClass))
    file.write(') {\n')

    for param in paramList:
        if param == 'name':
            continue  # nothing to do with attribute 'name'

        if parentParamList and param in parentParamList:  # if this parameter already exists in the parent class we don't add it here
            continue

        paramEntry = ai.AiNodeEntryLookUpParameter(nentry, param)
        if paramEntry == None:
            print 'Param Entry not found: {}.{}'.format(entryName, param)
            continue

        paramStr = arnoldToUsdParamString(paramEntry, attrScope)
        if paramStr != None and len(paramStr) > 0:
            file.write('    {}\n'.format(paramStr))

    file.write('}\n')

    if isAPI:
        file_module.write('    TF_WRAP(Usd%sAPI);\n' % schemaName)
    else:
        file_module.write('    TF_WRAP(Usd%s);\n' % schemaName)
Пример #2
0
def createArnoldClass(entryName,
                      parentClass,
                      paramList,
                      nentry,
                      parentParamList=None,
                      isAPI=False):

    schemaName = 'Arnold{}'.format(makeCamelCase(entryName))

    if isAPI:
        file.write('class "{}API"(\n'.format(schemaName))
        parentClass = 'APISchemaBase'
    else:
        file.write('class {} "{}"(\n'.format(schemaName, schemaName))

    file.write('    inherits = [</{}>]\n'.format(parentClass))
    file.write(') {\n')

    for param in paramList:
        if param == 'name':
            continue  # nothing to do with attribute 'name'
        if entryName == 'compare' and param == 'test':  # we have a problem with token test from shader compare (==, !=, <, >, etc...)
            continue
        if parentParamList and param in parentParamList:  # if this parameter already exists in the parent class we don't add it here
            continue
        paramEntry = ai.AiNodeEntryLookUpParameter(nentry, param)
        if paramEntry == None:
            print 'Param Entry not found: {}.{}'.format(entryName, param)
            continue

        paramStr = arnoldToUsdParamString(paramEntry)
        if paramStr != None and len(paramStr) > 0:
            file.write('    {}\n'.format(paramStr))

    file.write('}\n')

    if isAPI:
        file_module.write('    TF_WRAP(Usd%sAPI);\n' % schemaName)
    else:
        file_module.write('    TF_WRAP(Usd%s);\n' % schemaName)
Пример #3
0
def GetNode(user_data, i):
    ptype, pval = user_data.get("type")
    n = arnold.AiNode(pval)
    if n:
        name = "sample_%s" % pval
        arnold.AiNodeSetStr(n, "name", name)
        ne = arnold.AiNodeGetNodeEntry(n)
        for k, v in user_data.iteritems():
            if k == "type":
                continue
            ptype, pval = v
            pe = arnold.AiNodeEntryLookUpParameter(ne, k)
            if pe:
                if ptype == arnold.AI_TYPE_BOOLEAN:
                    arnold.AiNodeSetBool(n, k, pval)
                elif ptype == arnold.AI_TYPE_INT:
                    arnold.AiNodeSetInt(n, k, pval)
                elif ptype == arnold.AI_TYPE_UINT:
                    arnold.AiNodeSetUInt(n, k, pval)
                elif ptype == arnold.AI_TYPE_FLOAT:
                    arnold.AiNodeSetFlt(n, k, pval)
                elif ptype == arnold.AI_TYPE_POINT:
                    arnold.AiNodeSetPnt(n, k, pval.x, pval.y, pval.z)
                elif ptype == arnold.AI_TYPE_POINT2:
                    arnold.AiNodeSetPnt2(n, k, pval.x, pval.y)
                elif ptype == arnold.AI_TYPE_VECTOR:
                    arnold.AiNodeSetVec(n, k, pval.x, pval.y, pval.z)
                elif ptype == arnold.AI_TYPE_RGB:
                    arnold.AiNodeSetRGB(n, k, pval.r, pval.g, pval.b)
                elif ptype == arnold.AI_TYPE_RGBA:
                    arnold.AiNodeSetRGBA(n, k, pval.r, pval.g, pval.b, pval.a)
                elif ptype == arnold.AI_TYPE_STRING:
                    arnold.AiNodeSetStr(n, k, pval)
        return name
    else:
        return None