Ejemplo n.º 1
0
    def test_vmd_output(self):
        motion = VmdReader(u"test/data/補間曲線テスト01.vmd").read_data()
        model = PmxReader(
            "D:/MMD/MikuMikuDance_v926x64/UserFile/Model/ダミーボーン頂点追加2.pmx"
        ).read_data()

        for n in range(100):
            fill_fno = 8
            fill_bone_name = "右腕{0:03d}".format(n)
            fill_bf = motion.calc_bf(fill_bone_name, fill_fno)
            fill_bf.key = True

            motion.bones[fill_bone_name][fill_fno] = fill_bf

        data_set = MOptionsDataSet(
            motion, model, model,
            "E:/WebDownload/test_vmd_output_{0:%Y%m%d_%H%M%S}.vmd".format(
                datetime.now()), False, False)

        VmdWriter(data_set).write()
        print(data_set.output_vmd_path)
Ejemplo n.º 2
0
    def test_calc_bf_02(self):
        motion = VmdReader(u"test/data/補間曲線テスト01.vmd").read_data()

        bf = motion.calc_bf("ボーン01", 0)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 15)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 20, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 30, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 40, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               50,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               60.00003815,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               70,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 1)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0.032109514, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 10.18260956, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 4.065711975, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.000829206,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.000238923,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.000410508,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 2)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0.140442505, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 12.61500168, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 8.287061691, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.007236294,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.002085242,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.003582553,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 3)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0.348192513, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 13.84411716, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 12.79018593, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.026710032,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.007699313,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.013225263,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 4)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0.698622525, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 14.49679756, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 17.72015953, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.069654942,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.020092424,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.034498487,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 5)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 1.264359236, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 14.82721519, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 23.55570602, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.151426569,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.043738037,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.07503701,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 6)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 2.228799105, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 14.96385574, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 28.47421646, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.293533772,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.084980235,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.145587772,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 7)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 4.250654697, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 14.99863911, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 29.97695541, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.529829144,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.153979659,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.263184816,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 8)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 15.74932003, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 15.00131607, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 31.17938614, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0.91197902,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.266692847,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.454135865,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 9)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 17.77118301, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 15.03609848, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 32.36212158, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               1.525828362,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.450684816,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.762894511,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 10)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 18.73562622, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 15.17386436, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 33.57285309, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               2.53502202,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0.761205316,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               1.276175618,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 11)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 19.3013649, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 15.50316238, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 34.80752563, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               4.252967358,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               1.313556314,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               2.167253256,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 12)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 19.65179825, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 16.15584373, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 36.06707764, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               7.438279152,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               2.422097683,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               3.884207487,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 13)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 19.85955048, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 17.38496399, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 37.35407639, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               14.49954891,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               5.332914352,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               8.068556786,
                               delta=0.1)

        bf = motion.calc_bf("ボーン01", 14)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 19.96788788, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 19.81736565, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 38.66796112, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               33.70291519,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               18.53442383,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               24.47537041,
                               delta=0.1)
Ejemplo n.º 3
0
    def test_calc_bf_01(self):
        motion = VmdReader(
            "D:/MMD/MikuMikuDance_v926x64/UserFile/Motion/ダンス_1人/ドラマツルギー motion 配布用 moka/ドラマツルギー_0-500.vmd"
        ).read_data()

        bf = motion.calc_bf("右腕", 101)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               27.1,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               16.2,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               -32.9,
                               delta=0.1)

        bf = motion.calc_bf("右腕", 143)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               32.2,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               57.3,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               -23.6,
                               delta=0.1)

        bf = motion.calc_bf("右腕", 107)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               27.2,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               16.7,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               -32.8,
                               delta=0.1)

        bf = motion.calc_bf("右腕", 121)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               28.6,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               24.5,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               -31.4,
                               delta=0.1)

        bf = motion.calc_bf("右腕", 137)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 0, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               32.1,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               55.2,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               -24.1,
                               delta=0.1)

        bf = motion.calc_bf("センター", 108)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 1.00, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 1.75, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0,
                               delta=0.1)

        bf = motion.calc_bf("センター", 143)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 1.20, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 1.90, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0,
                               delta=0.1)

        bf = motion.calc_bf("センター", 135)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 1.18, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 1.89, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0,
                               delta=0.1)

        bf = motion.calc_bf("センター", 340)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 3.21, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 0, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), -0.96, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               0,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0,
                               delta=0.1)

        bf = motion.calc_bf("右足IK", 417)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 2.75, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 2.92, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 2.19, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               -29.6,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               -25.2,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               5.0,
                               delta=0.1)

        bf = motion.calc_bf("左足IK", 420)
        print(bf)
        self.assertAlmostEqual(bf.position.x(), 2.47, delta=0.1)
        self.assertAlmostEqual(bf.position.y(), 2.28, delta=0.1)
        self.assertAlmostEqual(bf.position.z(), 1.39, delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().x(),
                               -17.4,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().y(),
                               1.9,
                               delta=0.1)
        self.assertAlmostEqual(bf.rotation.toEulerAngles4MMD().z(),
                               0.7,
                               delta=0.1)