可以快速的导出Maya的mesh到wrl格式(For my GF)
例如,上图Tshape所导出wrl为:
#VRML V2.0 utf8 (Converted to ASCII) #Exported from Maya by SU&WEI Shape { geometry IndexedFaceSet { coord Coordinate { point [ -0.5 -0.5 0.5 -1 0.5 -0.5 0.5 -1 -0.5 0.5 0.5 -1 0.5 0.5 0.5 -1 -0.5 0.5 -0.5 -1 0.5 0.5 -0.5 -1 -0.5 -0.5 -0.5 -1 0.5 -0.5 -0.5 -1 -0.5 -0.5 1.94956040382 -1 0.5 -0.5 1.94956040382 -1 0.5 0.5 1.94956040382 -1 -0.5 0.5 1.94956040382 -1 1.39999997616 -0.5 -0.5 -1 1.39999997616 -0.5 0.5 -1 1.39999997616 0.5 -0.5 -1 1.39999997616 0.5 0.5 -1 -1.39999997616 -0.5 -0.5 -1 -1.39999997616 -0.5 0.5 -1 -1.39999997616 0.5 0.5 -1 -1.39999997616 0.5 -0.5 -1 ] } coordIndex [ 8 9 11 -1 9 10 11 -1 2 3 4 -1 3 4 5 -1 4 5 6 -1 5 6 7 -1 0 6 7 -1 0 1 7 -1 12 13 15 -1 12 14 15 -1 16 17 19 -1 17 18 19 -1 0 1 8 -1 1 8 9 -1 1 3 9 -1 3 9 10 -1 2 3 10 -1 2 10 11 -1 0 2 11 -1 0 8 11 -1 1 7 13 -1 7 12 13 -1 5 7 12 -1 5 12 14 -1 3 5 14 -1 3 14 15 -1 1 3 15 -1 1 13 15 -1 0 6 16 -1 0 16 17 -1 0 2 17 -1 2 17 18 -1 2 4 18 -1 4 18 19 -1 4 6 19 -1 6 16 19 -1 ] } }
source:
from maya.cmds import * import re ''' Transport selected mesh into .wrl format and write it to d:\\maya_output.wrl ''' # generate print('Generating WRL...'), buffer = '''#VRML V2.0 utf8 (Converted to ASCII) #Exported from Maya by SU&WEI Shape { geometry IndexedFaceSet { coord Coordinate { point [ ''' numVtx = polyEvaluate(v=1) for i in range(numVtx): pos = pointPosition('.vtx['+str(i)+']') buffer+='\t'*3+str(pos[0])+' '+str(pos[1])+' '+str(pos[2])+' -1\n' buffer+=''' ] } coordIndex [ ''' p=re.compile('\[\d*\]') numPoly = polyEvaluate(f=1) for i in range(numPoly): vtxIds = polyListComponentConversion('.f['+str(i)+']',tv=1) vtxIds = filterExpand(vtxIds,ex=1,sm=31) buffer+='\t'*3 for j in vtxIds: id = p.search(j).group() id = id[1:-1] buffer+=' '+id buffer+=' -1'+'\n' buffer+=''' ] } }''' print('OK') # write print(r'Writing to d:\maya_output.wrl...'), f = open(r'd:\maya_output.wrl','w') f.write(buffer) f.close() print('OK')