View Full Version : How to detect flipped UV face ?

11-10-2010, 06:44 PM
Hi. How to get flipped UV face in maya on mel/python ?

11-12-2010, 07:14 PM
from pymel.all import *
import pymel.core.datatypes as dt

faces = ls((polyListComponentConversion((ls(fl=1,sl=1)), tf=1)), fl=1)

for face in faces:
uvs = []
vtxFaces = ls(polyListComponentConversion(face,toVertexFace=True),flatten=True)
for vtxFace in vtxFaces:
uv = polyListComponentConversion(vtxFace,fromVertexFace=True,toUV=True)
uvs.append( uv[0] )
#get edge vectors and cross them to get the uv face normal
uvAPos = polyEditUV(uvs[0], q=1)
uvBPos = polyEditUV(uvs[1], q=1)
uvCPos = polyEditUV(uvs[2], q=1)
uvAB = dt.Vector([uvBPos[0]-uvAPos[0], uvBPos[1]-uvAPos[1]])
uvBC = dt.Vector([uvCPos[0]-uvBPos[0], uvCPos[1]-uvBPos[1]])
if uvAB.cross(uvBC) * dt.Vector([0, 0, 1]) > 0: uvnormal=1
else: uvnormal=-1
print face,uvnormal

CGTalk Moderation
11-12-2010, 07:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.