Ejemplo n.º 1
0
    def __makeSpring(self, target, base_obj, spring_stiffness):
        with bpyutils.select_object(target):
            bpy.ops.object.duplicate()
            spring_target = SceneOp(bpy.context).active_object
        t = spring_target.constraints.get('mmd_tools_rigid_parent')
        if t is not None:
            spring_target.constraints.remove(t)
        spring_target.mmd_type = 'SPRING_GOAL'
        spring_target.rigid_body.kinematic = True
        spring_target.rigid_body.collision_groups = (False, False, False,
                                                     False, False, False,
                                                     False, False, False,
                                                     False, False, False,
                                                     False, False, False,
                                                     False, False, False,
                                                     False, True)
        spring_target.parent = base_obj
        spring_target.matrix_parent_inverse = mathutils.Matrix(
            base_obj.matrix_basis).inverted()
        spring_target.hide = True

        obj = bpy.data.objects.new('S.' + target.name, None)
        SceneOp(bpy.context).link_object(obj)
        obj.location = target.location
        obj.empty_draw_size = 0.1
        obj.empty_draw_type = 'ARROWS'
        obj.hide_render = True
        obj.select = False
        obj.hide = True
        obj.mmd_type = 'SPRING_CONSTRAINT'
        obj.parent = self.temporaryGroupObject()

        with bpyutils.select_object(obj):
            bpy.ops.rigidbody.constraint_add(type='GENERIC_SPRING')
        rbc = obj.rigid_body_constraint
        rbc.object1 = target
        rbc.object2 = spring_target

        rbc.use_spring_x = True
        rbc.use_spring_y = True
        rbc.use_spring_z = True

        rbc.spring_stiffness_x = spring_stiffness[0]
        rbc.spring_stiffness_y = spring_stiffness[1]
        rbc.spring_stiffness_z = spring_stiffness[2]
Ejemplo n.º 2
0
def _setActiveMeshObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if obj.type == 'MESH' and obj.mmd_type == 'NONE':
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_mesh_index'] = v
Ejemplo n.º 3
0
def _setActiveJointObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if mmd_model.isJointObject(obj):
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_joint_object_index'] = v
Ejemplo n.º 4
0
def _setActiveRigidbodyObject(prop, v):
    obj = SceneOp(bpy.context).id_objects[v]
    if mmd_model.isRigidBodyObject(obj):
        obj.hide = False
        utils.selectAObject(obj)
    prop['active_rigidbody_object_index'] = v