From 893783a064493ab0f8f74aa4cdb222a88fb5914a Mon Sep 17 00:00:00 2001 From: Kristian <57712777+NMC-TBone@users.noreply.github.com> Date: Sun, 2 Feb 2025 17:11:14 +0100 Subject: [PATCH] feat(properties): add transformation property to display and interact with i3d coordinates --- i3d_exporter_additionals/properties.py | 20 ++++++++++++++++++++ i3d_exporter_additionals/ui.py | 9 +++++++++ 2 files changed, 29 insertions(+) diff --git a/i3d_exporter_additionals/properties.py b/i3d_exporter_additionals/properties.py index 0d7241e..b9faa27 100644 --- a/i3d_exporter_additionals/properties.py +++ b/i3d_exporter_additionals/properties.py @@ -528,9 +528,29 @@ class I3DEA_PG_List(bpy.types.PropertyGroup): _register, _unregister = bpy.utils.register_classes_factory(classes) +def get_translation(self) -> tuple: + from mathutils import Vector + # blender vs giants coordinate + # x = x, y = z, z = -y + return Vector((self.location[0], self.location[2], -self.location[1])) + + +def set_translation(self, value) -> None: + self.location = (value[0], -value[2], value[1]) + + def register() -> None: _register() bpy.types.Scene.i3dea = bpy.props.PointerProperty(type=I3DEA_PG_List) + bpy.types.Object.test_translation = bpy.props.FloatVectorProperty( + name="Location", + default=(0, 0, 0), + subtype='TRANSLATION', + size=3, + get=get_translation, + set=set_translation, + precision=3 + ) def unregister() -> None: diff --git a/i3d_exporter_additionals/ui.py b/i3d_exporter_additionals/ui.py index 6aaab6d..b3ec6bb 100644 --- a/i3d_exporter_additionals/ui.py +++ b/i3d_exporter_additionals/ui.py @@ -27,6 +27,15 @@ class I3DEA_PT_MainPanel(Panel): def draw(self, context): giants_i3d, stjerne_i3d = check_i3d_exporter_type() layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + obj = context.object + + if obj: + layout.use_property_split = False + col = layout.column(align=True) + col.prop(obj, "test_translation") if giants_i3d and stjerne_i3d: # "Exporter selection" box layout.label(text="Both Giants & Stjerne I3D exporter is enabled", icon='ERROR')