Last active
April 18, 2019 02:03
-
-
Save teionn/e97811af45dd07b2bc09d5f9541d1a0b 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
//ランタイムコマンド上書き | |
/* | |
source "pencilPorySmoothRender_command.mel" | |
*/ | |
global proc RenderIntoNewWindow() | |
{ | |
python("import pencilPorySmoothRender_command as pPSR_command;reload(pPSR_command)"); | |
python("pPSR_command.runtimePencilRender()"); | |
} | |
/* | |
//元に戻すやつ | |
global proc RenderIntoNewWindow() | |
{ | |
renderIntoNewWindow render; | |
} | |
*/ |
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 -*- | |
#コーディング: utf-8 | |
#------------------------------------------------------------------------------ | |
import maya.cmds as cmds | |
import maya.mel | |
#------------------------------------------------------------------------------ | |
""" | |
import pencilPorySmoothRender_command as pPSR_command;reload(pPSR_command) | |
#pPSR_command.createSets()#スムース用Setsの作成 | |
#pPSR_command.addSets()#スムース用Setsにメッシュオブジェクトを追加 | |
#pPSR_command.removeSets()#スムース用Setsからメッシュオブジェクトを除外 | |
#pPSR_command.pencilRender()#スムース用Sets内のメッシュオブジェクトにpolySmoothFace dv=2 を適用してレンダリングして元に戻す。 | |
""" | |
_PRSSets="pencilRenderSmoothSets" | |
def createSets(): | |
if not cmds.objExists(_PRSSets): | |
cmds.sets(name=_PRSSets) | |
def addSets(): | |
_getMesh=[_item for _item in cmds.ls(sl=True) if cmds.listRelatives(_item,shapes=True,type="mesh")] | |
createSets() | |
cmds.sets(_getMesh,edit=True,forceElement=_PRSSets) | |
def removeSets(): | |
_getMesh=[_item for _item in cmds.ls(sl=True) if cmds.listRelatives(_item,shapes=True,type="mesh")] | |
if cmds.objExists(_PRSSets): | |
cmds.sets(_getMesh,edit=True,rm=_PRSSets) | |
def pencilSmooth(_object): | |
_smooth=cmds.polySmooth(_object,dv=2) | |
cmds.rename(_smooth,"pencilPorySmooth#") | |
def deletePPS(_meshList=[]): | |
if not len(_meshList): | |
_meshList=[_item for _item in cmds.ls(sl=True) if cmds.listRelatives(_item,shapes=True,type="mesh")] | |
for _mesh in _meshList: | |
for _pps in list(set(cmds.listConnections(cmds.listRelatives(_mesh,shapes=True),type="polySmoothFace")or [])): | |
cmds.delete(_pps) | |
#deletePPS() | |
def resetSMP(_getList): | |
_dict={} | |
_meshList=[_item for _item in _getList if cmds.listRelatives(_item,shapes=True,type="mesh")] | |
for _mesh in _meshList: | |
_dict.update({_mesh:cmds.getAttr("%s.displaySmoothMesh" % _mesh)}) | |
cmds.setAttr("%s.displaySmoothMesh" % _mesh,0) | |
return _dict | |
def setSMP(_dict): | |
for _key,_value in _dict.items(): | |
cmds.setAttr("%s.displaySmoothMesh" % _key,_value) | |
def preRenderScript(): | |
pass | |
def postRenderScript(): | |
pass | |
def pencilRender(): | |
_pencilMsRender=False | |
if cmds.objExists(_PRSSets) and cmds.getAttr("defaultRenderGlobals.currentRenderer") == "mayaSoftware": | |
_pencilMsRender=True | |
if _pencilMsRender: | |
_getList=cmds.sets(_PRSSets,q=True) | |
deletePPS(_getList) | |
_dict=resetSMP(_getList) | |
for _mesh in _getList: | |
pencilSmooth(_mesh) | |
preRenderScript() | |
maya.mel.eval("renderIntoNewWindow render;") | |
if _pencilMsRender: | |
deletePPS(_getList) | |
setSMP(_dict) | |
postRenderScript() | |
#pencilRender() | |
#ランタイムコマンド用 & シーン内のメッシュ全部スムース | |
def runtimePencilRender(): | |
_pencilMsRender=False | |
if cmds.getAttr("defaultRenderGlobals.currentRenderer") == "mayaSoftware": | |
_pencilMsRender=True | |
if _pencilMsRender: | |
_getList=cmds.listRelatives(cmds.ls(type="mesh"),parent=True) | |
deletePPS(_getList) | |
_dict=resetSMP(_getList) | |
for _mesh in _getList: | |
pencilSmooth(_mesh) | |
preRenderScript() | |
maya.mel.eval("renderIntoNewWindow render;") | |
if _pencilMsRender: | |
deletePPS(_getList) | |
setSMP(_dict) | |
postRenderScript() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment