예제 #1
0
    def apply(self, set_30fps=True, add_chopnet=True):
        self.target_fps = get_hou().hscriptExpression(u"$FPS")
        if set_30fps:
            self.target_fps = 30
        self.apply_animation_settings(set_30fps)

        self.container = HoudiniRecordingContainer(recording=self.recording)
        self.container.apply_recording()

        if self.is_legacy_fbx():
            self.load_legacy_camera(add_chopnet=add_chopnet)
            self.load_legacy_nulls()
        else:
            self.load_fbx_scene(add_chopnet=add_chopnet,
                                parent_node=self.container.node)

        self.load_point_cloud()
        self.load_envlight()

        subnet_input_1 = self.container.node.indirectInputs()[0]
        for child in self.container.node.children():
            name = child.name().lower()
            if name == u"planes" or u'camera' in name or u'point_cloud' in name or name == u'nulls':
                child.setInput(0, subnet_input_1)
        self.container.node.layoutChildren()
예제 #2
0
    def set_byplay_recording_ids(node):
        ids = RecordingLocalStorage().list_recording_ids()
        ids = list(reversed(ids))

        if len(ids) == 0:
            get_hou().ui.displayMessage(
                u"There are no recordings. Did you try the app and downloaded something in Byplay Desktop?"
            )
            return
        selected_recording_id = node.parm(
            u"byplay_loaded_recording_id").evalAsString()
        HoudiniParamsBuilder.set_dropdown_values(
            node,
            u"byplay_recording_id",
            ids,
            labels=None,
            current_value=selected_recording_id)
예제 #3
0
 def apply_animation_settings(self, set_30fps):
     frame_count = self.recording.frame_count()
     hou = get_hou()
     start_frame = hou.hscriptExpression(u"$FSTART")
     end_frame = max(hou.hscriptExpression(u"$FEND"),
                     start_frame + frame_count)
     set_global_frange_expr = u"tset `({}-1)/$FPS` `{}/$FPS`".format(
         start_frame, end_frame)
     hou.hscript(set_global_frange_expr)
     hou.playbar.setPlaybackRange(start_frame, end_frame)
예제 #4
0
 def byplay_recording_container_parm_templates(node):
     hou = get_hou()
     return [
         hou.StringParmTemplate(u"byplay_can_edit_paths",
                                u"Byplay can edit paths",
                                1,
                                default_value=u"yes",
                                is_hidden=True),
         hou.StringParmTemplate(
             u"recording_path",
             u"Recording path",
             1,
             # conditionals={hou.parmCondType.DisableWhen: '{ byplay_can_edit_paths != "yes" }'}
         ),
         hou.StringParmTemplate(
             u"video_frames_path",
             u"Video frames path",
             1,
             # conditionals={hou.parmCondType.DisableWhen: '{ byplay_can_edit_paths != "yes" }'}
         ),
         hou.MenuParmTemplate(
             u"exr_name",
             u"Environment .exr",
             menu_items=[u'-'],
         ),
         hou.IntParmTemplate(u"byplay_start_frame",
                             u"Start at frame",
                             1,
                             default_value=(1, )),
         hou.StringParmTemplate(u"byplay_recording_id",
                                u"Byplay recording id",
                                1,
                                default_value=(u"", ),
                                is_hidden=True),
         hou.StringParmTemplate(u"byplay_recording_session_id",
                                u"Byplay recording session id",
                                1,
                                default_value=(u"unk", ),
                                is_hidden=True),
         hou.FloatParmTemplate(
             u"byplay_applied_postprocessing_y_offset",
             u"Postprocessing y offset",
             1,
             default_value=(0, ),
             # is_hidden=True
         ),
         hou.FloatParmTemplate(
             u"byplay_target_postprocessing_y_offset",
             u"Target y offset",
             1,
             default_value=(0, ),
             # is_hidden=True
         ),
     ]
예제 #5
0
    def add_byplay_tab_to_recording_container(node):
        hou = get_hou()
        parm_group = node.parmTemplateGroup()

        parm_folder = hou.FolderParmTemplate("byplay_settings", "Byplay")

        for tpl in HoudiniParamsBuilder.byplay_recording_container_parm_templates(node):
            parm_folder.addParmTemplate(tpl)

        parm_group.append(parm_folder)
        node.setParmTemplateGroup(parm_group)
