def test_rig_squeeze_facial_new(self): from omtk.modules.rigHead import Head from omtk.modules.rigFaceJaw import FaceJaw from omtk.modules.rigFaceBrow import FaceBrow from omtk.modules.rigFaceSquint import FaceSquint from omtk.modules.rigFaceLips import FaceLips from omtk.modules.rigFaceEyes import FaceEyes from omtk.modules.rigFaceLids import FaceLids from omtk.modules.rigFaceNose import FaceNose pymel.delete(pymel.ls(type='network')) rig = omtk.create() rig.add_module(Head([pymel.PyNode('Head_Jnt')])) rig.add_module(FaceJaw([pymel.PyNode('Jaw_Jnt')])) rig.add_module(FaceBrow(pymel.ls('*_Brow*_Jnt', type='joint'))) rig.add_module(FaceSquint(pymel.ls('*_Squint*_Jnt', type='joint'))) rig.add_module( FaceLips( pymel.ls('*_Lip*_Jnt', type='joint') + pymel.ls('*_Mouth*_Jnt', type='joint'))) rig.add_module( FaceEyes([pymel.PyNode('L_Eye_Jnt'), pymel.PyNode('R_Eye_Jnt')])) rig.add_module(FaceLids(pymel.ls('*_Lid*_Jnt', type='joint'))) rig.add_module(FaceNose(pymel.ls('*Nose*_Jnt', type='joint'))) rig.build(strict=True) libSerialization.export_network(rig)
def test_avar_connection_persistence(self): import omtk from omtk.modules import rigHead from omtk.modules import rigFaceJaw from omtk.modules import rigFaceLips from omtk.libs import libRigging # Create a base rig rig = omtk.create() rig.add_module(rigHead.Head([pymel.PyNode('jnt_head')])) module_jaw = rig.add_module(rigFaceJaw.FaceJaw([pymel.PyNode('jnt_jaw')])) module_lips = rig.add_module(rigFaceLips.FaceLips(pymel.ls('jnt_lip*', type='joint'))) rig.build(strict=True) # Connect some avars avar_src = next(iter(module_jaw.avars), None).attr_ud for avar in module_lips.avars: avar_dst = avar.attr_ud libRigging.connectAttr_withLinearDrivenKeys(avar_src, avar_dst) # Re-build the rig rig.unbuild(strict=True) rig.build(strict=True) # Ensure the avars are still connected. avar_src = next(iter(module_jaw.avars), None).attr_ud avar_src.set(1.0) for avar in module_lips.avars: avar_dst = avar.attr_ud self.assertAlmostEqual(avar_dst.get(), 1.0)
def test_ctrl_space_index_preservation(self): """ Check that after a ctrl have been built once, if we change it's hierarchy's and rebuild it, we will keep the old index. This ensure any rig update will never break an old animation. """ from omtk.modules import rigFK def check_targets_index_match(ctrl): self.assertEqual(len(ctrl.targets), len(ctrl.targets_indexes)) attr_space = ctrl.node.space for target, target_index in attr_space.getEnums().iteritems(): if target == 'Local': continue target = pymel.PyNode(target) self.assertIn(target, ctrl.targets) # Ensure the target is stored logical_index = ctrl.targets.index(target) self.assertEqual(target_index, ctrl.targets_indexes[logical_index]) # Create a simple influence hierarhy inf_a = pymel.createNode('joint') inf_b = pymel.createNode('joint', parent=inf_a) inf_c = pymel.createNode('joint', parent=inf_b) inf_d = pymel.createNode('joint', parent=inf_c) # Create a simple rig r = omtk.create() mod_a = r.add_module(rigFK.FK([inf_a])) mod_b = r.add_module(rigFK.FK([inf_b])) mod_c = r.add_module(rigFK.FK([inf_c])) mod_d = r.add_module(rigFK.FK([inf_d])) # Build the last module mod_d.build() # Analyse the indexes c = mod_d.ctrls[0] old_targets = c.targets old_targets_indexes = c.targets_indexes check_targets_index_match(c) # Unbulid the last module, change the hierarchy and rebuilt it mod_d.unbuild() inf_d.setParent(inf_b) mod_d.build() # Analyse the indexes c = mod_d.ctrls[0] new_targets = c.targets new_targets_indexes = c.targets_indexes check_targets_index_match(c) self.assertListEqual(old_targets, new_targets) self.assertListEqual(old_targets_indexes, new_targets_indexes)
def _create_simple_arm_build_and_export(self): jnt_1 = pymel.joint(position=[0, 0, 0]) jnt_2 = pymel.joint(position=[10, 0, 10]) jnt_3 = pymel.joint(position=[20, 0, 0]) rig = omtk.create() module = Arm([jnt_1, jnt_2, jnt_3]) rig.add_module(module) rig.build() libSerialization.export_network(rig) return rig, module
def _create_simple_arm_build_and_export(self): jnt_1 = pymel.joint(position=[0,0,0]) jnt_2 = pymel.joint(position=[10,0,10]) jnt_3 = pymel.joint(position=[20,0,0]) rig = omtk.create() module = Arm([jnt_1, jnt_2, jnt_3]) rig.add_module(module) rig.build() libSerialization.export_network(rig) return rig, module
def test_avargrp_withsurface(self): import omtk from omtk.modules import rigHead from omtk.modules import rigFaceJaw from omtk.modules import rigFaceLips # Create a base rig rig = omtk.create() rig.add_module(rigHead.Head([pymel.PyNode('jnt_head')])) rig.add_module(rigFaceJaw.FaceJaw([pymel.PyNode('jnt_jaw')])) rig.add_module(rigFaceLips.FaceLips(pymel.ls('jnt_lip*', type='joint') + [pymel.PyNode('surface_lips'), pymel.PyNode('pSphereShape1')])) # Ensure there's only one nurbsSurface in the scene. self.assertEqual(self._get_scene_surface_count(), 1) rig.build(strict=True) rig.unbuild(strict=True) rig.build(strict=True) # Ensure there's still only one nurbsSurface in the scene. self.assertEqual(self._get_scene_surface_count(), 1)
def test_avargrp_areaonsurface_withsurface(self): """ Ensure there's always a nurbsSurface created for an AvarGrpOnSurface and that it is correctly propageted to it's child avars. :return: """ import omtk from omtk.modules import rigHead from omtk.modules import rigFaceAvarGrps # Create a base rig rig = omtk.create() rig.add_module(rigHead.Head([pymel.PyNode('jnt_head')])) rig.add_module( rigFaceAvarGrps.AvarGrpOnSurface( pymel.ls('jnt_lip*', type='joint') + [pymel.PyNode('surface_lips'), pymel.PyNode('pSphereShape1')] ) ) # Validate the state of the scene before testing. self.assertEqual(self._get_scene_surface_count(), 1) rig.build(strict=True) # Ensure there's one one nurbsSurface in the scene. self.assertEqual(self._get_scene_surface_count(), 1) rig.unbuild(strict=True) # Ensure there's still one nurbsSurface in the scene. self.assertEqual(self._get_scene_surface_count(), 1) # Remove all surfaces pymel.delete(pymel.ls(type='nurbsSurface')) self.assertEqual(self._get_scene_surface_count(), 0) # Re-created the rig and ensure the new surface was correctly created. rig.build(strict=True) # Ensure there's still one nurbsSurface in the scene. self.assertEqual(self._get_scene_surface_count(), 1)
def test_create(self): rig_name = 'TestRig' rig = omtk.create(name=rig_name) self.assertTrue(isinstance(rig, omtk.core.classRig.Rig)) self.assertTrue(rig.name == rig_name)