-
-
Save fereria/7979f89d0e1c18ade636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## -*- coding: utf-8 -*- | |
import pymel.core as pm | |
def addOffset2DTexAttr(): | |
texName = pm.ls(sl=True,type="place2dTexture") | |
splitAttr = "Split" | |
numAttr = "Num" | |
for tex in texName: | |
if tex.hasAttr(splitAttr) != True: | |
tex.addAttr(splitAttr,k=True,at="long",dv=7) | |
if tex.hasAttr(numAttr) != True: | |
tex.addAttr(numAttr,k=True,at="long",dv=1) | |
#OffsetCommand生成 | |
expCmd = "int $texSplit = (int) " + tex.name() + "." + splitAttr + ";\n" | |
expCmd += "float $offset = 1.0 / $texSplit;\n" | |
expCmd += tex.name() + ".offsetU = (((" + tex.name() + "." + numAttr + "- 1) % $texSplit) * $offset);\n" | |
expCmd += tex.name() + ".offsetV = ((((int)(" + tex.name() + "." + numAttr + " - 1) / $texSplit)) * $offset ) * -1;\n" | |
print expCmd | |
pm.expression(s=expCmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment