Ejemplo n.º 1
0
    def UnapplySchema(self, dgModifier):
        if self.GetMayaObjectForSchema() is None:
            # Already unapplied?
            return False

        path = om.MDagPath.getAPathTo(self.mayaObject)
        if not path or not path.pop():
            return False

        BulletUtils.checkPluginLoaded()
        BulletUtils.removeBulletObjectsFromList([path.fullPathName()])

        return self.GetMayaObjectForSchema() is None
Ejemplo n.º 2
0
	def addToRigidSet( *args, **kw ):
		rbSets = _findRigidSetsFromSelection(excludeTransforms=True)

		if len(rbSets)>1:
			OpenMaya.MGlobal.displayError(maya.stringTable['y_RigidBody.kAmbiguousAddToSet' ])
			return 

		if len(rbSets)==0:
			OpenMaya.MGlobal.displayError(maya.stringTable['y_RigidBody.kNoRigidSetToAddSelected' ])
			return 

		addObjects = kw['members'] if kw.has_key('members') else maya.cmds.ls(sl=True, type='transform')
		hideShape = kw['hideShape'] if kw.has_key('hideShape') else True

		# filter out objects with rigid body shapes
		filteredAddObjects = []
		bulletObjects = []

		for object in addObjects:
			if BulletUtils.getRigidBodyFromTransform(object):
				OpenMaya.MGlobal.displayInfo(maya.stringTable['y_RigidBody.kAlreadyRigidBody' ].format(object))
				bulletObjects.append(object)
			else:
				filteredAddObjects.append(object)
		
		# ensure exclusive
		if len(filteredAddObjects):
			CreateRigidSet.removeFromRigidSet(members=filteredAddObjects, excludeSets=rbSets)

		# remove bullet rigid shape from objects
		if len(bulletObjects):
			BulletUtils.removeBulletObjectsFromList(bulletObjects)
			filteredAddObjects.extend( bulletObjects )

		if len(filteredAddObjects):
			maya.cmds.sets( filteredAddObjects, e=True, addElement=rbSets[0] )
			if hideShape:
				BulletUtils.setAsIntermediateObjects( filteredAddObjects, 1, deferred=True )