[Bf-blender-cvs] [289fc4b38a0] collada: feature: Collada: global axis rotation upon export (UI)

Gaia Clary noreply at git.blender.org
Wed Apr 10 22:40:11 CEST 2019


Commit: 289fc4b38a018ee328018969b0e84488e55d1517
Author: Gaia Clary
Date:   Wed Apr 3 12:00:46 2019 +0200
Branches: collada
https://developer.blender.org/rB289fc4b38a018ee328018969b0e84488e55d1517

feature: Collada: global axis rotation upon export (UI)

===================================================================

M	source/blender/collada/ExportSettings.h
M	source/blender/editors/io/io_collada.c

===================================================================

diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h
index d0a7a76f6aa..7c73f6d7f29 100644
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@ -27,6 +27,27 @@ extern "C" {
 
 #include "BLI_linklist.h"
 
+typedef enum BC_export_global_forward_axis {
+	BC_GLOBAL_FORWARD_X = 0,
+	BC_GLOBAL_FORWARD_Y = 1,
+	BC_GLOBAL_FORWARD_Z = 2,
+	BC_GLOBAL_FORWARD_MINUS_X = 3,
+	BC_GLOBAL_FORWARD_MINUS_Y = 4,
+	BC_GLOBAL_FORWARD_MINUS_Z = 5
+} BC_export_global_forward_axis;
+
+typedef enum BC_export_global_up_axis {
+	BC_GLOBAL_UP_X = 0,
+	BC_GLOBAL_UP_Y = 1,
+	BC_GLOBAL_UP_Z = 2,
+	BC_GLOBAL_UP_MINUS_X = 3,
+	BC_GLOBAL_UP_MINUS_Y = 4,
+	BC_GLOBAL_UP_MINUS_Z = 5
+} BC_export_global_up_axis;
+
+static const BC_export_global_forward_axis BC_DEFAULT_FORWARD = BC_GLOBAL_FORWARD_Y;
+static const BC_export_global_up_axis BC_DEFAULT_UP = BC_GLOBAL_UP_Z;
+
 typedef enum BC_export_mesh_type {
 	BC_MESH_TYPE_VIEW,
 	BC_MESH_TYPE_RENDER
@@ -53,6 +74,10 @@ typedef enum BC_ui_export_section {
 
 typedef struct ExportSettings {
 	bool apply_modifiers;
+	BC_export_global_forward_axis global_forward;
+	BC_export_global_up_axis global_up;
+	bool apply_global_orientation;
+
 	BC_export_mesh_type export_mesh_type;
 
 	bool selected;
diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c
index 3829821ef2e..830c90a2bd8 100644
--- a/source/blender/editors/io/io_collada.c
+++ b/source/blender/editors/io/io_collada.c
@@ -79,6 +79,9 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
 {
 	char filepath[FILE_MAX];
 	int apply_modifiers;
+	int global_forward;
+	int global_up;
+	int apply_global_orientation;
 	int export_mesh_type;
 	int selected;
 	int include_children;
@@ -139,6 +142,10 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
 	/* Options panel */
 	apply_modifiers          = RNA_boolean_get(op->ptr, "apply_modifiers");
 	export_mesh_type         = RNA_enum_get(op->ptr,    "export_mesh_type_selection");
+	global_forward           = RNA_enum_get(op->ptr, "export_global_forward_selection");
+	global_up                = RNA_enum_get(op->ptr, "export_global_up_selection");
+	apply_global_orientation = RNA_boolean_get(op->ptr, "apply_global_orientation");
+
 	selected                 = RNA_boolean_get(op->ptr, "selected");
 	include_children         = RNA_boolean_get(op->ptr, "include_children");
 	include_armatures        = RNA_boolean_get(op->ptr, "include_armatures");
@@ -180,6 +187,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
 	export_settings.filepath = filepath;
 
 	export_settings.apply_modifiers = apply_modifiers != 0;
+	export_settings.global_forward = global_forward;
+	export_settings.global_up = global_up;
+	export_settings.apply_global_orientation = apply_global_orientation != 0;
+
+	export_settings.export_mesh_type = export_mesh_type;
 	export_settings.export_mesh_type = export_mesh_type;
 	export_settings.selected = selected != 0;
 	export_settings.include_children = include_children != 0;
@@ -248,7 +260,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
 
 static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
 {
-	uiLayout *box, *row, *col, *split;
+	uiLayout *bbox, *box, *row, *col, *split;
 	bool include_animations = RNA_boolean_get(imfptr, "include_animations");
 	int ui_section = RNA_enum_get(imfptr, "prop_bc_export_ui_section");
 
@@ -268,6 +280,19 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
 		/* Export Data options */
 		/* =================== */
 
+		bbox = uiLayoutBox(layout);
+		row = uiLayoutRow(bbox, false);
+		uiItemL(row, IFACE_("Global Orientation:"), ICON_ORIENTATION_GLOBAL);
+		row = uiLayoutRow(bbox, false);
+		uiItemR(row, imfptr, "export_global_forward_selection", 0, "", ICON_NONE);
+
+		row = uiLayoutRow(bbox, false);
+		uiItemR(row, imfptr, "export_global_up_selection", 0, "", ICON_NONE);
+
+		row = uiLayoutRow(bbox, false);
+		uiItemR(row, imfptr, "apply_global_orientation", 0, NULL, ICON_NONE);
+
+
 		row = uiLayoutRow(box, false);
 		uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
 
@@ -283,6 +308,8 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
 		uiItemR(row, imfptr, "include_shapekeys", 0, NULL, ICON_NONE);
 		uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
 
+		row = uiLayoutRow(box, false);
+
 		/* Texture options */
 		box = uiLayoutBox(layout);
 		row = uiLayoutRow(box, false);
@@ -415,6 +442,26 @@ void WM_OT_collada_export(wmOperatorType *ot)
 		{0, NULL, 0, NULL, NULL},
 	};
 
+	static const EnumPropertyItem prop_bc_export_global_forward[] = {
+		{BC_GLOBAL_FORWARD_X,        "X", 0,  "X Forward", "Global Forward is positive X Axis"},
+		{BC_GLOBAL_FORWARD_Y,        "Y", 0,  "Y Forward", "Global Forward is positive Y Axis"},
+		{BC_GLOBAL_FORWARD_Z,        "Z", 0,  "Z Forward", "Global Forward is positive Z Axis"},
+		{BC_GLOBAL_FORWARD_MINUS_X, "-X", 0, "-X Forward", "Global Forward is negative X Axis"},
+		{BC_GLOBAL_FORWARD_MINUS_Y, "-Y", 0, "-Y Forward", "Global Forward is negative Y Axis"},
+		{BC_GLOBAL_FORWARD_MINUS_Z, "-Z", 0, "-Z Forward", "Global Forward is negative Z Axis"},
+		{0, NULL, 0, NULL, NULL},
+	};
+
+	static const EnumPropertyItem prop_bc_export_global_up[] = {
+		{BC_GLOBAL_UP_X,        "X", 0,  "X Up", "Global UP is positive X Axis"},
+		{BC_GLOBAL_UP_Y,        "Y", 0,  "Y Up", "Global UP is positive Y Axis"},
+		{BC_GLOBAL_UP_Z,        "Z", 0,  "Z Up", "Global UP is positive Z Axis"},
+		{BC_GLOBAL_UP_MINUS_X, "-X", 0, "-X Up", "Global UP is negative X Axis"},
+		{BC_GLOBAL_UP_MINUS_Y, "-Y", 0, "-Y Up", "Global UP is negative Y Axis"},
+		{BC_GLOBAL_UP_MINUS_Z, "-Z", 0, "-Z Up", "Global UP is negative Z Axis"},
+		{0, NULL, 0, NULL, NULL},
+	};
+
 	static const EnumPropertyItem prop_bc_export_transformation_type[] = {
 		{ BC_TRANSFORMATION_TYPE_MATRIX, "matrix", 0, "Matrix", "Use <matrix> to specify transformations" },
 		{ BC_TRANSFORMATION_TYPE_TRANSROTLOC, "transrotloc", 0, "TransRotLoc", "Use <translate>, <rotate>, <scale> to specify transformations" },
@@ -461,10 +508,22 @@ void WM_OT_collada_export(wmOperatorType *ot)
 	                "Apply modifiers to exported mesh (non destructive))");
 
 	RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX,
-	            "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
+                    "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
 
 	RNA_def_enum(func, "export_mesh_type_selection", prop_bc_export_mesh_type, 0,
-	             "Resolution", "Modifier resolution for export");
+                    "Resolution", "Modifier resolution for export");
+
+	RNA_def_enum(func, "export_global_forward_selection", prop_bc_export_global_forward, BC_DEFAULT_FORWARD,
+		"Global Forward Axis", "Global Forward axis for export");
+
+	RNA_def_enum(func, "export_global_up_selection", prop_bc_export_global_up, BC_DEFAULT_UP,
+		"Global Up Axis", "Global Up axis for export");
+
+	RNA_def_boolean(func, "", false, "Selection Only",
+		"Export only selected elements");
+
+	RNA_def_boolean(func, "apply_global_orientation", false, "Apply Global Orientation",
+		"enabled: Rotate all root objects to match the global orientation settings.\ndisabled: set global orientation in Collada assets");
 
 	RNA_def_boolean(func, "selected", false, "Selection Only",
 	                "Export only selected elements");



More information about the Bf-blender-cvs mailing list