def test_apply_dict(self):
        # New scene
        pm.newFile(f=True)

        # Create plane and ncloth
        self.plane = pm.polyPlane()[0]
        pm.select(self.plane, r=1)

        nClothCreate()

        self.ncloth = pm.PyNode('nCloth1')
        self.nucleus = pm.PyNode('nucleus1')

        d = {'bounce': 3.0, 'evaluationOrder': 1}

        ims.apply_dict(self.ncloth, d)

        self.assertEqual(self.ncloth.getShape().bounce.get(), 3.0)
        self.assertEqual(self.ncloth.getShape().evaluationOrder.get(), 1)

        d = {'planeNormal': (0.0, 0.0, 1.0)}

        ims.apply_dict(self.nucleus, d)

        self.assertEqual(self.nucleus.planeNormal.get(), (0.0, 0.0, 1.0))
    def test_apply_dict(self):
        # New scene
        pm.newFile(f=True)

        # Create plane and ncloth
        self.plane = pm.polyPlane()[0]
        pm.select(self.plane, r=1)

        nClothCreate()

        self.ncloth = pm.PyNode('nCloth1')
        self.nucleus = pm.PyNode('nucleus1')

        d = {'bounce': 3.0,
             'evaluationOrder': 1}

        ims.apply_dict(self.ncloth, d)

        self.assertEqual(self.ncloth.getShape().
                         bounce.get(), 3.0)
        self.assertEqual(self.ncloth.getShape().
                         evaluationOrder.get(), 1)

        d = {'planeNormal': (0.0, 0.0, 1.0)}

        ims.apply_dict(self.nucleus, d)

        self.assertEqual(self.nucleus.planeNormal.get(), (0.0, 0.0, 1.0))
Esempio n. 3
0
	def __new__(cls, transform, **kwargs):
		if not isinstance(transform, Transform):
			transform = transform.getParent()
		select(transform, replace=True)
		nClothCreate()
		shape = selected()[0]
		nc_xform = shape.getParent()
		rename(nc_xform, transform.namespace() + 'snCloth' + \
			_util.capitalize(transform.name().split(':')[-1]))
		shape.__class__ = cls
		return shape
Esempio n. 4
0
 def __new__(cls, transform, **kwargs):
     if not isinstance(transform, Transform):
         transform = transform.getParent()
     select(transform, replace=True)
     nClothCreate()
     shape = selected()[0]
     nc_xform = shape.getParent()
     rename(nc_xform, transform.namespace() + 'snCloth' + \
      _util.capitalize(transform.name().split(':')[-1]))
     shape.__class__ = cls
     return shape
    def setUp(self):
        # New scene
        pm.newFile(f=True)

        # Get ncloth attributes from file
        self.ncloth_attrs = []
        self.ncloth_attrsFile = os.path.dirname(__file__).\
            replace('tests', 'tool')
        self.ncloth_attrsFile = self.ncloth_attrsFile + \
            os.sep + 'ncloth_attrs.txt'

        if not os.path.exists(self.ncloth_attrsFile):
            msg = 'File not found: ', self.ncloth_attrsFile
            raise Exception(msg)

        f = open(self.ncloth_attrsFile, 'r')
        self.ncloth_attrs = f.readlines()
        f.close()

        # Get nucleus attributes from file
        self.nucleus_attrs = []
        self.nucleus_attrsFile = os.path.dirname(__file__).\
            replace('tests', 'tool')
        self.nucleus_attrsFile = self.nucleus_attrsFile + \
            os.sep + 'nucleus_attrs.txt'

        if not os.path.exists(self.nucleus_attrsFile):
            msg = 'File not found: ', self.nucleus_attrsFile
            raise Exception(msg)

        f = open(self.nucleus_attrsFile, 'r')
        self.nucleus_attrs = f.readlines()
        f.close()

        # Create plane and ncloth
        self.plane = pm.polyPlane()[0]
        pm.select(self.plane, r=1)

        nClothCreate()

        self.ncloth = pm.PyNode('nCloth1')
        self.nucleus = pm.PyNode('nucleus1')

        # Create expected name
        now = datetime.now()
        self.name = self.ncloth.name() + '_' + \
            str(now.year) + '-' + str(now.month) + '-' + \
            str(now.day) + '_' + \
            str(now.hour) + '-' + str(now.minute)
Esempio n. 6
0
    def setUp(self):
        # New scene
        pm.newFile(f=True)

        # Get ncloth attributes from file
        self.ncloth_attrs = []
        self.ncloth_attrsFile = os.path.dirname(__file__).\
            replace('tests', 'tool')
        self.ncloth_attrsFile = self.ncloth_attrsFile + \
            os.sep + 'ncloth_attrs.txt'

        if not os.path.exists(self.ncloth_attrsFile):
            msg = 'File not found: ', self.ncloth_attrsFile
            raise Exception(msg)

        f = open(self.ncloth_attrsFile, 'r')
        self.ncloth_attrs = f.readlines()
        f.close()

        # Get nucleus attributes from file
        self.nucleus_attrs = []
        self.nucleus_attrsFile = os.path.dirname(__file__).\
            replace('tests', 'tool')
        self.nucleus_attrsFile = self.nucleus_attrsFile + \
            os.sep + 'nucleus_attrs.txt'

        if not os.path.exists(self.nucleus_attrsFile):
            msg = 'File not found: ', self.nucleus_attrsFile
            raise Exception(msg)

        f = open(self.nucleus_attrsFile, 'r')
        self.nucleus_attrs = f.readlines()
        f.close()

        # Create plane and ncloth
        self.plane = pm.polyPlane()[0]
        pm.select(self.plane, r=1)

        nClothCreate()

        self.ncloth = pm.PyNode('nCloth1')
        self.nucleus = pm.PyNode('nucleus1')

        # Create expected name
        now = datetime.now()
        self.name = self.ncloth.name() + '_' + \
            str(now.year) + '-' + str(now.month) + '-' + \
            str(now.day) + '_' + \
            str(now.hour) + '-' + str(now.minute)
Esempio n. 7
0
def make_nCloth(*args, **kwargs):
    '''
    Convert nodes to nCloth objects

    :param args: List of pymel.PyNode transforms
    :param kwargs: nCloth attribute values
    '''

    nodes = args
    kwargs.setdefault('stretchResistance', 20)
    kwargs.setdefault('compressionResistance', 10)
    kwargs.setdefault('bendResistance', 0.6)
    kwargs.setdefault('inputMeshAttract', 1)
    kwargs.setdefault('inputAttractMethod', 1)
    kwargs.setdefault('inputAttractDamp', 0)
    kwargs.setdefault('selfCollisionFlag', 4)
    kwargs.setdefault('thickness', 0.005)
    kwargs.setdefault('pointMass', 100)
    kwargs.setdefault('drag', 0.15)

    # Input attract weight ramp
    ramp = pm.createNode('ramp')
    ramp.colorEntryList[0].color.set(1, 1, 1)
    ramp.colorEntryList[1].position.set(0.1)
    ramp.colorEntryList[1].color.set(0, 0, 0)
    ramp.interpolation.set(0)

    with selection(nodes):
        nClothCreate()
        ncloth_shapes = pm.selected()
        for ncloth in ncloth_shapes:
            for attr, value in kwargs.iteritems():
                ncloth.attr(attr).set(value)
            ramp.outAlpha.connect(ncloth.inputAttractMap)
        ncloth_transforms = [n.getParent() for n in ncloth_shapes]

    return ncloth_shapes, ncloth_transforms