Beispiel #1
0
    def test_rebuildJoints(self):
        """
        Test that a set of rebuilt joints have the same rotate, orient, and scale
        as they did when originally built
        """
        info = {}
        preJointAttrs = []
        postJointAttrs = []
        for j in self.jnts:
            control.setStorableXformAttrs(j, worldSpace=True)
            info[j] = control.getStorableXformInfo(j)

            attrs = {}
            attrs['r'] = MC.getAttr('%s.r' % j)[0]
            attrs['t'] = MC.getAttr('%s.t' % j)[0]
            attrs['s'] = MC.getAttr('%s.s' % j)[0]
            attrs['o'] = MC.getAttr('%s.jointOrient' % j)[0]
            preJointAttrs.append(attrs)

        MC.delete(self.jnts)

        #first build nodes
        for jnt in self.jnts:
            control.makeStorableXform(jnt, createNodeOnly=True, **info[jnt])
        #now parent and apply attrs
        for j in self.jnts:
            control.makeStorableXform(j, **info[j])
            attrs = {}
            attrs['r'] = MC.getAttr('%s.r' % j)[0]
            attrs['t'] = MC.getAttr('%s.t' % j)[0]
            attrs['s'] = MC.getAttr('%s.s' % j)[0]
            attrs['o'] = MC.getAttr('%s.jointOrient' % j)[0]
            postJointAttrs.append(attrs)


        for i, jnt in enumerate(self.jnts):
            preAttrs = preJointAttrs[i]
            postAttrs = postJointAttrs[i]
            for attr in ['r', 't', 's', 'o']:
                for j in range(3):
                    self.assertAlmostEqual(preAttrs[attr][j],
                                           postAttrs[attr][j])

            m = MC.xform(jnt, q=1, ws=1, m=1)
            for j in range(len(m)):
                self.assertAlmostEqual(m[j], info[jnt]['matrix'][j])
Beispiel #2
0
    def test_getXformArgs(self):
        xform = control.makeStorableXform('myXform')
        t = [1,2,3]
        r = [10,20,30]
        s = [1.1, 2.2, 3.3]

        MC.setAttr('%s.t' % xform, *t, type='double3')
        MC.setAttr('%s.r' % xform, *r, type='double3')
        MC.setAttr('%s.s' % xform, *s, type='double3')

        result = control.getStorableXformInfo(xform)

        xform2 = control.makeStorableXform('myXform2', **result)
        for i in range(3):
            self.assertTrue(MC.getAttr('%s.t' % xform2)[0][i] - tuple(t)[i] < .0001)
            self.assertTrue(MC.getAttr('%s.r' % xform2)[0][i] - tuple(r)[i] < .0001)
            self.assertTrue(MC.getAttr('%s.s' % xform2)[0][i] - tuple(s)[i] < .0001)
Beispiel #3
0
    def test_makeStorableXformCtl(self):
        xform1 = control.makeStorableXform('myXform_a')
        xform2 = control.makeStorableXform('myXform_b', nodeType='joint')
        xform3 = control.makeStorableXform('myXform_c', nodeType='joint', parent=xform2)
        control.makeControl(xform1)
        control.makeControl(xform2)
        control.makeControl(xform3)

        info1 = control.getStorableXformInfo(xform1)
        info2 = control.getStorableXformInfo(xform2)
        info3 = control.getStorableXformInfo(xform3)

        MC.delete(xform1)
        MC.delete(xform2)

        control.makeStorableXform(xform1, **info1)
        control.makeStorableXform(xform2, **info2)
        control.makeStorableXform(xform3, **info3)
Beispiel #4
0
    def test_worldSpaceArgsExisting(self):
        xform = control.makeStorableXform('myXform')
        t = [1,2,3]
        r = [10,20,30]
        s = [1.1, 2.2, 3.3]

        MC.setAttr('%s.t' % xform, *t, type='double3')
        MC.setAttr('%s.r' % xform, *r, type='double3')
        MC.setAttr('%s.s' % xform, *s, type='double3')

        xform2 = control.makeStorableXform('myXform_b', parent=xform, worldSpace=True)
        MC.setAttr('%s.t' % xform2, *t, type='double3')
        MC.setAttr('%s.r' % xform2, *r, type='double3')
        MC.setAttr('%s.s' % xform2, *s, type='double3')

        result = control.getStorableXformInfo(xform2)
        MC.createNode('transform', name='myXform_c')
        xform3 = control.makeStorableXform('myXform_c', **result)
        for i in range(3):
            self.assertTrue(MC.getAttr('%s.t' % xform3)[0][i] - tuple(t)[i] < .0001)
            self.assertTrue(MC.getAttr('%s.r' % xform3)[0][i] - tuple(r)[i] < .0001)
            self.assertTrue(MC.getAttr('%s.s' % xform3)[0][i] - tuple(s)[i] < .0001)
Beispiel #5
0
 def test_makeStorableXform(self):
     xform = control.makeStorableXform('myXform_a')
     xform2 = control.makeStorableXform('myXform_b', nodeType='joint')
     xform3 = control.makeStorableXform('myXform_c', nodeType='joint', parent=xform2)