Пример #1
0
    def __importJoints(self):
        start_time = time.time()
        joint_pool = self.__rig.createJointPool(len(self.__model.joints))
        for i, (joint,
                joint_obj) in enumerate(zip(self.__model.joints, joint_pool)):
            loc = Vector(joint.location).xzy * self.__scale
            rot = Vector(joint.rotation).xzy * -1

            obj = self.__rig.createJoint(
                obj=joint_obj,
                name=joint.name,
                name_e=joint.name_e,
                location=loc,
                rotation=rot,
                rigid_a=self.__rigidTable.get(joint.src_rigid, None),
                rigid_b=self.__rigidTable.get(joint.dest_rigid, None),
                maximum_location=Vector(joint.maximum_location).xzy *
                self.__scale,
                minimum_location=Vector(joint.minimum_location).xzy *
                self.__scale,
                maximum_rotation=Vector(joint.minimum_rotation).xzy * -1,
                minimum_rotation=Vector(joint.maximum_rotation).xzy * -1,
                spring_linear=Vector(joint.spring_constant).xzy,
                spring_angular=Vector(joint.spring_rotation_constant).xzy,
            )
            obj.hide = True
            MoveObject.set_index(obj, i)

        logging.debug('Finished importing joints in %f seconds.',
                      time.time() - start_time)
Пример #2
0
    def __importRigids(self):
        start_time = time.time()
        self.__rigidTable = {}
        rigid_pool = self.__rig.createRigidBodyPool(len(self.__model.rigids))
        for i, (rigid, rigid_obj) in enumerate(zip(self.__model.rigids, rigid_pool)):
            loc = Vector(rigid.location).xzy * self.__scale
            rot = Vector(rigid.rotation).xzy * -1
            size = Vector(rigid.size).xzy if rigid.type == pmx.Rigid.TYPE_BOX else Vector(rigid.size)

            obj = self.__rig.createRigidBody(
                obj = rigid_obj,
                name = rigid.name,
                name_e = rigid.name_e,
                shape_type = rigid.type,
                dynamics_type = rigid.mode,
                location = loc,
                rotation = rot,
                size = size * self.__scale,
                collision_group_number = rigid.collision_group_number,
                collision_group_mask = [rigid.collision_group_mask & (1<<i) == 0 for i in range(16)],
                arm_obj = self.__armObj,
                mass=rigid.mass,
                friction = rigid.friction,
                angular_damping = rigid.rotation_attenuation,
                linear_damping = rigid.velocity_attenuation,
                bounce = rigid.bounce,
                bone = None if rigid.bone == -1 or rigid.bone is None else self.__boneTable[rigid.bone].name,
                )
            obj.hide = True
            MoveObject.set_index(obj, i)
            self.__rigidTable[i] = obj

        logging.debug('Finished importing rigid bodies in %f seconds.', time.time() - start_time)