Ejemplo n.º 1
0
    def test_replace_morph_03(self):
        motion = VmdMotion()
        motion.morphs = {"A": {}}
        for fno, ratio in [(0, 10), (1, 20), (3, 30), (7, 0), (10, 3)]:
            motion.morphs["A"][fno] = VmdMorphFrame(fno)
            motion.morphs["A"][fno].ratio = ratio

        morph_list = [("A", "B", 0.5), ("A", "C", 2)]

        data_set = MOptionsDataSet(motion, None, None, None, False, False,
                                   morph_list, None, None)

        service = MorphService(None)
        service.replace_morph(0, data_set)

        self.assertEqual(["B", "C"], sorted(list(motion.morphs.keys())))

        self.assertTrue("B" in motion.morphs)
        self.assertEqual([0, 1, 3, 7, 10],
                         sorted(list(motion.morphs["B"].keys())))
        self.assertEqual(5, motion.morphs["B"][0].ratio)
        self.assertEqual(10, motion.morphs["B"][1].ratio)
        self.assertEqual(15, motion.morphs["B"][3].ratio)
        self.assertEqual(0, motion.morphs["B"][7].ratio)
        self.assertEqual(1.5, motion.morphs["B"][10].ratio)

        self.assertTrue("C" in motion.morphs)
        self.assertEqual([0, 1, 3, 7, 10],
                         sorted(list(motion.morphs["C"].keys())))
        self.assertEqual(20, motion.morphs["C"][0].ratio)
        self.assertEqual(40, motion.morphs["C"][1].ratio)
        self.assertEqual(60, motion.morphs["C"][3].ratio)
        self.assertEqual(0, motion.morphs["C"][7].ratio)
        self.assertEqual(6, motion.morphs["C"][10].ratio)
Ejemplo n.º 2
0
    def test_replace_morph_01(self):
        motion = VmdMotion()
        motion.morphs = {"A": {}}
        for fno, ratio in [(0, 10), (1, 20), (3, 30), (7, 0), (10, 3)]:
            motion.morphs["A"][fno] = VmdMorphFrame(fno)
            motion.morphs["A"][fno].ratio = ratio

        morph_list = []

        data_set = MOptionsDataSet(motion, None, None, None, False, False,
                                   morph_list, None, None)

        service = MorphService(None)
        service.replace_morph(0, data_set)

        self.assertEqual(["A"], sorted(list(motion.morphs.keys())))

        self.assertTrue("A" in motion.morphs)
        self.assertEqual([0, 1, 3, 7, 10],
                         sorted(list(motion.morphs["A"].keys())))