def __init__(self, name): if DEBUG: print ("Initializing ViewRenderOverride") #omr.MRenderOverride.__init__(self, name) super(ViewRenderOverride, self).__init__(name) # name in the renderer dropdown menu self.UIName = PLUGIN_NAME # this counts through the render passes # restarts for every frame output to the screen self.operation = 0 # label for the onion # current frame, used for setting the onion target key self.currentFrame = 0 # holds all avaialable onion skin renders # the key to the target is its frame number self.onionSkinBuffer = {} # save the order in which onions where added self.onionSkinBufferQueue = collections.deque() # max amount of buffered frames self.maxOnionSkinBufferSize = 200 # store blend passes for relative onion skin display # a pass is stored when the user activates it in the ui with the "v" icon self.relativeBlendPasses = {} # only display every nth relative onion self.relativeStep = 1 # store blend passes for absolute onion skin display # a blend pass is stored with the key being its frame # a blend pass is added for each absolute onion skin display the user registers self.absoluteBlendPasses = {} # buffer onion objects to make adding sets possible self.onionObjectBuffer = om.MSelectionList() # save all the objects to display in a list self.onionObjectList = om.MSelectionList() # store the render operations that combine onions in a list self.renderOperations = [] # tint colors for different os types rgb 0-255 self.relativeFutureTint = [255,0,0] self.relativePastTint = [0,255,0] self.absoluteTint = [0,0,255] # tint strengths, 1 is full tint self.tintStrength = 1.0 self.globalOpacity = 1.0 self.onionSkinDisplayType = 1 # outline width in pixels self.outlineWidth = 3 self.drawBehind = 1 # range 0-2. # 0 = default, 1 = relative random, 2 = static random self.tintType = 0 # seed value set by user to get different random colors for tints self.tintSeed = 0 # If this is True, we will show onion skins on the next keyticks # e.g. if relativeBlendPasses has 1 and 3 in it, it will draw # the next and the 3rd frame with a tick on the timeslider self.relativeKeyDisplay = True # self.timeCallbackId = 0 # self.cameraMovedCallbackIds = [] # self.autoClearBuffer = True # Passes self.clearPass = clearRender.viewRenderClearRender("clearPass") self.clearPass.setOverridesColors(False) self.renderOperations.append(self.clearPass) self.standardPass = sceneRender.OSSceneRender( "standardPass", omr.MClearOperation.kClearNone ) self.renderOperations.append(self.standardPass) # the onion skin pass buffers an image of the specified object on the current frame self.onionSkinPass = sceneRender.OSSceneRender( "onionSkinPass", omr.MClearOperation.kClearAll ) self.onionSkinPass.setSceneFilter(omr.MSceneRender.kRenderShadedItems) self.onionSkinPass.setDrawSelectionFilter(True) self.renderOperations.append(self.onionSkinPass) self.HUDPass = hudRender.viewRenderHUDRender() self.renderOperations.append(self.HUDPass) self.presentTarget = presentTarget.viewRenderPresentTarget("presentTarget") self.renderOperations.append(self.presentTarget) # TARGETS # standard target is what will be displayed. all but onion skins render to this target self.standardTargetDescr = omr.MRenderTargetDescription() self.standardTargetDescr.setName("standardTarget") self.standardTargetDescr.setRasterFormat(omr.MRenderer.kR8G8B8A8_UNORM) self.depthTargetDescr = omr.MRenderTargetDescription() self.depthTargetDescr.setName("depthTarget") self.depthTargetDescr.setRasterFormat(omr.MRenderer.kD24S8) # with this onion skins will be blended over standard target self.blendTargetDescr = omr.MRenderTargetDescription() self.blendTargetDescr.setName("onionTarget") self.blendTargetDescr.setRasterFormat(omr.MRenderer.kR8G8B8A8_UNORM) # Set the targets that don't change self.targetMgr = omr.MRenderer.getRenderTargetManager() self.standardTarget = self.targetMgr.acquireRenderTarget(self.standardTargetDescr) self.clearPass.setRenderTarget(self.standardTarget) self.standardPass.setRenderTarget(self.standardTarget) self.HUDPass.setRenderTarget(self.standardTarget) self.presentTarget.setRenderTarget(self.standardTarget)
def isUnderSceneRoot(node): fn = om2.MFnDagNode(node) par = fn.parent(0) return isSceneRoot(par)
def worldMatrixPlug(mobject): wm = om2.MFnDependencyNode(mobject).findPlug("worldMatrix", False) wm.evaluateNumElements() return wm.elementByPhysicalIndex(0)
def makeMatteLayerFromSelectedGRP(): selected = cmds.ls(sl = True) selectedTransforms = cmds.listRelatives(selected, allDescendents = True, type = "transform") selectedShapes = cmds.listRelatives(selected, allDescendents = True, type = "shape") makeLayer = rs.createRenderLayer(selected[0] + ' Matte Layers') makeCollection = makeLayer.createCollection(selected[0] + 'Matte Collection ON') makeCollection.getSelector().setPattern("*") makeCollection.getSelector().setFilterType(2) matteCollectionOverride = makeCollection.createOverride(selected[0] + " Matte Override", OpenMaya.MTypeId(0x58000378)) matteCollection = makeLayer.createCollection(selected[0] + ' Matte Collection OFF') matteCollection.getSelector().staticSelection.set(selectedShapes) matteCollection.getSelector().setFilterType(2) matteCollectionOverride2 = matteCollection.createOverride(selected[0] + " Matte Override", OpenMaya.MTypeId(0x58000378)) plug = '%s.aiMatte' % selectedShapes[0] matteCollectionOverride.setAttributeName(plug) matteCollectionOverride.finalize(plug) matteCollectionOverride.setAttrValue(1) matteCollectionOverride2.setAttributeName(plug) matteCollectionOverride2.finalize(plug) matteCollectionOverride2.setAttrValue(0)
def asDagPath(node): sel = om2.MSelectionList() sel.add(node) return sel.getDagPath(0)
def J_exportSelections2json(frameRange=''): if frameRange == "": frameRange = [ cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True) ] sel = om.MSelectionList(om.MGlobal.getActiveSelectionList()) #sel=cmds.ls(sl=True) for item in range(0, sel.length()): outData = {} filePath = cmds.file(query=True, sceneName=True).replace( cmds.file(query=True, sceneName=True, shortName=True), '') if cmds.file(query=True, sceneName=True, shortName=True) == '': cmds.confirmDialog(title=u'错误', message=u'文件未保存,或者需要另存为mb格式', button='好吧') return jsonFile = filePath + '/' + cmds.file( query=True, sceneName=True, shortName=True)[0:-3] + sel.getComponent( item)[0].partialPathName().replace(":", "") + "@" + str( frameRange[0]) + "_" + str(frameRange[1]) + '.txt' frameData = [] if sel.getComponent(item)[0].extendToShape().apiType() == 250: cameraNode = om.MFnCamera( sel.getComponent(item)[0].extendToShape()) aOfv = cameraNode.horizontalFieldOfView() for i in range(int(frameRange[0]), int(frameRange[1])): cmds.currentTime(i) trNode = om.MTransformationMatrix( sel.getComponent(item)[0].inclusiveMatrix()) position = [ trNode.translation(4)[0] * (-0.01), trNode.translation(4)[1] * (0.01), trNode.translation(4)[2] * (0.01) ] rotationQuaternion = [ trNode.rotation(True)[0] * (-1), trNode.rotation(True)[1] * (-1), trNode.rotation(True)[2], trNode.rotation(True)[3] ] frameData.append({ 'pos': position, 'rot': rotationQuaternion, 'fov': str( math.atan(math.tan(aOfv * 0.5) / 1.7777778) * 360 / 3.141592) }) outData['frame'] = frameData elif sel.getComponent(item)[0].extendToShape().apiType() == 296: for i in range(int(frameRange[0]), int(frameRange[1])): cmds.currentTime(i) trNode = om.MTransformationMatrix( sel.getComponent(item)[0].inclusiveMatrix()) position = [ trNode.translation(4)[0] * (-0.01), trNode.translation(4)[1] * (0.01), trNode.translation(4)[2] * (0.01) ] rotationQuaternion = [ trNode.rotation(True)[0] * (-1), trNode.rotation(True)[1] * (-1), trNode.rotation(True)[2], trNode.rotation(True)[3] ] scale = [ trNode.scale(4)[0], trNode.scale(4)[1], trNode.scale(4)[2] ] frameData.append({ 'pos': position, 'rot': rotationQuaternion, 'scale': scale }) outData['frame'] = frameData outFile = open(jsonFile, 'w') outFile.write( json.dumps([outData], encoding='utf-8', ensure_ascii=False)) outFile.close() os.startfile(filePath)
def get_anim_curve_default_value(anim_curve): """ Get the default value of the given anim curve :param anim_curve: Animation curve :type anim_curve: oma.MFnAnimCurve :return: Default value of attribute curve is connected to. :rtype: float or None """ plug = anim_curve.findPlug('output', True) if plug: destinations = plug.destinations() if not destinations: return None for dst_plug in destinations: # if the first node we hit does not have an output, assume it is the node we want to animate if dst_plug.node().hasFn(om.MFn.kDagNode): return get_attribute_default_value(dst_plug) it = om.MItDependencyGraph( dst_plug, om.MFn.kInvalid, direction=om.MItDependencyGraph.kDownstream, traversal=om.MItDependencyGraph.kDepthFirst, level=om.MItDependencyGraph.kPlugLevel) target_plug = None # search through blend nodes and always grab the source plug of the node that comes after the blend node while not it.isDone(): if it.currentNode().apiType() in animlayers.BLEND_NODE_TYPES: it.next() if not it.isDone(): target_plug = it.currentPlug( ) # should result in input of blend or the desired attribute it.next() continue it.next() # if plug is compound then use same child index as the one we came from if dst_plug.isChild and target_plug.isChild: parent = dst_plug.parent() idx = -1 for i in range(parent.numChildren()): if parent.child(i) == dst_plug: idx = i break target_parent = target_plug.parent() if target_parent.numChildren() > idx: p = target_parent.child(idx) return get_attribute_default_value(p) else: return None # resolve non-compound plugs if target_plug: return get_attribute_default_value(target_plug) return None
def testSkelTransforms(self): """ Tests that the computed joint transforms in USD, when tarnsformed into world space, match the world space transforms of the Maya joints. """ mayaFile = os.path.join(self.inputPath, "UsdExportSkeletonTest", "UsdExportSkeleton.ma") cmds.file(mayaFile, force=True, open=True) # frameRange = [1, 30] frameRange = [1, 3] # TODO: The joint hierarchy intentionally includes non-joint nodes, # which are expected to be ignored. However, when we try to extract # restTransforms from the dagPose, the intermediate transforms cause # problems, since they are not members of the dagPose. As a result, # no dag pose is exported. Need to come up with a way to handle this # correctly in export. print("Expect warnings about invalid restTransforms") usdFile = os.path.abspath('UsdExportSkeleton.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFile, shadingMode='none', frameRange=frameRange, exportSkels='auto') stage = Usd.Stage.Open(usdFile) root = UsdSkel.Root.Get(stage, '/SkelChar') self.assertTrue(root) skelCache = UsdSkel.Cache() if Usd.GetVersion() > (0, 20, 8): skelCache.Populate(root, Usd.PrimDefaultPredicate) else: skelCache.Populate(root) skel = UsdSkel.Skeleton.Get(stage, '/SkelChar/Hips') self.assertTrue(skel) skelQuery = skelCache.GetSkelQuery(skel) self.assertTrue(skelQuery) xfCache = UsdGeom.XformCache() for frame in range(*frameRange): cmds.currentTime(frame, edit=True) xfCache.SetTime(frame) skelLocalToWorld = xfCache.GetLocalToWorldTransform(skelQuery.GetPrim()) usdJointXforms = skelQuery.ComputeJointSkelTransforms(frame) for joint,usdJointXf in zip(skelQuery.GetJointOrder(), usdJointXforms): usdJointWorldXf = usdJointXf * skelLocalToWorld selList = OM.MSelectionList() selList.add(Sdf.Path(joint).name) dagPath = selList.getDagPath(0) mayaJointWorldXf = Gf.Matrix4d(*dagPath.inclusiveMatrix()) self.assertTrue(Gf.IsClose(mayaJointWorldXf, usdJointWorldXf, 1e-5))
def reset_vtcs_selection(self): self.vtcs_selection = {'obj_path': om2.MDagPath(), 'indices': om2.MIntArray()} self.get_selected_vtcs_pB.setStyleSheet('background-color: dark gray')
def deformById(curve, mobjects): points = [] for o in mobjects: if o.isNull() or not len(om2.MFnDagNode(o).fullPathName()): return False fn = om2.MFnTransform(o) points.append(fn.translation(om2.MSpace.kTransform)) curve.points = points return True NUM_POINTS = 4 POINTS = [ om2.MVector([random.randint(-10, 10) for _ in range(3)]) for _ in range(NUM_POINTS) ] # create a bezier curve with `NUM_POINTS` control points cage = mscreen.drawCurve(POINTS, color=mscreen.COLOR_GRAY) crv = mscreen.drawCurve(POINTS, degree=mscreen.CURVE_BEZIER, color=mscreen.COLOR_GREEN) # lets create a transform node per control point objs = [] for i in range(NUM_POINTS): fn = om2.MFnTransform() mobject = fn.create() fn.setTranslation(POINTS[i], om2.MSpace.kTransform)
def postConstructor(self, *args): dependNode = om.MFnDependencyNode(self.thisMObject())
def clearTargetObjects(self): self.onionObjectList = om.MSelectionList() self.onionObjectBuffer = om.MSelectionList() self.clearOnionSkinBuffer()
def removeTargetObject(self, dagPath): tmpList = om.MSelectionList() tmpList.add(dagPath) self.onionObjectBuffer.merge(tmpList, om.MSelectionList.kRemoveFromList) self.onionObjectList = self.flattenSelectionList(self.onionObjectBuffer) self.clearOnionSkinBuffer()
def isPlugInteresting(self, plug, targetPlug): mfn_dep = om.MFnDependencyNode(plug.node()) return plug == mfn_dep.findPlug(targetPlug, True)
def dag_to_curve(dag, curve): ''' Provide matrices that are an equal distribution along a curve Args: dag (str): name of dag node to attach to curve curve (str): name of curve to attach to ''' sel = om.MSelectionList() sel.add(curve) crv = om.MFnNurbsCurve() crv.setObject(sel.getDagPath(0)) curve_length = crv.length() max_param = crv.findParamFromLength(curve_length) mscs = [] up_vecs = [] ctrl_params = [] # create control to control up vector of curve ctrl_height = curve_length / 10.0 param = 0.001 ctrl = dg.create_dag('C_crv_upvec', type='control', ctrl_type='triangle', offset=True) ctrl_ofs = ctrl + '_OFS' ctrl_zero = ctrl + '_ZERO' line_loc = cmds.spaceLocator(name='C_crv_upvec_LOC')[0] ctrl_poci = cmds.createNode('pointOnCurveInfo', name=ctrl + '_POCI') dm = cmds.createNode('decomposeMatrix', name=ctrl + '_DM') sub_vec = cmds.createNode('math_SubtractVector', name=ctrl + '_SV') normalize = cmds.createNode('math_NormalizeVector', name=ctrl + '_NV') ctrl_params.append(param) cmds.connectAttr(curve + '.worldSpace[0]', ctrl_poci + '.inputCurve') cmds.setAttr(ctrl_poci + '.parameter', param) cmds.connectAttr(ctrl_poci + '.position', ctrl_zero + '.translate') cmds.connectAttr(ctrl_poci + '.position', line_loc + '.translate') cmds.setAttr(ctrl_ofs + '.ty', ctrl_height) cmds.connectAttr(ctrl + '.worldMatrix[0]', dm + '.inputMatrix') cmds.connectAttr(dm + '.outputTranslate', sub_vec + '.input1') cmds.connectAttr(line_loc + '.translate', sub_vec + '.input2') cmds.connectAttr(sub_vec + '.output', normalize + '.input') line_curve = curves.curve_from_objects([ctrl, line_loc], name=ctrl + '_vec_CRV') cmds.setAttr(line_curve + '.overrideEnabled', 1) cmds.setAttr(line_curve + '.overrideDisplayType', 2) up_vecs.append(normalize) # create instance to control pos and rot of controls being attached dag_poci = cmds.createNode('pointOnCurveInfo') fbf = cmds.createNode('fourByFourMatrix') msc = cmds.createNode('millSimpleConstraint') z_vec = cmds.createNode('vectorProduct') mscs.append(msc) # connect vecs to pair blend cmds.setAttr(z_vec + '.operation', 2) cmds.connectAttr(normalize + '.output', z_vec + '.input1') cmds.connectAttr(dag_poci + '.normalizedTangent', z_vec + '.input2') cmds.connectAttr(curve + '.worldSpace[0]', dag_poci + '.inputCurve') cmds.setAttr(dag_poci + '.parameter', param) cmds.connectAttr(dag_poci + '.normalizedTangentX', fbf + '.in00') cmds.connectAttr(dag_poci + '.normalizedTangentY', fbf + '.in01') cmds.connectAttr(dag_poci + '.normalizedTangentZ', fbf + '.in02') cmds.connectAttr(normalize + '.outputX', fbf + '.in10') cmds.connectAttr(normalize + '.outputY', fbf + '.in11') cmds.connectAttr(normalize + '.outputZ', fbf + '.in12') cmds.connectAttr(z_vec + '.outputX', fbf + '.in20') cmds.connectAttr(z_vec + '.outputY', fbf + '.in21') cmds.connectAttr(z_vec + '.outputZ', fbf + '.in22') cmds.connectAttr(dag_poci + '.positionX', fbf + '.in30') cmds.connectAttr(dag_poci + '.positionY', fbf + '.in31') cmds.connectAttr(dag_poci + '.positionZ', fbf + '.in32') cmds.connectAttr(fbf + '.output', msc + '.inMatrix') # attribute on dag to control the position along the curve par_attr = attribute.add_generic_blend(dag, 'curveDistance', max_value=max_param) cmds.connectAttr(par_attr, ctrl_poci + '.parameter') cmds.connectAttr(par_attr, dag_poci + '.parameter') # connect dag to curve cmds.connectAttr(dag + '_ZERO.parentInverseMatrix[0]', msc + '.parentInverseMatrix') cmds.connectAttr(msc + '.outTranslate', dag + '_ZERO.translate') cmds.connectAttr(msc + '.outRotate', dag + '_ZERO.rotate')
def initialize(): """ initialize plugin """ compound_attribute = OpenMaya.MFnCompoundAttribute() enumerate_attribute = OpenMaya.MFnEnumAttribute() numeric_attribute = OpenMaya.MFnNumericAttribute() typed_attribute = OpenMaya.MFnTypedAttribute() # create unique ui manager index attribute Plugin.aHudIndex = numeric_attribute.create( "hudIndex", "hudi", OpenMaya.MFnNumericData.kInt) numeric_attribute.default = -1 numeric_attribute.hidden = True OpenMaya.MPxNode.addAttribute(Plugin.aHudIndex) Plugin.aCreationUnixTime = numeric_attribute.create( "creationUnixTime", "cutime", OpenMaya.MFnNumericData.kDouble) numeric_attribute.default = -1 numeric_attribute.hidden = True OpenMaya.MPxNode.addAttribute(Plugin.aCreationUnixTime) # add resolution attribute Plugin.aResolution = numeric_attribute.create( "uiResolution", "ures", OpenMaya.MFnNumericData.k2Double) numeric_attribute.default = (256.0, 256.0) OpenMaya.MPxNode.addAttribute(Plugin.aResolution) # create ui type attribute Plugin.aUIType = enumerate_attribute.create("uiType", "ut", constants.kText) enumerate_attribute.addField("Text", constants.kText) enumerate_attribute.addField("Point", constants.kPoint) enumerate_attribute.addField("Circle", constants.kCircle) enumerate_attribute.addField("Line", constants.kLine) enumerate_attribute.addField("None", constants.kNone) # create size attribute Plugin.aSize = numeric_attribute.create( "size", "sz", OpenMaya.MFnNumericData.kDouble, 1.0) # create radius attribute Plugin.aRadius = numeric_attribute.create( "radius", "rad", OpenMaya.MFnNumericData.kDouble, 5.0) # create text attribute string_data = OpenMaya.MFnStringData() default_text_value = string_data.create("Text") Plugin.aText = typed_attribute.create("text", "t", OpenMaya.MFnData.kString, default_text_value) # create text dynamic control attribute Plugin.aTextDynamic = numeric_attribute.create( "textDynamic", "txtdyn", OpenMaya.MFnNumericData.kBoolean, 0) # create text auto resize control attribute Plugin.aFitToResolutionGate = numeric_attribute.create( "fitToResolutionGate", "fittoresg", OpenMaya.MFnNumericData.kBoolean, 0) # create horizontal alignment attribute Plugin.aHorizontalUiAttach = enumerate_attribute.create( "horizontalAttach", "ha", constants.kAttachHorizontalLeft) enumerate_attribute.addField("Left", constants.kAttachHorizontalLeft) enumerate_attribute.addField("Right", constants.kAttachHorizontalRight) enumerate_attribute.addField("Middle", constants.kAttachHorizontalMiddle) # create attach vertical attribute Plugin.aVerticalUiAttach = enumerate_attribute.create( "verticalAttach", "va", constants.kAttachVerticalTop) enumerate_attribute.addField("Top", constants.kAttachVerticalTop) enumerate_attribute.addField("Bottom", constants.kAttachVerticalBottom) enumerate_attribute.addField("Middle", constants.kAttachVerticalMiddle) # create attach vertical attribute Plugin.aResolutionGate = enumerate_attribute.create( "resolutionGate", "rgt", constants.kFilmGate) enumerate_attribute.addField("Port", constants.kPortGate) enumerate_attribute.addField("Viewport", constants.kViewportGate) enumerate_attribute.addField("Film", constants.kFilmGate) enumerate_attribute.addField("Image", constants.kImageGate) enumerate_attribute.addField("Safe title", constants.kSafeTitleGate) enumerate_attribute.addField("Safe action", constants.kSafeTitleAction) enumerate_attribute.addField("Render", constants.kRenderGate) enumerate_attribute.addField("Render safe title", constants.kSafeTitleRenderGate) enumerate_attribute.addField("Render safe action", constants.kSafeTitleRenderAction) # create drawing enable attribute Plugin.aDrawResolutionGateEnable = numeric_attribute.create( "gateDraw", "gdraw", OpenMaya.MFnNumericData.kBoolean, 0) # create horizontal alignment attribute Plugin.aHorizontalUiAlignment = enumerate_attribute.create( "horizontalAlignment", "hal", constants.kHorizontalAlignmentLeft) enumerate_attribute.addField("Left", constants.kHorizontalAlignmentLeft) enumerate_attribute.addField("Right", constants.kHorizontalAlignmentRight) enumerate_attribute.addField("Center", constants.kHorizontalAlignmentCenter) # create vertical alignment attribute Plugin.aVerticalUiAlignment = enumerate_attribute.create( "verticalAlignment", "val", constants.kVerticalAlignmentTop) enumerate_attribute.addField("Top", constants.kVerticalAlignmentTop) enumerate_attribute.addField("Bottom", constants.kVerticalAlignmentBottom) enumerate_attribute.addField("Center", constants.kVerticalAlignmentCenter) # create position alignment attribute Plugin.aPosition = numeric_attribute.create( "position", "pos", OpenMaya.MFnNumericData.k2Double) numeric_attribute.default = (0.0, 0.0) numeric_attribute.array = True # create drawing rectangle filled attribute Plugin.aUIRegionIsFilled = numeric_attribute.create( "regionIsFilled", "rif", OpenMaya.MFnNumericData.kBoolean, 0) # create drawing enable attribute Plugin.aUIDrawEnable = numeric_attribute.create( "draw", "draw", OpenMaya.MFnNumericData.kBoolean, 0) # create drawing enable attribute Plugin.aUIRegionDrawEnable = numeric_attribute.create( "regionDraw", "rdraw", OpenMaya.MFnNumericData.kBoolean, 0) # create drawing rectangle attribute Plugin.aUIRegion = numeric_attribute.create( "region", "reg", OpenMaya.MFnNumericData.k2Double) numeric_attribute.default = (0.0, 1.0) # create drawing filled attribute Plugin.aFilled = numeric_attribute.create( "filled", "fil", OpenMaya.MFnNumericData.kBoolean, 0) # create drawing rectangle offset position attribute Plugin.aUIRegionPosition = numeric_attribute.create( "regionPosition", "rpos", OpenMaya.MFnNumericData.k2Double) numeric_attribute.default = (0.0, 0.0) # create color attribute Plugin.aColor = numeric_attribute.create( "color", "col", OpenMaya.MFnNumericData.k3Float) numeric_attribute.default = (0.0, 1.0, 1.0) numeric_attribute.usedAsColor = True # create color transparency attribute Plugin.aTransparency = numeric_attribute.create( "transparency", "trans", OpenMaya.MFnNumericData.kFloat, 0.0) numeric_attribute.setSoftMin(0.0) numeric_attribute.setSoftMax(1.0) # create drawing rectangle fill color attribute Plugin.aUIRegionColor = numeric_attribute.create( "regionColor", "rcol", OpenMaya.MFnNumericData.k3Float) numeric_attribute.default = (0.0, 1.0, 1.0) numeric_attribute.usedAsColor = True # create drawing rectangle fill color transparency attribute Plugin.aUIRegionTransparency = numeric_attribute.create( "regionTransparency", "rtrans", OpenMaya.MFnNumericData.kFloat, 0.0) numeric_attribute.setSoftMin(0.0) numeric_attribute.setSoftMax(1.0) # create drawing text background fill color attribute Plugin.aUITextBackgroundColor = numeric_attribute.create( "textBackgroundColor", "tbcol", OpenMaya.MFnNumericData.k3Float) numeric_attribute.default = (0.0, 1.0, 1.0) numeric_attribute.usedAsColor = True # create drawing text background fill color transparency attribute Plugin.aUITextBackgroundTransparency = numeric_attribute.create( "textBackgroundTransparency", "tbtrans", OpenMaya.MFnNumericData.kFloat, 1.0) numeric_attribute.setSoftMin(0.0) numeric_attribute.setSoftMax(1.0) # create text incline attribute Plugin.aFontIncline = enumerate_attribute.create( "textIncline", "tic", constants.kFontStyleInclineNormal) enumerate_attribute.addField("Normal", constants.kFontStyleInclineNormal) enumerate_attribute.addField("Italic", constants.KFontStyleInclineItalic) # create text incline attribute Plugin.aFontWeight = enumerate_attribute.create( "fontWeight", "fw", constants.kFontStyleWeightLight) enumerate_attribute.addField("Normal", constants.kFontStyleWeightLight) enumerate_attribute.addField("Bold", constants.KFontStyleWeightBold) # create text font size attribute Plugin.aFontStyleSize = numeric_attribute.create( "fontSize", "fs", OpenMaya.MFnNumericData.kInt, OpenMayaRender.MUIDrawManager.kDefaultFontSize) numeric_attribute.setMin(-1) numeric_attribute.setMax(1000) # create text font size attribute Plugin.aLineWidth = numeric_attribute.create( "lineWidth", "lwd", OpenMaya.MFnNumericData.kFloat, 2.0) # create text font style attribute try: Plugin.uiFontStyleList = OpenMayaRender.MUIDrawManager.getFontList( ) except Exception as exception_data: Plugin.uiFontStyleList = [] logger.error(repr(exception_data)) logger.error("can`t read font list") if len(Plugin.uiFontStyleList) == 0: logger.error("no available font founded") # create text stretch attribute Plugin.aFontStyleStretch = numeric_attribute.create( "fontStretch", "fstr", OpenMaya.MFnNumericData.kInt, OpenMayaRender.MUIDrawManager.kStretchUnstretched) numeric_attribute.setMin(50) numeric_attribute.setMax(200) Plugin.aFontStyleName = enumerate_attribute.create( "fontStyle", "fstl", 0) for i, font_style in enumerate(Plugin.uiFontStyleList): try: enumerate_attribute.addField(font_style, i) except Exception as exception_data: logger.error(repr(exception_data)) logger.error("can`t add font field") # create text draw line attribute Plugin.aFontLine = enumerate_attribute.create( "fontLine", "fln", constants.kFontStyleLineNone) enumerate_attribute.addField("None", constants.kFontStyleLineNone) enumerate_attribute.addField("Overline", constants.kFontStyleLineOverline) enumerate_attribute.addField("Underline", constants.KFontStyleLineUnderline) enumerate_attribute.addField("Strikeout", constants.KFontStyleLineStrikeout) # create draw line style attribute Plugin.aLineStyle = enumerate_attribute.create("lineStyle", "ls", constants.kLineSolid) enumerate_attribute.addField("Solid", constants.kLineSolid) enumerate_attribute.addField("Short dotted", constants.kLineShortDotted) enumerate_attribute.addField("Short dashed", constants.kLineShortDashed) enumerate_attribute.addField("Dotted", constants.kLineDotted) enumerate_attribute.addField("Dashed", constants.kLineDashed) # create ui list attribute Plugin.aUI = compound_attribute.create("ui", "ui") compound_attribute.array = True compound_attribute.readable = True compound_attribute.writable = True # add attribute to compound attribute list compound_attribute.addChild(Plugin.aUIType) compound_attribute.addChild(Plugin.aUIDrawEnable) compound_attribute.addChild(Plugin.aDrawResolutionGateEnable) compound_attribute.addChild(Plugin.aResolutionGate) compound_attribute.addChild(Plugin.aUIRegionIsFilled) compound_attribute.addChild(Plugin.aRadius) compound_attribute.addChild(Plugin.aUIRegionColor) compound_attribute.addChild(Plugin.aUIRegionDrawEnable) compound_attribute.addChild(Plugin.aUIRegionTransparency) compound_attribute.addChild(Plugin.aHorizontalUiAttach) compound_attribute.addChild(Plugin.aVerticalUiAttach) compound_attribute.addChild(Plugin.aHorizontalUiAlignment) compound_attribute.addChild(Plugin.aVerticalUiAlignment) compound_attribute.addChild(Plugin.aText) compound_attribute.addChild(Plugin.aTextDynamic) compound_attribute.addChild(Plugin.aFitToResolutionGate) compound_attribute.addChild(Plugin.aUITextBackgroundColor) compound_attribute.addChild(Plugin.aUITextBackgroundTransparency) compound_attribute.addChild(Plugin.aFontIncline) compound_attribute.addChild(Plugin.aFilled) compound_attribute.addChild(Plugin.aFontWeight) compound_attribute.addChild(Plugin.aFontStyleName) compound_attribute.addChild(Plugin.aFontStyleSize) compound_attribute.addChild(Plugin.aUIRegion) compound_attribute.addChild(Plugin.aUIRegionPosition) compound_attribute.addChild(Plugin.aFontLine) compound_attribute.addChild(Plugin.aLineStyle) compound_attribute.addChild(Plugin.aLineWidth) compound_attribute.addChild(Plugin.aSize) compound_attribute.addChild(Plugin.aPosition) compound_attribute.addChild(Plugin.aFontStyleStretch) compound_attribute.addChild(Plugin.aColor) compound_attribute.addChild(Plugin.aTransparency) compound_attribute.usesArrayDataBuilder = True OpenMaya.MPxNode.addAttribute(Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIType, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aResolutionGate, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegionIsFilled, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aDrawResolutionGateEnable, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIDrawEnable, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegionColor, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegionDrawEnable, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegionTransparency, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aHorizontalUiAttach, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aVerticalUiAttach, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aHorizontalUiAlignment, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUITextBackgroundColor, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUITextBackgroundTransparency, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aRadius, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aVerticalUiAlignment, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aText, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aTextDynamic, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFitToResolutionGate, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFilled, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontIncline, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontWeight, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontStyleName, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontStyleSize, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegion, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aUIRegionPosition, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontLine, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aLineStyle, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aLineWidth, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aSize, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aPosition, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aFontStyleStretch, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aColor, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aTransparency, Plugin.aUI) OpenMaya.MPxNode.attributeAffects(Plugin.aResolution, Plugin.aUI)
def birail_nurbs_plane(dags, name, side_vector): """ Args: dags[(str)]: dag nodes to control plane name (str): base name of plane side_vector (om.MVector()): side vector to orient/create plane Returns: str: nurbs plane """ mtxs = [] side_vector = side_vector * 2 other_side_vector = side_vector * -1 for each in dags: mtx = cmds.xform(each, matrix=True, ws=True, q=True) mtxs.append(mtx) mtx1 = om.MMatrix() mtx1.setElement(3, 0, side_vector[0]) mtx1.setElement(3, 1, side_vector[1]) mtx1.setElement(3, 2, side_vector[2]) mtx2 = om.MMatrix() mtx2.setElement(3, 0, other_side_vector[0]) mtx2.setElement(3, 1, other_side_vector[1]) mtx2.setElement(3, 2, other_side_vector[2]) prof_crv1 = curves.curve_from_matrices(mtxs, name=name + '_prof1_CRV', degree=2) prof_crv2 = curves.curve_from_matrices(mtxs, name=name + '_prof2_CRV', degree=2) rail_crv1 = curves.curve_from_matrices([mtx1, mtx2], name=name + '_rail1_CRV', degree=1) rail_crv2 = curves.curve_from_matrices([mtx1, mtx2], name=name + '_rail2_CRV', degree=1) cmds.rebuildCurve(prof_crv1, ch=1, rpo=1, kr=0, kcp=1, kt=0, s=30, d=2, tol=0.01) cmds.rebuildCurve(prof_crv2, ch=1, rpo=1, kr=0, kcp=1, kt=0, s=30, d=2, tol=0.01) plane = cmds.doubleProfileBirailSurface(prof_crv1, prof_crv2, rail_crv1, rail_crv2, po=0, name=name) constraint.simple_constraint(dags[0], rail_crv1) constraint.simple_constraint(dags[-1], rail_crv2) for x, each in enumerate(dags): scon1 = cmds.createNode("millSimpleConstraint", name=prof_crv1 + '_MSC') scon2 = cmds.createNode("millSimpleConstraint", name=prof_crv1 + '_MSC') cmds.connectAttr(each + '.worldMatrix[0]', scon1 + '.inMatrix') cmds.connectAttr(prof_crv1 + '.parentInverseMatrix[0]', scon1 + '.parentInverseMatrix') cmds.connectAttr(each + '.worldMatrix[0]', scon2 + '.inMatrix') cmds.connectAttr(prof_crv2 + '.parentInverseMatrix[0]', scon2 + '.parentInverseMatrix') cmds.setAttr(scon1 + '.translateOffset', side_vector[0], side_vector[1], side_vector[2]) cmds.setAttr(scon2 + '.translateOffset', side_vector[0], side_vector[1], side_vector[2]) cmds.connectAttr(scon1 + '.outTranslate', prof_crv1 + '.cv[{}]'.format(x)) cmds.connectAttr(scon2 + '.outTranslate', prof_crv2 + '.cv[{}]'.format(x)) return plane
def write(path, target, skin=None, outdir=None, start=None, end=None): """ Write out data for the machine learning algorithm to train from. :param path: The path to the mesh we're writing data for. :param target: The target mesh to compare the vertices to. :param skin: The skin cluster to read weights from. :param outdir: The directory to write to. If no directory is provided, uses training directory. :param start: The start frame to write from. :param end: The end frame to write to :return: The path to the written data. """ # Make sure we can write out the data if not outdir: logger.warning('No output directory specified. Using default: %s', DEFAULT_LOCATION) outdir = DEFAULT_LOCATION if not os.path.exists(outdir): os.mkdir(outdir) # Figure out the start and end range if start is None: start = mc.playbackOptions(minTime=True, query=True) if end is None: end = mc.playbackOptions(maxTime=True, query=True) start = int(math.floor(start)) end = int(math.ceil(end)) currentTime = mc.currentTime(query=True) # Get the meshes sel = om.MSelectionList() sel.add(skinning.get_mesh(path)) sel.add(skinning.get_mesh(target)) mesh = om.MFnMesh(sel.getDagPath(0)) target_mesh = om.MFnMesh(sel.getDagPath(1)) # Get the skin cluster if not skin: skin = skinning.get_skincluster(mesh.fullPathName()) sel.add(skin) skin_node = sel.getDependNode(2) skin_cluster = oma.MFnSkinCluster(skin_node) # Get the weights vertices = range(mesh.numVertices) influence_objects = skin_cluster.influenceObjects() joints = [i.fullPathName() for i in influence_objects] joint_transforms = [om.MFnTransform(j) for j in influence_objects] influence_indexes, vertex_cmpt, weights = skinning.get_weights( mesh, skin_cluster, vertices) stride = len(influence_indexes) # Store the weight associations for vertices weight_map = [] joint_map = [] for i in range(stride): joint_map.append(list()) for vtx in vertices: vtx_weights = weights[vtx * stride:(vtx * stride) + stride] for i, weight in enumerate(vtx_weights): if weight > 0: weight_map.append(i) joint_map[i].append(vtx) break # Prepare data for joints frame_data = {} for joint in joints: frame_data[joint] = [] # Go through every frame and write out the data for all the joints and the vertexes for frame in range(start, end + 1): logger.debug('Processing frame %s', frame) mc.currentTime(frame) points = mesh.getPoints() target_points = target_mesh.getPoints() for jidx, vertices in enumerate(joint_map): xform = joint_transforms[jidx] rotation = xform.rotation(om.MSpace.kWorld, asQuaternion=True) translate = xform.translation(om.MSpace.kWorld) data = [] data += rotation data += translate for vtx in vertices: mpoint = points[vtx] tpoint = target_points[vtx] displacement = tpoint - mpoint data += displacement frame_data[joints[jidx]].append(data) # Write the data out to csv files csv_files = [] for joint in joints: data = frame_data[joint] filename = '%s.csv' % joint.replace('|', '_') if filename.startswith('_'): filename = filename[1:] filename = os.path.join(outdir, filename) logger.info('Wrote data for %s to %s', joint, filename) heading = ['rx', 'ry', 'rz', 'rw', 'tx', 'ty', 'tz'] verts = joint_map[joints.index(joint)] for v in verts: heading.extend(['vtx%sx' % v, 'vtx%sy' % v, 'vtx%sz' % v]) with open(filename, 'w') as f: writer = csv.writer(f) writer.writerow(heading) writer.writerows(data) csv_files.append(filename) mc.currentTime(currentTime) map_data = { 'joint_names': joints, 'joint_indexes': [i for i in influence_indexes], 'weights': weight_map, 'csv_files': csv_files, 'joint_map': joint_map, 'input_fields': ['rx', 'ry', 'rz', 'rw', 'tx', 'ty', 'tz'] } # Finally write out the data map_file = os.path.join(outdir, 'input_data.json') with open(map_file, 'w') as f: json.dump(map_data, f) logger.info('Wrote Weight Map to %s', map_file) return outdir
from maya import cmds # extraction des position des différents objets dans la l'espace # extraction _L_shoulder_JNT _L_shoulder_JNT_point = cmds.xform('_L_shoulder_JNT', q=True, ws=True, t=True) # extraction _L_elbow_JNT _L_elbow_JNT_point = cmds.xform('_L_elbow_JNT', q=True, ws=True, t=True) # extraction _L_wrist_JNT _L_wrist_JNT_point = cmds.xform('_L_wrist_JNT', q=True, ws=True, t=True) ### VECTOR # import du module OpenMaya from maya.api import OpenMaya # convertion des listes de point en objet de type MVector _L_shoulder_JNT_mVector = OpenMaya.MVector(_L_shoulder_JNT_point) _L_elbow_JNT_mVector = OpenMaya.MVector(_L_elbow_JNT_point) _L_wrist_JNT_mVector = OpenMaya.MVector(_L_wrist_JNT_point) # calcul du vecteur qui part du coude vers l'épaule. _L_upperArm_vect = _L_shoulder_JNT_mVector - _L_elbow_JNT_mVector _L_upperArm_vect = _L_upperArm_vect.normal() # calcul du vecteur qui part du coude vers le poignée _L_lowerArm_vect = _L_wrist_JNT_mVector - _L_elbow_JNT_mVector _L_lowerArm_vect = _L_lowerArm_vect.normal() # calcul du vecteur qui part de l'épaule vers le coude. _L_shoulder_vect = _L_elbow_JNT_mVector - _L_shoulder_JNT_mVector _L_shoulder_vect = _L_shoulder_vect.normal()
def _GetDepNode(name): selectionList = OM.MSelectionList() selectionList.add(name) return OM.MFnDependencyNode(selectionList.getDependNode(0))
def get_anim_curves_from_objects(nodes): """ Gets the animation curves connected to nodes. :param nodes: List with MFnDependencyNode :type nodes: list of om.MFnDependencyNode :return: Tuple of curves and plugs :rtype: (list of om.MFnDependencyNode, list of om.MPlug) """ curves = [] plugs = [] channelbox_attr = get_channelbox_attributes() animlayers.cache.reset( ) # always reset cache before querying for animation layers! has_anim_layers = animlayers.has_anim_layers() if has_anim_layers and animlayers.all_layers_locked(): cmds.warning('All animation layers are locked!') # get curves for node in nodes: # get all attributes attr_count = node.attributeCount() for index in range(attr_count): attr = node.attribute(index) plug = node.findPlug(attr, True) if plug.isLocked or not plug.isKeyable: continue connections = plug.connectedTo(True, False) # if the attribute has a connection if connections: conn_node = connections[0].node() api = conn_node.apiType() if api in ANIM_CURVE_TYPES: # filter out attributes not selected in channelbox if channelbox_attr: attr_name = om.MFnAttribute(attr).shortName if attr_name not in channelbox_attr: continue # add the node if it matches one of the types we want curves.append(om.MFnDependencyNode(conn_node)) plugs.append(plug) # find curve in animation layer elif has_anim_layers and api in animlayers.BLEND_NODE_TYPES: # filter out attributes not selected in channelbox if channelbox_attr: attr_name = om.MFnAttribute(attr).shortName if attr_name not in channelbox_attr: continue # for testing purposes # print('Attribute: %s' % plug) # benchmark_start = time.clock() best_layer = animlayers.get_best_layer(plug) if not best_layer: continue # for testing purposes # try: # print('-> Best layer is %s' % (om.MFnDependencyNode(best_layer).name())) # except Exception as e: # pass curve_node = animlayers.get_anim_curve(plug, best_layer) # animlayers.cache.benchmark += time.clock() - benchmark_start if curve_node: curves.append(om.MFnDependencyNode(curve_node)) plugs.append(plug) # sys.stdout.write('# Retrieved %d curves in %.4f sec\n' % (len(curve_list), animlayers.cache.benchmark)) return curves, plugs
def _isValid(self, obj): '''Check if obj is a valid object to send notifications for.''' return OpenMaya.MObjectHandle(obj).hashCode( ) not in self._aboutToCreate and utils.canOverrideNode(obj)
def get_mobject(node): sel = om2.MSelectionList() sel.add(node) return sel.getDependNode(0)
def _nodeAddedCB(self, obj, clientData): self._aboutToCreate.difference_update( (OpenMaya.MObjectHandle(obj).hashCode(), )) if not utils.canOverrideNode(obj): return self._notifyObservers(eventType=SceneObservable.NODE_ADDED, obj=obj)
def isSceneRoot(node): fn = om2.MFnDagNode(node) return fn.object().hasFn(om2.MFn.kDagNode) and fn.name() == "world"
def _beforeLoadReferenceCB(self, referenceNode, resolvedRefPath, clientData): self._notifyObservers( eventType=SceneObservable.BEFORE_REFERENCE_LOAD, referenceNode=OpenMaya.MFnReference(referenceNode).name(), resolvedRefPath=resolvedRefPath.expandedFullName())
def isValidMObject(node): mo = om2.MObjectHandle(node) if not mo.isValid() or not mo.isAlive(): return False return True
def _afterUnloadReferenceCB(self, referenceNode, resolvedRefPath, clientData): self._notifyObservers( eventType=SceneObservable.REFERENCE_UNLOADED, referenceNode=OpenMaya.MFnReference(referenceNode).name(), resolvedRefPath=resolvedRefPath.expandedFullName())
def decomposeMatrix(matrix, rotationOrder, space=om2.MSpace.kWorld): transformMat = om2.MTransformationMatrix(matrix) rotation = transformMat.rotation() rotation.reorderIt(rotationOrder) return transformMat.translation(space), rotation, transformMat.scale(space)
def getUVs(geoName='', multiOnly=True): """ Function to get as much info about the mesh uvs for use later on as possible """ ### Create dictionary for storing final uv data #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('geoName:', geoName), verbose = False) uvSetData = {} shapeFn = None ## Full path to the geo for writing out later. fullPathToName = cmds.ls(geoName, l=True)[0] #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('fullPathToName:', fullPathToName), verbose = False) ## make sure this is a mesh getChildren = cmds.listRelatives(fullPathToName, children=True)[0] #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('getChildren:', getChildren), verbose = False) if getChildren: #debug(None, method = 'uv_getUVs.getUVs', message = 'Shape has a child...', verbose = False) if cmds.nodeType(getChildren) == 'mesh': selectionList = om.MSelectionList() selectionList.add(fullPathToName) nodeDagPath = selectionList.getDagPath(0) shapeFn = om.MFnMesh(nodeDagPath) ## Now fetch data from shapeFn shapeName = shapeFn.name() #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('shapeName:', shapeName), verbose = False) currentUVSets = shapeFn.getUVSetNames() ## Now we find the UV sets for the mesh into a valid list. ## We're looking through each face to see what uvSets are assigned to them to find valid uv sets. uvsets = _getUVSets( shapeFn ) ### VALID UV SETS WILL BE RETURNED IF THE ARTIST HAS CREATED AN EMPTY UV SET IT WILL BE DISCARDED #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('uvSets:', uvsets), verbose = False) ## Check to see if the flag for mult uv sets only is on if multiOnly: if len(uvsets) > 1: export = True else: export = False else: export = True if export: debug(None, method='uv_getUVs.getUVs', message='{0:<10}{1}'.format('Processing: ', geoName), verbose=False) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('len(currentUVSets): ', len(currentUVSets)), verbose = False) for eachUVSet in uvsets: data = [] ## Add the uvset name.... shapeFn.setCurrentUVSetName(eachUVSet) ## Add the path to the geo ## Returns |path|to|geo data.extend([fullPathToName]) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('fullPathToName:', fullPathToName), verbose = False) ## Add the name ## Returns nameofUvSet data.extend([eachUVSet]) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('uvSetName:', eachUVSet), verbose = False) ## Add the u and v from the straight foward fetch ## Returns [uArray], [vArray] getUVArrays = _getUandV(shapeFn, eachUVSet) data.extend([getUVArrays[0]]) data.extend([getUVArrays[1]]) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('getUVArraysU:', getUVArrays[0]), verbose = False) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('getUVArraysV:', getUVArrays[1]), verbose = False) ## Get the perFace info in case we need it for rebuilding later ## Returns {faceId: [myVertixIntArray, myUVID_IntArray]} faceUVInfo = _getPerFaceUVInfo(shapeFn, eachUVSet) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('faceUVInfo:', faceUVInfo), verbose = False) data.extend([faceUVInfo]) ## Add the num of uvshells and the shell list ## Returns (shellCount, [vertIndexShellAssociationList]), {shell: [shellUVs]}, [ShellUVsCount] #getShells = _getUVShells(shapeFn, eachUVSet, faceUVInfo) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('getShells:', getShells), verbose = False) #data.extend([getShells]) ## The uvName index #print 'processing uvindex for %s' % eachUVSet data.extend([ _uvMapIndex(pathToGeo=fullPathToName, mapName=eachUVSet) ]) #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('mapIndex:', _uvMapIndex(eachUVSet)), verbose = False) uvSetData[eachUVSet] = data #debug(None, method = 'uv_getUVs.getUVs', message = '{0:<10}{1}'.format('uvSetData:', uvSetData), verbose = False) ## Forcing this back to map1 to see if I can avoid crashes shapeFn.setCurrentUVSetName('map1') #print 'Data stored for %s' % geoName if uvSetData: return [geoName, uvSetData] else: return None