def setup(self): """creates the setup """ from anima.env.mayaEnv import auxiliary vtx_coord = pm.xform(self.pin_to_vertex, ws=1, t=1) self.pin_to_shape = self.pin_to_vertex.node() self.pin_uv = self.pin_to_shape.getUVAtPoint(vtx_coord, space='world') # create a sphere with the size of pin_size self.pin_transform, self.pin_shape = pm.sphere(radius=self.size) # create two axial correction groups self.compensation_group = \ auxiliary.axial_correction_group(self.pin_node) self.axial_correction_group = \ auxiliary.axial_correction_group(self.compensation_group) # create compensation setup decompose_matrix = pm.nt.DecomposeMatrix() self.pin_transform.inverseMatrix >> decompose_matrix.inputMatrix decompose_matrix.outputTranslate >> self.compensation_group.t decompose_matrix.outputRotate >> self.compensation_group.r decompose_matrix.outputScale >> self.compensation_group.s # create a follicle on the shape at the given uv self.follicle_transform, self.follicle_shape = \ auxiliary.create_follicle(self.pin_to_shape, self.pin_uv) # move the axial correction group pm.xform(self.axial_correction_group, ws=1, t=vtx_coord)
def create_constrained_parent(self): """creates parents for the object """ # check if there is a stabilizerParent try: pm.nodetypes.DagNode(self._stabilizer_parent) except pm.MayaNodeError: return self._constrained_parent = pm.nodetypes.DagNode( auxiliary.axial_correction_group(self._stabilizer_parent)) self._constrained_parent = pm.nodetypes.DagNode( pm.rename(self._constrained_parent, self._object.name() + "_constrained_parent")) index = self._object.attr('pickedData.createdNodes').numElements() self._constrained_parent.attr('message') >> \ self._object.attr('pickedData.createdNodes[' + str(index) + ']')
def create_stabilizer_parent(self): """creates the stabilizer parent """ # the new stabilizer parent should be at the origin of the original # objects parent so that the keyframes of the object should not be altered self._stabilizer_parent = pm.nodetypes.DagNode( auxiliary.axial_correction_group(self._object, to_parents_origin=True)) self._stabilizer_parent = pm.nodetypes.DagNode( pm.rename(self._stabilizer_parent, self._object.name() + "_stabilizer_parent")) # connect it to the created nodes attribute index = self._object.attr('pickedData.createdNodes').numElements() self._stabilizer_parent.attr('message') >> \ self._object.attr('pickedData.createdNodes[' + str(index) + ']')
def axial_correction_group(cls): selection = pm.ls(sl=1) for item in selection: auxiliary.axial_correction_group(item)
def setup(self): """creates the setup """ from anima.env.mayaEnv import auxiliary vtx_coord = pm.xform(self.pin_to_vertex, q=1, ws=1, t=1) self.pin_to_shape = self.pin_to_vertex.node() self.pin_uv = self.pin_to_shape.getUVAtPoint(vtx_coord, space='world', uvSet='map1') # create a sphere with the size of pin_size self.pin_transform, make_nurbs_node = pm.sphere(radius=self.size) self.pin_transform.rename("%s#" % self.pin_name_prefix) self.pin_shape = self.pin_transform.getShape() # create two axial correction groups self.compensation_group = \ auxiliary.axial_correction_group(self.pin_transform) self.compensation_group.rename("%s_CompensationGrp" % self.pin_transform.name()) self.axial_correction_group = \ auxiliary.axial_correction_group(self.compensation_group) # create compensation setup decompose_matrix = pm.nt.DecomposeMatrix() self.pin_transform.inverseMatrix >> decompose_matrix.inputMatrix decompose_matrix.outputTranslate >> self.compensation_group.t decompose_matrix.outputRotate >> self.compensation_group.r decompose_matrix.outputScale >> self.compensation_group.s # limit movement # set the transform limit of the pin to [-1, 1] range pm.transformLimits( self.pin_transform, tx=[-1, 1], etx=[1, 1], ty=[-1, 1], ety=[1, 1], tz=[-1, 1], etz=[1, 1], ) # create a follicle on the shape at the given uv self.follicle_transform, self.follicle_shape = \ auxiliary.create_follicle(self.pin_to_shape, self.pin_uv) self.follicle_transform.rename("%s_Follicle" % self.pin_transform.name()) # move the axial correction group pm.xform(self.axial_correction_group, ws=1, t=vtx_coord) # parent the axial correction group to the follicle pm.parent(self.axial_correction_group, self.follicle_transform) # hide the follicle shape self.follicle_shape.v.set(0) # assign shader shader = self.get_pin_shader() shading_engine = shader.outputs(type='shadingEngine')[0] pm.sets("initialShadingGroup", rm=self.pin_shape) pm.sets(shading_engine, fe=self.pin_shape)