def test_reset_complement_01(self): # モーションの宣言 motion = VmdMotion() motion.frames["左手首"] = [] bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 0 bf.read = True bf.key = True bf.complement = [ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 ] motion.frames["左手首"].append(bf) # 腕リストの宣言 arm_links = self.create_arm_links() # 処理実施 sub_arm_ik.reset_complement(motion, arm_links) for c in motion.frames["左手首"][0].complement: self.assertEqual(10, c)
def test_create_replace_morphs_03(self): logger.info("-------------------------") motion = VmdMotion() motion.morphs["あ"] = [] motion.morphs["い"] = [] m = VmdMorphFrame() m.name = "あ".encode('shift-jis') m.frame = 0 m.ratio = 10 motion.morphs["あ"].append(m) m = VmdMorphFrame() m.name = "い".encode('shift-jis') m.frame = 3 m.ratio = 20 motion.morphs["い"].append(m) vmd_choice_values = ["あ"] rep_choice_values = ["い"] rep_rate_values = [0.55] replace_morphs = sub_morph.create_replace_morphs( motion, vmd_choice_values, rep_choice_values, rep_rate_values) self.assertEqual(1, len(replace_morphs)) self.assertEqual(("い", "あ"), list(replace_morphs.keys())[0]) m = replace_morphs[("い", "あ")][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(5.5, m.ratio)
def test_exec_02(self): logger.info("test_exec_02 -------------------------") motion = VmdMotion() motion.morphs["あ"] = [] m = VmdMorphFrame() m.name = "あ".encode('shift-jis') m.frame = 0 m.ratio = 10 motion.morphs["あ"].append(m) vmd_choice_values = ["あ"] rep_choice_values = ["い"] rep_rate_values = [2] sub_morph.exec(motion, None, None, None, vmd_choice_values, rep_choice_values, rep_rate_values) self.assertEqual(2, len(motion.morphs)) self.assertEqual("あ", list(motion.morphs.keys())[0]) self.assertEqual(0, len(motion.morphs["あ"])) self.assertEqual("い", list(motion.morphs.keys())[1]) self.assertEqual(1, len(motion.morphs["い"])) m = motion.morphs["い"][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(20, m.ratio)
def test_blend_morphs_02(self): logger.info("test_blend_morphs_01 -------------------------") motion = VmdMotion() motion.morphs["い"] = [] m = VmdMorphFrame() m.name = "い".encode('shift-jis') m.frame = 0 m.ratio = 10 motion.morphs["い"].append(m) replace_morphs = {} replace_morphs[("い", "あ")] = [] m = VmdMorphFrame() m.name = "い".encode('shift-jis') m.frame = 0 m.ratio = 6 replace_morphs[("い", "あ")].append(m) blended_morphs = sub_morph.blend_morphs(motion, replace_morphs) self.assertEqual(1, len(blended_morphs)) self.assertEqual("い", list(blended_morphs.keys())[0]) self.assertEqual(1, len(blended_morphs["い"])) m = blended_morphs["い"][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(16, m.ratio)
def test_create_replace_morphs_04(self): logger.info("-------------------------") motion = VmdMotion() motion.morphs["あ"] = [] motion.morphs["う"] = [] m = VmdMorphFrame() m.name = "あ".encode('shift-jis') m.frame = 0 m.ratio = 10 motion.morphs["あ"].append(m) m = VmdMorphFrame() m.name = "あ".encode('shift-jis') m.frame = 4 m.ratio = 20 motion.morphs["あ"].append(m) m = VmdMorphFrame() m.name = "う".encode('shift-jis') m.frame = 10 m.ratio = 30 motion.morphs["う"].append(m) vmd_choice_values = ["あ", "う"] rep_choice_values = ["い", "い"] rep_rate_values = [0.6, 0.3] replace_morphs = sub_morph.create_replace_morphs( motion, vmd_choice_values, rep_choice_values, rep_rate_values) # logger.info("replace_morphs: %s, ", replace_morphs) self.assertEqual(2, len(replace_morphs)) self.assertEqual(("い", "あ"), list(replace_morphs.keys())[0]) m = replace_morphs[("い", "あ")][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(6, m.ratio) m = replace_morphs[("い", "あ")][1] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(4, m.frame) self.assertEqual(12, m.ratio) self.assertEqual(("い", "う"), list(replace_morphs.keys())[1]) m = replace_morphs[("い", "う")][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(10, m.frame) self.assertEqual(9, m.ratio)
def test_regist_morphs_02(self): logger.info("-------------------------") motion = VmdMotion() motion.morphs["あ"] = [] motion.morphs["い"] = [] m = VmdMorphFrame() m.name = "あ".encode('shift-jis') m.frame = 0 m.ratio = 10 motion.morphs["あ"].append(m) m = VmdMorphFrame() m.name = "い".encode('shift-jis') m.frame = 3 m.ratio = 20 motion.morphs["い"].append(m) blended_morphs = {} blended_morphs["い"] = [] m = VmdMorphFrame() m.name = "い".encode('shift-jis') m.frame = 0 m.ratio = 6 blended_morphs["い"].append(m) sub_morph.regist_morphs(motion, blended_morphs) self.assertEqual(2, len(motion.morphs)) self.assertEqual("あ", list(motion.morphs.keys())[0]) self.assertEqual(1, len(motion.morphs["あ"])) m = motion.morphs["あ"][0] self.assertEqual("あ".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(10, m.ratio) self.assertEqual("い", list(motion.morphs.keys())[1]) self.assertEqual(1, len(motion.morphs["い"])) m = motion.morphs["い"][0] self.assertEqual("い".encode('shift-jis'), m.name) self.assertEqual(0, m.frame) self.assertEqual(6, m.ratio)
def test_reset_complement_06(self): # モーションの宣言 motion = VmdMotion() motion.frames["左手首"] = [] bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 0 bf.read = True bf.key = True for r in utils.R_x1_idxs: bf.complement[r] = 10 for r in utils.R_y1_idxs: bf.complement[r] = 10 for r in utils.R_x2_idxs: bf.complement[r] = 10 for r in utils.R_y2_idxs: bf.complement[r] = 10 motion.frames["左手首"].append(bf) bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 5 bf.read = True # 間に有効キーあり bf.key = True for r in utils.R_x1_idxs: bf.complement[r] = 30 for r in utils.R_y1_idxs: bf.complement[r] = 30 for r in utils.R_x2_idxs: bf.complement[r] = 30 for r in utils.R_y2_idxs: bf.complement[r] = 30 motion.frames["左手首"].append(bf) bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 10 bf.read = False # 有効キーの次に無効キー bf.key = False for r in utils.R_x1_idxs: bf.complement[r] = 30 for r in utils.R_y1_idxs: bf.complement[r] = 30 for r in utils.R_x2_idxs: bf.complement[r] = 30 for r in utils.R_y2_idxs: bf.complement[r] = 30 motion.frames["左手首"].append(bf) bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 15 bf.read = False # 2つ目の有効キー bf.key = True for r in utils.R_x1_idxs: bf.complement[r] = 30 for r in utils.R_y1_idxs: bf.complement[r] = 30 for r in utils.R_x2_idxs: bf.complement[r] = 30 for r in utils.R_y2_idxs: bf.complement[r] = 30 motion.frames["左手首"].append(bf) bf = VmdBoneFrame() bf.format_name = "左手首" bf.frame = 30 bf.read = True bf.key = True for r in utils.R_x1_idxs: bf.complement[r] = 10 for r in utils.R_y1_idxs: bf.complement[r] = 10 for r in utils.R_x2_idxs: bf.complement[r] = 20 for r in utils.R_y2_idxs: bf.complement[r] = 20 motion.frames["左手首"].append(bf) # 腕リストの宣言 arm_links = self.create_arm_links() # 処理実施 sub_arm_ik.reset_complement(motion, arm_links) # --------------------------------- # 前回の開始X for r in utils.R_x1_idxs: self.assertEqual(10, motion.frames["左手首"][0].complement[r]) # 前回の開始Y for r in utils.R_y1_idxs: self.assertEqual(10, motion.frames["左手首"][0].complement[r]) # 前回の終了X for r in utils.R_x2_idxs: self.assertEqual(10, motion.frames["左手首"][0].complement[r]) # 前回の終了Y for r in utils.R_y2_idxs: self.assertEqual(10, motion.frames["左手首"][0].complement[r]) # --------------------------------- # 今回の開始X for r in utils.R_x1_idxs: self.assertEqual(30, motion.frames["左手首"][1].complement[r]) # 今回の開始Y for r in utils.R_y1_idxs: self.assertEqual(30, motion.frames["左手首"][1].complement[r]) # 今回の終了X for r in utils.R_x2_idxs: self.assertEqual(30, motion.frames["左手首"][1].complement[r]) # 今回の終了Y for r in utils.R_y2_idxs: self.assertEqual(30, motion.frames["左手首"][1].complement[r]) # --------------------------------- # 無効次回の開始X for r in utils.R_x1_idxs: self.assertEqual(30, motion.frames["左手首"][2].complement[r]) # 無効次回の開始Y for r in utils.R_y1_idxs: self.assertEqual(30, motion.frames["左手首"][2].complement[r]) # 無効次回の終了X for r in utils.R_x2_idxs: self.assertEqual(30, motion.frames["左手首"][2].complement[r]) # 無効次回の終了Y for r in utils.R_y2_idxs: self.assertEqual(30, motion.frames["左手首"][2].complement[r]) # --------------------------------- # 有効次回の開始X for r in utils.R_x1_idxs: self.assertEqual(17, motion.frames["左手首"][3].complement[r]) # 有効次回の開始Y for r in utils.R_y1_idxs: self.assertEqual(17, motion.frames["左手首"][3].complement[r]) # 有効次回の終了X for r in utils.R_x2_idxs: self.assertEqual(34, motion.frames["左手首"][3].complement[r]) # 有効次回の終了Y for r in utils.R_y2_idxs: self.assertEqual(34, motion.frames["左手首"][3].complement[r]) # --------------------------------- # 次回の開始X for r in utils.R_x1_idxs: self.assertEqual(29, motion.frames["左手首"][4].complement[r]) # 次回の開始Y for r in utils.R_y1_idxs: self.assertEqual(29, motion.frames["左手首"][4].complement[r]) # 次回の終了X for r in utils.R_x2_idxs: self.assertEqual(70, motion.frames["左手首"][4].complement[r]) # 次回の終了Y for r in utils.R_y2_idxs: self.assertEqual(70, motion.frames["左手首"][4].complement[r])