【MAYA】 머티리얼의 페이스 어사인시에 머티리얼 미정의면이 되어 있지 않은지 확인한다

MAYA에서는 (어떤 사고로) 머티리얼의 어사인이 잡혀 버린 폴리곤의 표시는 이렇게 형광 그린과 같은 색으로 표시되는 것입니다만,

페이스 어사인으로 일부만 머티리얼이 없는 상태도 만들 수 있습니다. 이것은 페이스와 SG의 커넥션을 끊는 것만으로는 좋지 않고, 그러한 경우는 대신에 compInstObjGroups(컴퍼넌트 인스턴스 오브젝트 그룹)로 설정되어 있는 머티리얼이 적용됩니다. 그래서 그 compInstObjGroups측의 SG와의 커넥션도 끊어 주는 것으로 이러한 상태를 만들어낼 수가 있습니다.
만들 수 있다고 해서, 우연히 할 수 있는 일이 있는가 하면 그렇게 하지 않는 것은? 라고 생각해 버립니다만 , 지인 웬만해 생긴 적이 있는 것 같기 때문에 , 이것을 판정하는 프로그램을 써 봅니다.
주의점
실제 코드
def is_face_assigned_all(shape):
"""
フェイスアサインの抜けがあって、マテリアル未定義面ができていないか確認する
:param shape: チェックするシェイプ
:type shape: pymel.nodetypes.Shape
:rtype: bool
"""
# compInstObjGroupsからコネクションがSGに伸びていればフェイスアサインに抜けがあってもマテリアルがない面が現れることはない
indices = shape.compInstObjGroups.getArrayIndices()
found = False
for i in indices:
group = shape.compInstObjGroups[i].compObjectGroups[0]
cons = pm.listConnections(group, plugs=True)
if len(cons) > 0 and cons[0].type() == 'shadingEngine':
found = True
break
if found:
return True
# フェイス面ごとにフラグを持ってマテリアルアサイン抜けがある部分を探す
instanceNumber = shape.instanceNumber()
indices = shape.instObjGroups[instanceNumber].objectGroups.getArrayIndices()
numFaces = shape.numFaces()
assined_map = [False] * numFaces
for i in indices:
objectGrpCompList = shape.instObjGroups[instanceNumber].objectGroups[i].objectGrpCompList
faces_list = objectGrpCompList.get() # ex) ['f[0]','f[1:3]']
# 返ってきたフェイス情報が文字列なので力技で面番号のリストに変換する。。。
for faces in faces_list:
faces = faces[2:-1] # ex) '0' or '1:3'
if ':' in faces:
a_ = [int(x) for x in faces.split(':')] # ex [1,3]
a_ = xrange(a_[0], a_[1] + 1) # ex [1,2,3]
else:
a_ = [int(faces)] # ex [0]
# マテリアル設定があった面情報としてTrueをセット
for i in a_:
assined_map[i] = True
#一つもFalseがなかったら全ての面にマテリアルが定義されている
return not (False in assined_map)
문자열을 호게하고 있는 근처가 역기입니다.
동작 검증
전회와 같은 검증 씬(야츠케 감반단 없음)을 사용합니다.

아래에서 pCube1,2,3,4,5,6
shape = pm.PyNode('pCube1|pCubeShape1') # フェイスアサインのないインスタンスシェイプ
print(is_face_assigned_all(shape)) # -> False
shape = pm.PyNode('pCube2|pCubeShape1') # フェイスアサインのあるインスタンスシェイプ
print(is_face_assigned_all(shape)) # -> True
shape = pm.PyNode('pCube3|pCubeShape3') # インスタンスが存在しないフェイスアサインのないシェイプ
print(is_face_assigned_all(shape)) # -> False
shape = pm.PyNode('pCube4|pCubeShape4') # インスタンスが存在しないフェイスアサインのあるシェイプ
print(is_face_assigned_all(shape)) # -> True
shape = pm.PyNode('pCube5|pCubeShape5') # マテリアルが外れてしまったシェイプ
print(is_face_assigned_all(shape)) # -> False
shape = pm.PyNode('pCube6|pCubeShape6') # 一部faceのマテリアルが外れてしまったシェイプ
print(is_face_assigned_all(shape)) # -> False
우선, 제대로 움직이고 있는 것 같습니다.
Reference
이 문제에 관하여(【MAYA】 머티리얼의 페이스 어사인시에 머티리얼 미정의면이 되어 있지 않은지 확인한다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/harayoki/items/49dcb96512141e0e1b08텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)