diff options
Diffstat (limited to 'source/blender/editors/io/io_obj.c')
-rw-r--r-- | source/blender/editors/io/io_obj.c | 102 |
1 files changed, 46 insertions, 56 deletions
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c index f1cd7607771..79ec7ebf2a5 100644 --- a/source/blender/editors/io/io_obj.c +++ b/source/blender/editors/io/io_obj.c @@ -4,54 +4,39 @@ * \ingroup editor/io */ -#include "DNA_space_types.h" +#ifdef WITH_IO_WAVEFRONT_OBJ -#include "BKE_context.h" -#include "BKE_main.h" -#include "BKE_report.h" +# include "DNA_space_types.h" -#include "BLI_path_util.h" -#include "BLI_string.h" -#include "BLI_utildefines.h" +# include "BKE_context.h" +# include "BKE_main.h" +# include "BKE_report.h" -#include "BLT_translation.h" +# include "BLI_path_util.h" +# include "BLI_string.h" +# include "BLI_utildefines.h" -#include "ED_outliner.h" +# include "BLT_translation.h" -#include "MEM_guardedalloc.h" +# include "ED_outliner.h" -#include "RNA_access.h" -#include "RNA_define.h" +# include "MEM_guardedalloc.h" -#include "UI_interface.h" -#include "UI_resources.h" +# include "RNA_access.h" +# include "RNA_define.h" -#include "WM_api.h" -#include "WM_types.h" +# include "UI_interface.h" +# include "UI_resources.h" -#include "DEG_depsgraph.h" +# include "WM_api.h" +# include "WM_types.h" -#include "IO_path_util_types.h" -#include "IO_wavefront_obj.h" -#include "io_obj.h" +# include "DEG_depsgraph.h" -static const EnumPropertyItem io_obj_transform_axis_forward[] = { - {OBJ_AXIS_X_FORWARD, "X_FORWARD", 0, "X", "Positive X axis"}, - {OBJ_AXIS_Y_FORWARD, "Y_FORWARD", 0, "Y", "Positive Y axis"}, - {OBJ_AXIS_Z_FORWARD, "Z_FORWARD", 0, "Z", "Positive Z axis"}, - {OBJ_AXIS_NEGATIVE_X_FORWARD, "NEGATIVE_X_FORWARD", 0, "-X", "Negative X axis"}, - {OBJ_AXIS_NEGATIVE_Y_FORWARD, "NEGATIVE_Y_FORWARD", 0, "-Y", "Negative Y axis"}, - {OBJ_AXIS_NEGATIVE_Z_FORWARD, "NEGATIVE_Z_FORWARD", 0, "-Z", "Negative Z axis"}, - {0, NULL, 0, NULL, NULL}}; - -static const EnumPropertyItem io_obj_transform_axis_up[] = { - {OBJ_AXIS_X_UP, "X_UP", 0, "X", "Positive X axis"}, - {OBJ_AXIS_Y_UP, "Y_UP", 0, "Y", "Positive Y axis"}, - {OBJ_AXIS_Z_UP, "Z_UP", 0, "Z", "Positive Z axis"}, - {OBJ_AXIS_NEGATIVE_X_UP, "NEGATIVE_X_UP", 0, "-X", "Negative X axis"}, - {OBJ_AXIS_NEGATIVE_Y_UP, "NEGATIVE_Y_UP", 0, "-Y", "Negative Y axis"}, - {OBJ_AXIS_NEGATIVE_Z_UP, "NEGATIVE_Z_UP", 0, "-Z", "Negative Z axis"}, - {0, NULL, 0, NULL, NULL}}; +# include "IO_orientation.h" +# include "IO_path_util_types.h" +# include "IO_wavefront_obj.h" +# include "io_obj.h" static const EnumPropertyItem io_obj_export_evaluation_mode[] = { {DAG_EVAL_RENDER, "DAG_EVAL_RENDER", 0, "Render", "Export objects as they appear in render"}, @@ -115,6 +100,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op) export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects"); export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv"); export_params.export_normals = RNA_boolean_get(op->ptr, "export_normals"); + export_params.export_colors = RNA_boolean_get(op->ptr, "export_colors"); export_params.export_materials = RNA_boolean_get(op->ptr, "export_materials"); export_params.path_mode = RNA_enum_get(op->ptr, "path_mode"); export_params.export_triangulated_mesh = RNA_boolean_get(op->ptr, "export_triangulated_mesh"); @@ -175,6 +161,7 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr) sub = uiLayoutColumnWithHeading(col, false, IFACE_("Export")); uiItemR(sub, imfptr, "export_uv", 0, IFACE_("UV Coordinates"), ICON_NONE); uiItemR(sub, imfptr, "export_normals", 0, IFACE_("Normals"), ICON_NONE); + uiItemR(sub, imfptr, "export_colors", 0, IFACE_("Colors"), ICON_NONE); uiItemR(sub, imfptr, "export_materials", 0, IFACE_("Materials"), ICON_NONE); uiItemR(sub, imfptr, "export_triangulated_mesh", 0, IFACE_("Triangulated Mesh"), ICON_NONE); uiItemR(sub, imfptr, "export_curves_as_nurbs", 0, IFACE_("Curves as NURBS"), ICON_NONE); @@ -221,11 +208,11 @@ static bool wm_obj_export_check(bContext *C, wmOperator *op) int end = RNA_int_get(op->ptr, "end_frame"); /* Set the defaults. */ if (start == INT_MIN) { - start = SFRA; + start = scene->r.sfra; changed = true; } if (end == INT_MAX) { - end = EFRA; + end = scene->r.efra; changed = true; } /* Fix user errors. */ @@ -261,7 +248,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) ot->ui = wm_obj_export_draw; ot->check = wm_obj_export_check; - ot->flag |= OPTYPE_PRESET; + ot->flag = OPTYPE_PRESET; WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER, @@ -279,7 +266,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) "Export multiple frames instead of the current frame only"); RNA_def_int(ot->srna, "start_frame", - INT_MIN, /* wm_obj_export_check uses this to set SFRA. */ + INT_MIN, /* wm_obj_export_check uses this to set scene->r.sfra. */ INT_MIN, INT_MAX, "Start Frame", @@ -288,7 +275,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) INT_MAX); RNA_def_int(ot->srna, "end_frame", - INT_MAX, /* wm_obj_export_check uses this to set EFRA. */ + INT_MAX, /* wm_obj_export_check uses this to set scene->r.efra. */ INT_MIN, INT_MAX, "End Frame", @@ -296,13 +283,9 @@ void WM_OT_obj_export(struct wmOperatorType *ot) INT_MIN, INT_MAX); /* Object transform options. */ - RNA_def_enum(ot->srna, - "forward_axis", - io_obj_transform_axis_forward, - OBJ_AXIS_NEGATIVE_Z_FORWARD, - "Forward Axis", - ""); - RNA_def_enum(ot->srna, "up_axis", io_obj_transform_axis_up, OBJ_AXIS_Y_UP, "Up Axis", ""); + RNA_def_enum( + ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", ""); + RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); RNA_def_float(ot->srna, "scaling_factor", 1.0f, @@ -334,6 +317,7 @@ void WM_OT_obj_export(struct wmOperatorType *ot) "Export Normals", "Export per-face normals if the face is flat-shaded, per-face-per-loop " "normals if smooth-shaded"); + RNA_def_boolean(ot->srna, "export_colors", false, "Export Colors", "Export per-vertex colors"); RNA_def_boolean(ot->srna, "export_materials", true, @@ -408,6 +392,7 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op) import_params.clamp_size = RNA_float_get(op->ptr, "clamp_size"); import_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis"); import_params.up_axis = RNA_enum_get(op->ptr, "up_axis"); + import_params.import_vertex_groups = RNA_boolean_get(op->ptr, "import_vertex_groups"); import_params.validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes"); OBJ_import(C, &import_params); @@ -438,6 +423,7 @@ static void ui_obj_import_settings(uiLayout *layout, PointerRNA *imfptr) box = uiLayoutBox(layout); uiItemL(box, IFACE_("Options"), ICON_EXPORT); col = uiLayoutColumn(box, false); + uiItemR(col, imfptr, "import_vertex_groups", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE); } @@ -456,6 +442,7 @@ void WM_OT_obj_import(struct wmOperatorType *ot) ot->name = "Import Wavefront OBJ"; ot->description = "Load a Wavefront OBJ scene"; ot->idname = "WM_OT_obj_import"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->invoke = wm_obj_import_invoke; ot->exec = wm_obj_import_exec; @@ -479,13 +466,14 @@ void WM_OT_obj_import(struct wmOperatorType *ot) "Resize the objects to keep bounding box under this value. Value 0 disables clamping", 0.0f, 1000.0f); - RNA_def_enum(ot->srna, - "forward_axis", - io_obj_transform_axis_forward, - OBJ_AXIS_NEGATIVE_Z_FORWARD, - "Forward Axis", - ""); - RNA_def_enum(ot->srna, "up_axis", io_obj_transform_axis_up, OBJ_AXIS_Y_UP, "Up Axis", ""); + RNA_def_enum( + ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", ""); + RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", ""); + RNA_def_boolean(ot->srna, + "import_vertex_groups", + false, + "Vertex Groups", + "Import OBJ groups as vertex groups"); RNA_def_boolean(ot->srna, "validate_meshes", false, @@ -496,3 +484,5 @@ void WM_OT_obj_import(struct wmOperatorType *ot) prop = RNA_def_string(ot->srna, "filter_glob", "*.obj;*.mtl", 0, "Extension Filter", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } + +#endif /* WITH_IO_WAVEFRONT_OBJ */ |