Exemplo n.º 1
0
    def load_scene(self, filepath=""):
        if filepath == "":
            filepath = Dialogs.open_file(self.p, AppSettings.save_dir)[0]
        if not os.path.isfile(filepath):
            Scene().set_status("file selected is not valid.", "warning")
            return

        # open
        f = open(filepath, "r")
        scene_file = json.loads(f.read())
        f.close()

        # Load mocap (if it was there)
        if scene_file["mocap"] != "":
            MocapHandle().load_mocap("%s/%s" % (AppSettings.demuddle_dir, scene_file["mocap"]))

        # Load characters.
        for fp in scene_file["character_filepaths"]:
            self.add_toon_from_file("%s/%s" % (AppSettings.demuddle_dir, fp))

        # Apply info and motion onto characters
        cindex = 0
        for cindex in range(len(scene_file["character_motion_maps"])):
            motion_maps = scene_file["character_motion_maps"][cindex]
            character_infos = scene_file["character_info"][cindex]

            for joint_name in motion_maps.keys():
                character_info = character_infos[joint_name]
                motion_map = motion_maps[joint_name]
                joint_obj = self.toons[cindex].joint_by_name(joint_name)
                joint_obj.set_info(character_info)
                joint_obj.generate_retargets_from_map(motion_map)
            cindex += 1

        self.p.update()
Exemplo n.º 2
0
    def load_mocap(self, filepath=""):
        if filepath == "":
            filepath = Dialogs.open_file(None, AppSettings.data_dir)[0]

        if os.path.isfile(filepath):
            self.last_loaded = filepath
            data = self.load_from_file(filepath)

            self.motion = data[AppSettings.motion_type]
            first_key = self.motion.keys()[0]
            first_dof = self.motion[first_key].keys()[0]
            first_curve = self.motion[first_key][first_dof]

            Timeline().set_frame_range(data["start_frame"], len(first_curve))
            Animation.mocap_reset()
Exemplo n.º 3
0
 def load_toon(self):
     filepath = Dialogs.open_file(self.p, AppSettings.toon_dir)[0]
     if os.path.isfile(filepath):
         self.add_toon_from_file(filepath)
     else:
         Scene().set_status("File selected is not valid", "error")