- Implemented RuntimeModelsPanel and DebugPanel for UI integration in Blender. - Created SnapFormPreferences to manage user settings for storage and runtime configuration. - Defined SnapFormSettings to hold various properties related to input, model selection, and export options. - Developed runtime management functions for installation, model downloading, and reconstruction commands. - Added status bar functionality to display job progress and status in the Blender UI. - Implemented worker script for handling model downloads and depth reconstruction tasks. - Introduced unit tests for download progress reporting and image depth extraction functionalities.
113 lines
3.6 KiB
Python
113 lines
3.6 KiB
Python
import bpy
|
|
|
|
from .models import MODELS, selected_model_key
|
|
from .operators import active_job
|
|
from .runtime import model_ready, runtime_ready
|
|
|
|
|
|
class RuntimeModelsPanel(bpy.types.Panel):
|
|
bl_label = "Setup"
|
|
bl_idname = "SNAPFORM_PT_runtime_models"
|
|
bl_space_type = "VIEW_3D"
|
|
bl_region_type = "UI"
|
|
bl_category = "SnapForm"
|
|
|
|
def draw(self, _context):
|
|
layout = self.layout
|
|
running = active_job() is not None
|
|
|
|
if not runtime_ready():
|
|
layout.label(text="Runtime is not installed", icon="ERROR")
|
|
if not running:
|
|
operator = layout.operator(
|
|
"snapform.run_job",
|
|
text="Install Runtime",
|
|
icon="IMPORT",
|
|
)
|
|
operator.job_type = "INSTALL_RUNTIME"
|
|
|
|
for model in MODELS.values():
|
|
self._draw_model(layout, model, running)
|
|
|
|
def _draw_model(self, layout, model, running):
|
|
row = layout.row(align=True)
|
|
row.label(text=model.label)
|
|
if model_ready(model.key):
|
|
row.label(text="Ready", icon="CHECKMARK")
|
|
elif runtime_ready() and not running:
|
|
operator = row.operator(
|
|
"snapform.run_job",
|
|
text="Download",
|
|
icon="IMPORT",
|
|
)
|
|
operator.job_type = "DOWNLOAD_MODEL"
|
|
operator.model_key = model.key
|
|
else:
|
|
row.label(text="Not downloaded", icon="ERROR")
|
|
|
|
|
|
class DebugPanel(bpy.types.Panel):
|
|
bl_label = "Debug"
|
|
bl_idname = "SNAPFORM_PT_debug"
|
|
bl_space_type = "VIEW_3D"
|
|
bl_region_type = "UI"
|
|
bl_category = "SnapForm"
|
|
bl_options = {"DEFAULT_CLOSED"}
|
|
|
|
def draw(self, context):
|
|
layout = self.layout
|
|
settings = context.scene.snapform_settings
|
|
|
|
layout.prop(settings, "export_format")
|
|
model_key = selected_model_key(settings)
|
|
model_property = (
|
|
"gs_model" if settings.export_format == "gs_ply" else "model"
|
|
)
|
|
model_row = layout.row(align=True)
|
|
model_row.prop(settings, model_property)
|
|
if model_ready(model_key):
|
|
model_row.label(text="", icon="CHECKMARK")
|
|
else:
|
|
model_row.label(text="", icon="ERROR")
|
|
|
|
layout.prop(settings, "input_path")
|
|
input_path = bpy.path.abspath(settings.input_path)
|
|
if input_path.lower().endswith(
|
|
(
|
|
".mp4",
|
|
".mov",
|
|
".avi",
|
|
".mkv",
|
|
".webm",
|
|
".m4v",
|
|
".mts",
|
|
".mpg",
|
|
".mpeg",
|
|
)
|
|
):
|
|
layout.prop(settings, "video_frames")
|
|
layout.prop(settings, "device")
|
|
layout.prop(settings, "process_res")
|
|
layout.prop(settings, "process_res_method")
|
|
layout.prop(settings, "use_ray_pose")
|
|
layout.prop(settings, "ref_view_strategy")
|
|
|
|
if settings.export_format == "glb":
|
|
glb_box = layout.box()
|
|
glb_box.label(text="GLB Settings")
|
|
glb_box.prop(settings, "conf_thresh_percentile")
|
|
glb_box.prop(settings, "num_max_points")
|
|
glb_box.prop(settings, "show_cameras")
|
|
elif settings.export_format == "gs_ply":
|
|
ply_box = layout.box()
|
|
ply_box.label(text="PLY (3DGS) Settings")
|
|
ply_box.prop(settings, "gs_views_interval")
|
|
|
|
if active_job() is None:
|
|
operator = layout.operator(
|
|
"snapform.run_job",
|
|
text="Export",
|
|
icon="EXPORT",
|
|
)
|
|
operator.job_type = "RECONSTRUCT"
|