예제 #1
0
    def parent_bones(self):
        self.targets = force_lazy(self.bones)

        assert len(self.targets) > 0

        if len(self.targets) == 1:
            target = force_lazy(self.targets[0])
            if isinstance(target, tuple):
                target = target[0]

            self.set_bone_parent(
                self.output_bone,
                target,
                inherit_scale='NONE' if self.copy_scale else 'FIX_SHEAR')
예제 #2
0
    def generate_bones(self):
        self.output_bone = self.node.make_bone(make_derived_name(
            self.node.name, 'mch', '_arm'),
                                               1 / 4,
                                               rig=self.rig)

        self.rig.generator.disable_auto_parent(self.output_bone)

        if self.orientation:
            matrix = force_lazy(self.orientation).to_matrix().to_4x4()
            matrix.translation = self.node.point
            self.get_bone(self.output_bone).matrix = matrix
예제 #3
0
    def rig_bones(self):
        if len(self.targets) > 1:
            self.make_constraint(self.output_bone,
                                 'ARMATURE',
                                 targets=force_lazy(self.bones),
                                 use_deform_preserve_volume=True)

            self.make_constraint(self.output_bone, 'LIMIT_ROTATION')

        if self.copy_rotation:
            self.make_constraint(self.output_bone, 'COPY_ROTATION',
                                 self.copy_rotation)
        if self.copy_scale:
            self.make_constraint(self.output_bone, 'COPY_SCALE',
                                 self.copy_scale)
예제 #4
0
    def make_scale_properties(self):
        org = self.bones.org
        bone = self.get_bone(org)
        input_bone = force_lazy(self.input_ref)

        bone['s'] = 0.0
        bone['p'] = 0.0
        bone['f'] = 0.0

        variables = {
            'sx': driver_var_transform(self.obj, input_bone, type='SCALE_X', space='LOCAL'),
            'sy': driver_var_transform(self.obj, input_bone, type='SCALE_Z', space='LOCAL'),
        }

        self.make_driver(bone, quote_property('s'), expression='sx+sy-2', variables=variables)
        self.make_driver(bone, quote_property('p'), expression='sx-sy', variables=variables)

        variables = {
            **variables,
            'tx': driver_var_transform(self.obj, input_bone, type='LOC_X', space='LOCAL'),
            'ty': driver_var_transform(self.obj, input_bone, type='LOC_Z', space='LOCAL'),
        }

        self.make_driver(bone, quote_property('f'), expression='max(1e-5,(sx+sy-2)/2+sqrt(tx*tx+ty*ty))', variables=variables)
예제 #5
0
 def parent_bones(self):
     self.rig_parent_bone = force_lazy(
         self.get_child_chain_parent_next(self))
예제 #6
0
 def output_bone(self):
     return force_lazy(self._output_bone)