Python maya.OpenMaya.MDoubleArray() Examples
The following are 17
code examples of maya.OpenMaya.MDoubleArray().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.OpenMaya
, or try the search function
.
Example #1
Source File: skin.py From mgear_core with MIT License | 6 votes |
def getCurrentWeights(skinCls, dagPath, components): """Get the skincluster weights Arguments: skinCls (PyNode): The skincluster node dagPath (MDagPath): The skincluster dagpath components (MObject): The skincluster components Returns: MDoubleArray: The skincluster weights """ weights = OpenMaya.MDoubleArray() util = OpenMaya.MScriptUtil() util.createFromInt(0) pUInt = util.asUintPtr() skinCls.__apimfn__().getWeights(dagPath, components, weights, pUInt) return weights ###################################### # Skin Collectors ######################################
Example #2
Source File: skin.py From mgear_core with MIT License | 6 votes |
def setBlendWeights(skinCls, dagPath, components, dataDic, compressed): if compressed: # The compressed format skips 0.0 weights. If the key is empty, # set it to 0.0. JSON keys can't be integers. The vtx number key # is unicode. example: vtx[35] would be: u"35": 0.6974, # But the binary format is still an int, so cast the key to int. blendWeights = OpenMaya.MDoubleArray(dataDic['vertexCount']) for key, value in dataDic['blendWeights'].items(): blendWeights.set(value, int(key)) else: # The original weight format was a full list for every vertex # For backwards compatibility on older skin files: blendWeights = OpenMaya.MDoubleArray(len(dataDic['blendWeights'])) for ii, w in enumerate(dataDic['blendWeights']): blendWeights.set(w, ii) skinCls.__apimfn__().setBlendWeights(dagPath, components, blendWeights)
Example #3
Source File: skin.py From maya-skinning-tools with GNU General Public License v3.0 | 6 votes |
def getSkinWeights(dag, skinCluster, component): """ Get the skin weights of the original vertex and of its connected vertices. :param OpenMaya.MDagPath dag: :param OpenMayaAnim.MFnSkinCluster skinCluster: :param OpenMaya.MFn.kMeshVertComponent component: :return: skin weights and number of influences :rtype: tuple(OpenMaya.MDoubleArray, int) """ # weights variables weights = OpenMaya.MDoubleArray() # influences variables influenceMSU = OpenMaya.MScriptUtil() influencePTR = influenceMSU.asUintPtr() # get weights skinCluster.getWeights(dag, component, weights, influencePTR) # get num influences num = OpenMaya.MScriptUtil.getUint(influencePTR) return weights, num
Example #4
Source File: fnData.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 6 votes |
def getWeightData(self, elements): """ Args: elements (list) Returns: SkinWeightData """ dagPath, components = utils.getDagPathComponents(elements) # Get all influences infs = self.listInfluences(asDagPath=False) influenceIndices = om.MIntArray() [influenceIndices.append(self.getPhysicalInfluenceIndex(inf)) for inf in infs] # Get all weights weights = om.MDoubleArray() self.fn.getWeights(dagPath, components, influenceIndices, weights) weights = [w for w in weights] return SkinWeightData(elements, infs, weights) #----------------------------------------------------------------------
Example #5
Source File: fnData.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setWeightData(self, data, normalize=True): """ Args: data (SkinWeightData) normalize (bool, Optional): Defaults to True """ # Construct dagPath and components compList = data.getComponents() dagPath, components = utils.getDagPathComponents(compList) # Construct influence indices influenceIndices = om.MIntArray() [influenceIndices.append(self.getPhysicalInfluenceIndex(inf)) for inf in data.getInfluences()] # Construct weights weights = om.MDoubleArray() [weights.append(w) for w in data.getWeights()] oldValues = om.MDoubleArray() self.fn.getWeights(dagPath, components, influenceIndices, oldValues) self.fn.setWeights(dagPath, components, influenceIndices, weights, normalize, oldValues) #----------------------------------------------------------------------
Example #6
Source File: fnData.py From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License | 5 votes |
def getInfluenceData(self, influence): """ Args: influence (str) Returns: WeightData """ try: dagPath = utils.getDagPath(influence) except: raise utils.UserInputError("Could not find influence '%s' in %s" % (influence, self.skinCluster)) selList = om.MSelectionList() weights = om.MDoubleArray() self.fn.getPointsAffectedByInfluence(dagPath, selList, weights) componentStr = [] selList.getSelectionStrings(componentStr) componentStr = cmds.ls(componentStr, ap=1, fl=1) weights = [w for w in weights] return WeightData(componentStr, weights) #----------------------------------------------------------------------
Example #7
Source File: weight_transfer_multiple.py From SIWeightEditor with MIT License | 5 votes |
def init_bake_data(self): if MAYA_VER >= 2016: self.bake_node_id_dict = defaultdict(lambda : om2.MIntArray()) self.bake_node_weight_dict = defaultdict(lambda : om2.MDoubleArray()) self.bake_node_inf_dict = defaultdict(lambda : om2.MIntArray()) self.org_node_weight_dict = defaultdict(lambda : om2.MDoubleArray()) else: self.bake_node_id_dict = defaultdict(lambda : om.MIntArray()) self.bake_node_weight_dict = defaultdict(lambda : om.MDoubleArray()) self.bake_node_inf_dict = defaultdict(lambda : om.MIntArray()) self.org_node_weight_dict = defaultdict(lambda : om.MDoubleArray()) self.undo_node_weight_dict = defaultdict(lambda : []) self.redo_node_weight_dict = defaultdict(lambda : []) #部分転送
Example #8
Source File: skinio.py From cmt with MIT License | 5 votes |
def set_blend_weights(self, dag_path, components): """Set the blendWeights. :param dag_path: MDagPath of the deformed geometry. :param components: Component MObject of the deformed components. """ elements = OpenMaya.MIntArray() fncomp = OpenMaya.MFnSingleIndexedComponent(components) fncomp.getElements(elements) blend_weights = OpenMaya.MDoubleArray(elements.length()) for i in range(elements.length()): blend_weights.set(self.data["blendWeights"][elements[i]], i) self.fn.setBlendWeights(dag_path, components, blend_weights)
Example #9
Source File: skinio.py From cmt with MIT License | 5 votes |
def set_influence_weights(self, dag_path, components): """Sets all the influence weights. :param dag_path: MDagPath of the deformed geometry. :param components: Component MObject of the deformed components. """ influence_paths = OpenMaya.MDagPathArray() influence_count = self.fn.influenceObjects(influence_paths) elements = OpenMaya.MIntArray() fncomp = OpenMaya.MFnSingleIndexedComponent(components) fncomp.getElements(elements) weights = OpenMaya.MDoubleArray(elements.length() * influence_count) components_per_influence = elements.length() for imported_influence, imported_weights in self.data["weights"].items(): imported_influence = imported_influence.split("|")[-1] for ii in range(influence_paths.length()): influence_name = influence_paths[ii].partialPathName() influence_without_namespace = shortcuts.remove_namespace_from_name( influence_name ) if influence_without_namespace == imported_influence: # Store the imported weights into the MDoubleArray for jj in range(components_per_influence): weights.set(imported_weights[elements[jj]], jj * influence_count + ii) break influence_indices = OpenMaya.MIntArray(influence_count) for ii in range(influence_count): influence_indices.set(ii, ii) self.fn.setWeights(dag_path, components, influence_indices, weights, False)
Example #10
Source File: skinio.py From cmt with MIT License | 5 votes |
def __get_current_weights(self, dag_path, components): """Get the current skin weight array. :param dag_path: MDagPath of the deformed geometry. :param components: Component MObject of the deformed components. :return: An MDoubleArray of the weights. """ weights = OpenMaya.MDoubleArray() util = OpenMaya.MScriptUtil() util.createFromInt(0) ptr = util.asUintPtr() self.fn.getWeights(dag_path, components, weights, ptr) return weights
Example #11
Source File: skinio.py From cmt with MIT License | 5 votes |
def gather_blend_weights(self, dag_path, components): """Gathers the blendWeights :param dag_path: MDagPath of the deformed geometry. :param components: Component MObject of the deformed components. """ weights = OpenMaya.MDoubleArray() self.fn.getBlendWeights(dag_path, components, weights) self.data["blendWeights"] = [weights[i] for i in range(weights.length())]
Example #12
Source File: spore_sampler.py From spore with MIT License | 5 votes |
def __init__(self): self.position = om.MPointArray() self.normal = om.MVectorArray() self.poly_id = om.MIntArray() self.u_coord = [] # om.MDoubleArray() self.v_coord = [] # om.MDoubleArray()
Example #13
Source File: skin.py From mgear_core with MIT License | 5 votes |
def collectBlendWeights(skinCls, dagPath, components, dataDic): weights = OpenMaya.MDoubleArray() skinCls.__apimfn__().getBlendWeights(dagPath, components, weights) # round the weights down. This should be safe on Dual Quat blends # because it is not normalized. And 6 should be more than accurate enough. dataDic['blendWeights'] = { i: round(weights[i], 6) for i in range(weights.length()) if round(weights[i], 6) != 0.0 }
Example #14
Source File: ptc_cache.py From spore with MIT License | 5 votes |
def get_points(self): """ return all points from the cache :return: MPointArray - list of all point positions MVectorArray - list of all normals MIntArray - list of all polygon ids MDoubleArray - list of all u_coordinates MDoubleArray - list of all v coordinates """ return self.points, self.normals, self.poly_ids, self.u_coords, self.v_coords, self.user
Example #15
Source File: ptc_cache.py From spore with MIT License | 5 votes |
def __init__(self): self._locked = False # sampled data from the ptc self.points = om.MPointArray() self.normals = om.MVectorArray() self.poly_ids = om.MIntArray() self.u_coords = om.MDoubleArray() self.v_coords = om.MDoubleArray() self.user = [] self.bb = None
Example #16
Source File: instance_data.py From spore with MIT License | 5 votes |
def __init__(self, node): log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL'] self.logger = logging_util.SporeLogger(__name__, log_lvl) dg_fn = om.MFnDependencyNode(node) self.node_name = dg_fn.name() self.node = node # TODO - hold on to selection list instead of mobj # self.bounding_box = None self.state = None self.data_plug = om.MPlug() self.data_object = om.MObject() # instance data attributes self.position = om.MVectorArray() self.scale = om.MVectorArray() self.rotation = om.MVectorArray() self.instance_id = om.MIntArray() self.visibility = om.MIntArray() self.normal = om.MVectorArray() self.tangent = om.MVectorArray() self.u_coord = om.MDoubleArray() self.v_coord = om.MDoubleArray() self.poly_id = om.MIntArray() self.color = om.MVectorArray() self.unique_id = om.MIntArray() self.exclusive_paint = [] # collect points for kd tree self.np_position = np.empty((0,3), float) self.tree = None self.logger.info('Instanciate new InstanceData object for: {}'.format(self.node_name))
Example #17
Source File: spore_context.py From spore with MIT License | 5 votes |
def __init__(self): ompx.MPxToolCommand.__init__(self) self.setCommandString(K_TOOL_CMD_NAME) K_TRACKING_DICTIONARY[ompx.asHashable(self)] = self log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL'] self.logger = logging_util.SporeLogger(__name__, log_lvl) self.brush_state = None self.instance_data = None self.last_brush_position = None self.last_undo_journal = '' self.last_count = 0 self.last_state = {} self.next_redo_journal = '' self.position = om.MVectorArray() self.scale = om.MVectorArray() self.rotation = om.MVectorArray() self.instance_id = om.MIntArray() self.visibility = om.MIntArray() self.normal = om.MVectorArray() self.tangent = om.MVectorArray() self.u_coord = om.MDoubleArray() self.v_coord = om.MDoubleArray() self.poly_id = om.MIntArray() self.color = om.MVectorArray() self.point_id = om.MIntArray() self.initial_rotation = om.MVectorArray() self.initial_scale = om.MVectorArray() self.initial_offset = om.MDoubleArray() self.initial_id = om.MIntArray() self.spray_coords = []