예제 #6
0
    def _get_parent_node(self, parent_path):
        hou = get_hou()
        if parent_path is not None:
            return hou.node(parent_path)

        root = hou.node(u"/obj")
        if self.recording is None:
            return root
        parent_name = u"Byplay_{}".format(self.recording.id)
        parent = root.node(parent_name)
        if parent is None:
            raise ValueError(u"Could not find parent node {}".format(parent_name))
        return parent
예제 #7
0
 def set_params(self, props, at_frame=None, create_non_existing=False):
     props = expand_vector_props(props)
     for prop, val in props.items():
         parm = self.node.parm(prop)
         if parm is None:
             print u"Could not find parm {} on {}".format(prop, self.node.path())
             continue
         if type(val) == unicode or at_frame is None:
             parm.set(val)
             continue
         kf = get_hou().Keyframe()
         kf.setValue(float(val))
         if at_frame is not None:
             kf.setFrame(at_frame)
         parm.setKeyframe(kf)
예제 #8
0
    def add_byplay_tab_to_loader(node):
        hou = get_hou()
        parm_group = node.parmTemplateGroup()

        parm_folder = hou.FolderParmTemplate(u"byplay_settings", u"Byplay")

        for tpl in HoudiniParamsBuilder.byplay_settings_parm_templates(node):
            parm_folder.addParmTemplate(tpl)

        if Config.is_dev():
            parm_folder.addParmTemplate(
                hou.ButtonParmTemplate(
                    u"byplay_reload_modules",
                    u"[[DEV]] reload Byplay python modules",
                    script_callback=
                    u"__import__('byplay').ui_callbacks.reload_all_modules()",
                    script_callback_language=hou.scriptLanguage.Python))

        parm_group.append(parm_folder)
        node.setParmTemplateGroup(parm_group)
예제 #9
0
 def make_float_keyframe(self, value, frame):
     kf = get_hou().Keyframe()
     kf.setValue(value)
     kf.setFrame(frame)
     return kf
예제 #10
0
 def byplay_settings_parm_templates(node):
     hou = get_hou()
     return [
         hou.StringParmTemplate(u"byplay_can_edit_paths",
                                u"Byplay can edit paths",
                                1,
                                default_value=u"yes",
                                is_hidden=True),
         hou.StringParmTemplate(u"byplay_loaded_recording_id",
                                u"Loaded recording id",
                                1,
                                default_value=u"",
                                is_hidden=True),
         hou.StringParmTemplate(
             u"byplay_recordings_dir",
             u"Recordings directory",
             1,
             help=u"This is set in Byplay Desktop",
             # conditionals={hou.parmCondType.DisableWhen: '{ byplay_can_edit_paths != "yes" }'}
         ),
         hou.MenuParmTemplate(
             u"byplay_recording_id",
             u"Recording id",
             menu_items=[u'[click refresh]'],
             join_with_next=True,
             help=
             u"These are downloaded & extracted recording ids from Byplay Desktop"
         ),
         hou.ButtonParmTemplate(
             u"byplay_reload_recordings",
             u"Refresh",
             script_callback=
             u"__import__('byplay').ui_callbacks.reload_recordings_list('{}')"
             .format(node.path()),
             script_callback_language=hou.scriptLanguage.Python),
         hou.ToggleParmTemplate(u"byplay_set_30fps",
                                u"Set scene FPS to 30",
                                is_hidden=True,
                                default_value=True,
                                join_with_next=True),
         hou.ToggleParmTemplate(
             u"byplay_add_chopnet",
             u"Add CHOP to change timings",
             is_hidden=True,
             default_value=True,
         ),
         hou.ButtonParmTemplate(
             u"byplay_load_recording",
             u"Load",
             script_callback=
             u"__import__('byplay').ui_callbacks.load_recording_for_ui('{}')"
             .format(node.path()),
             script_callback_language=hou.scriptLanguage.Python,
             conditionals={
                 hou.parmCondType.DisableWhen:
                 u'{ byplay_recording_id == "[click refresh]" }'
             }),
         hou.MenuParmTemplate(u"byplay_use_exr_from",
                              u"Use EXR env from", [],
                              item_generator_script=u"""
             els = [n.name()[len("Byplay_"):] for n in hou.node("/obj/byplayloader").outputs()]
             return [item for item in els for i in range(2)]
             """)
     ]
예제 #11
0
 def make_float_keyframe(self, value: float, frame: int) -> object:
     kf = get_hou().Keyframe()
     kf.setValue(value)
     kf.setFrame(frame)
     return kf