Exemple #1
0
def getTextureAttr (path = None):
    """
    This function return a list containing the type of the texture
    and a list of attributes that should match the textures attribute.
    This is used to check if the texture have the right naming convention and the right attributes.

    :param path: The list of files to push
    :type path: str
    :returns: str -- Return the directory of the pushed files

    **Example:**
    >>> getTextureAttr ( path = "/homeworks/users/jdoe/projects/bls/chr/belanus/tex/main/bls_chr_belanus_tex_main_spec1.1001.tif" )
    >>> ('spec1', ('R', '8-bit 16-bit', 'rgb(255,255,255)', True, 'triangle', '1'))
    
    """

    # Get authorized texture types list
    textureType=utils.getTextureTypes ()

    # Get the texture filename
    fname=os.path.basename (path)

    # Iterate over all the texture types
    for typ in textureType :

        # Define common texture patern
        simpTex="%s\d*.\d\d\d\d."%typ

        # Define animated texture patern
        animTex="%s\d*.\d\d\d\d.\d\d\d\d."%typ

        # Combine patterns
        pattern="%s|%s"%(simpTex, animTex)

        # Check the filename belong to one of the texture type
        if re.findall (pattern, fname)==[]:
            return (typ, textureType [ typ ])

    return (False, False)
Exemple #2
0
def hkImportChannels ( path, doc_id, ver ):
	""""""
	texture_type = utils.getTextureTypes ()

	print "doc_id:", doc_id
	geo = mari.geo.current ()
	variation = PythonQt.QtGui.QInputDialog.getText ( PythonQt.QtGui.QDialog(), 'Input Dialog', 'Variation:')
	#TODO:check if ID exists
	gid = geo.metadata ("id")
	ismod = ( gid.replace ( "mod", "tex" ) == doc_id )
	isrig = ( gid.replace ( "rig", "tex" ) == doc_id )

	if ismod or isrig :
		
		for channel_name in texture_type :
			texls = glob.glob ( os.path.join ( path, "*_%s_%s.*.tif" % ( variation, channel_name ) ) )

			if len ( texls ) > 0 :
				hkImportChannel ( path, doc_id, channel_name, variation, geo, False )

	else:
		print "Not a proper asset"
Exemple #3
0
def hkExportAllChannels ( wedge = "wedge1", geo = None, dialog = False, animation = False ):
	texture_type = utils.getTextureTypes ()
	exported = ""

	"Check input geo"
	if geo == None :
		geo = mari.geo.current ()

	"Processing export"
	channel_list = geo.channelList ()
	if dialog :
		wedge = PythonQt.QtGui.QInputDialog.getText ( PythonQt.QtGui.QDialog(), 'Input Dialog', 'Wedge name:')
		if wedge == "": wedge = "wedge"

	for chan in channel_list:
		channel_name = chan.name ()

		if channel_name in texture_type :
			hkExportChannel ( channel_name, wedge, geo )

		else:
			print "hkExportAllChannels (): %s channel skipped" % channel_name

	return True
Exemple #4
0
def textureCheck (doc_id = "", files = list()) :
    """
    This function check if textures respect the Homeworks rules.

    :param doc_id: The asset code
    :type doc_id: str
    :param files: File(s) to check
    :type files: str/list of str
    :returns: list -- Return a list of textures path that have not success the check

    **Example:**
    >>> textureOptimise ( path = "/homeworks/users/jdoe/projects/bls/chr/belanus/tex/main/bls_chr_belanus_tex_main_spec1.1001.tif" )

    **Note:**
        This function use system commands that calls 'imagemagick'.
        Make sure to have it installed.
        
    """

    # Get authorised textures types
    textureType=utils.getTextureTypes ()

    # Make sure files is a list
    not_success=list (files)

    # Iterate over provided files
    for fil in files :

        # Get filename
        fname=os.path.basename (fil)

        # Check the texture 'fil' is legal
        for typ in textureType :

            # Common texture pattern
            simpTex="%s_\d*_%s\d*.\d\d\d\d."%(doc_id, typ)
            simpTex=simpTex+"tif|"+simpTex+"exr"

            # Animated texture pattern
            animTex="%s_\d*_%s\d*.\d\d\d\d.\d\d\d\d."%(doc_id, typ)
            animTex=animTex+"tif|"+animTex+"exr"

            # Combine patterns
            pattern="%s|%s"%(simpTex, animTex)

            # If 'fil' texture respect one of the patterns
            if re.findall (pattern, fname):

                texfile=""
                # Get the extension
                fext=fname.split (".")[-1]

                # Check if the texture is already built
                if fext!="tex":

                    # Replace the current extension by .tex
                    texfile=fil.replace (".%s"%fext, ".tex")

                    # Check if texfile exist
                    if os.path.exists (texfile):

                        # Remove the textures from not_success
                        not_success.remove (fil)
                        not_success.remove (texfile)
                        print "textureCheck: %s OK"%fname

                    else:
                        print "textureCheck: missing .tex for %s"%fname

    return not_success