Exemple #1
0
def makeTreeShaders(num):
    '''
    Creates a number of shaders suitable for trees.
    
    num: The number of different green coloured shaders that will be created.
    On exit: Creates a shader for the tree trunk, and returns a list with the
             specified number of shaders with different green colours.
    '''
    trunkShader = tools.makeShader((0.124,0.043,0.000), "trunkMaterial")
    cmds.setAttr("trunkMaterial.reflectivity", 0)
    cmds.setAttr("trunkMaterial.specularColor", 0, 0, 0)
    l =[]
    for i in range(num):
        hue = random.randint(75, 120)
        saturation = random.uniform(0.6, 1)
        value = random.uniform(0.15, 0.6)
        RGB = tools.convertToRgb((hue, saturation, value))
        treeShader = tools.makeShader((RGB[0], RGB[1], RGB[2]), "treeMaterial")
        cmds.setAttr(treeShader[0] + ".reflectivity", 0)
        cmds.setAttr(treeShader[0] + ".specularColor", 0, 0, 0)
        l.append(treeShader)
    return l
def makeHouseShaders(num, colourRange):
    '''
    Creates a number of shaders for houses.
    
    num: The number of shaders that will be created.
    colourRange: A tuple containing two triples with hsv colour values. These 
                 colour values gives the range for the hue, saturation and value 
                 the shaders will have.
    On exit: The specified number of shaders have been created and added to a list. 
             All the shaders have colours within the given colour range. The list
             is returned.
    '''
    shaderList = []    
    for i in range(num):
        hue = tools.getRandomValue((colourRange[0][0]/360.0,colourRange[1][0]/360.0))
        saturation = tools.getRandomValue((colourRange[0][1],colourRange[1][1]))
        value = tools.getRandomValue((colourRange[0][2],colourRange[1][2]))
        RGB = tools.convertToRgb((hue*360, saturation, value))
        shader = tools.makeShader((RGB[0], RGB[1], RGB[2]))
        cmds.setAttr(shader[0] + ".reflectivity", 0.000)
        cmds.setAttr(shader[0] + ".specularColor", 0.120, 0.120, 0.120)
        shaderList.append(shader)
    return shaderList