From 953a74b18dd0f4654fe9e58eb9d1c975586f4d86 Mon Sep 17 00:00:00 2001 From: Tamas Nepusz Date: Wed, 6 Mar 2024 13:26:19 +0100 Subject: [PATCH] feat: added support for DSS PATH3 format (depending on the server) --- src/addons/ui_skybrush_studio.py | 2 + src/modules/sbstudio/model/file_formats.py | 2 + .../sbstudio/plugin/operators/__init__.py | 3 +- .../plugin/operators/export_to_dss.py | 50 ++++++++++++++++--- .../sbstudio/plugin/operators/utils.py | 8 +++ src/modules/sbstudio/plugin/panels/export.py | 4 ++ 6 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/addons/ui_skybrush_studio.py b/src/addons/ui_skybrush_studio.py index 706b92cc..3cc376f5 100644 --- a/src/addons/ui_skybrush_studio.py +++ b/src/addons/ui_skybrush_studio.py @@ -80,6 +80,7 @@ DetachMaterialsFromDroneTemplateOperator, DrotekExportOperator, DSSPathExportOperator, + DSSPath3ExportOperator, DuplicateLightEffectOperator, FixConstraintOrderingOperator, AddMarkersFromQRCodeOperator, @@ -206,6 +207,7 @@ DACExportOperator, DrotekExportOperator, DSSPathExportOperator, + DSSPath3ExportOperator, LitebeeExportOperator, UseSelectedVertexGroupForFormationOperator, GetFormationStatisticsOperator, diff --git a/src/modules/sbstudio/model/file_formats.py b/src/modules/sbstudio/model/file_formats.py index e37fa729..4fa38403 100644 --- a/src/modules/sbstudio/model/file_formats.py +++ b/src/modules/sbstudio/model/file_formats.py @@ -16,6 +16,7 @@ class FileFormat(Enum): CSV = "csv" PDF = "pdf" DSS = "dss" + DSS3 = "dss3" DAC = "dac" DROTEK = "drotek" LITEBEE = "litebee" @@ -44,6 +45,7 @@ def update_supported_file_formats_from_limits(limits: Limits) -> None: formats.append(FileFormat.DAC) elif feature == "export:dss": formats.append(FileFormat.DSS) + formats.append(FileFormat.DSS3) elif feature == "export:drotek": formats.append(FileFormat.DROTEK) elif feature == "export:litebee": diff --git a/src/modules/sbstudio/plugin/operators/__init__.py b/src/modules/sbstudio/plugin/operators/__init__.py index 4adaef2a..6aabf477 100644 --- a/src/modules/sbstudio/plugin/operators/__init__.py +++ b/src/modules/sbstudio/plugin/operators/__init__.py @@ -15,7 +15,7 @@ from .duplicate_light_effect import DuplicateLightEffectOperator from .export_to_csv import SkybrushCSVExportOperator from .export_to_dac import DACExportOperator -from .export_to_dss import DSSPathExportOperator +from .export_to_dss import DSSPathExportOperator, DSSPath3ExportOperator from .export_to_drotek import DrotekExportOperator from .export_to_litebee import LitebeeExportOperator from .export_to_skyc import SkybrushExportOperator @@ -64,6 +64,7 @@ "DetachMaterialsFromDroneTemplateOperator", "DrotekExportOperator", "DSSPathExportOperator", + "DSSPath3ExportOperator", "DuplicateLightEffectOperator", "FixConstraintOrderingOperator", "AddMarkersFromQRCodeOperator", diff --git a/src/modules/sbstudio/plugin/operators/export_to_dss.py b/src/modules/sbstudio/plugin/operators/export_to_dss.py index 8d07c357..73baa98b 100644 --- a/src/modules/sbstudio/plugin/operators/export_to_dss.py +++ b/src/modules/sbstudio/plugin/operators/export_to_dss.py @@ -1,24 +1,24 @@ from typing import Any, Dict -from bpy.props import StringProperty +from bpy.props import IntProperty, StringProperty from sbstudio.model.file_formats import FileFormat from .base import ExportOperator -__all__ = ("DSSPathExportOperator",) +__all__ = ("DSSPathExportOperator", "DSSPath3ExportOperator") -############################################################################# -# Operator that allows the user to invoke the .dac export operation -############################################################################# +#################################################################################### +# Operator that allows the user to invoke the DSS .path and .path3 export operations +#################################################################################### class DSSPathExportOperator(ExportOperator): """Export object trajectories and light animation into DSS PATH format.""" bl_idname = "export_scene.dss_path" - bl_label = "Export DSS" + bl_label = "Export DSS PATH" bl_options = {"REGISTER"} # List of file extensions that correspond to DSS PATH files @@ -33,3 +33,41 @@ def get_operator_name(self) -> str: def get_settings(self) -> Dict[str, Any]: return {} + + +class DSSPath3ExportOperator(ExportOperator): + """Export object trajectories and light animation into DSS PATH3 format.""" + + bl_idname = "export_scene.dss_path3" + bl_label = "Export DSS PATH3" + bl_options = {"REGISTER"} + + # List of file extensions that correspond to DSS PATH3 files + filter_glob = StringProperty(default="*.zip", options={"HIDDEN"}) + filename_ext = ".zip" + + # output trajectory frame rate + output_fps = IntProperty( + name="Trajectory FPS", + default=4, + description="Number of samples to take from trajectories per second", + ) + + # output light program frame rate + light_output_fps = IntProperty( + name="Light FPS", + default=24, + description="Number of samples to take from light programs per second", + ) + + def get_format(self) -> FileFormat: + return FileFormat.DSS3 + + def get_operator_name(self) -> str: + return "DSS PATH3 exporter" + + def get_settings(self) -> Dict[str, Any]: + return { + "output_fps": self.output_fps, + "light_output_fps": self.light_output_fps, + } diff --git a/src/modules/sbstudio/plugin/operators/utils.py b/src/modules/sbstudio/plugin/operators/utils.py index 7b42a8d9..61a75ee7 100644 --- a/src/modules/sbstudio/plugin/operators/utils.py +++ b/src/modules/sbstudio/plugin/operators/utils.py @@ -370,6 +370,14 @@ def export_show_to_file_using_api( elif format is FileFormat.DSS: log.info("Exporting show to DSS PATH format") renderer = "dss" + elif format is FileFormat.DSS3: + log.info("Exporting show to DSS PATH3 format") + renderer = "dss3" + renderer_params = { + **renderer_params, + "fps": settings["output_fps"], + "light_fps": settings["light_output_fps"], + } elif format is FileFormat.LITEBEE: log.info("Exporting show to Litebee format") renderer = "litebee" diff --git a/src/modules/sbstudio/plugin/panels/export.py b/src/modules/sbstudio/plugin/panels/export.py index 8e875f17..4c09c188 100644 --- a/src/modules/sbstudio/plugin/panels/export.py +++ b/src/modules/sbstudio/plugin/panels/export.py @@ -5,6 +5,7 @@ DACExportOperator, DrotekExportOperator, DSSPathExportOperator, + DSSPath3ExportOperator, LitebeeExportOperator, RefreshFileFormatsOperator, SkybrushExportOperator, @@ -59,6 +60,9 @@ def draw(self, context): layout.operator( DSSPathExportOperator.bl_idname, text="Export to DSS PATH format" ) + layout.operator( + DSSPath3ExportOperator.bl_idname, text="Export to DSS PATH3 format" + ) elif format is FileFormat.LITEBEE: layout.operator( LitebeeExportOperator.bl_idname, text="Export to Litebee format"