diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/CMakeLists.txt | 1 | ||||
-rwxr-xr-x | source/blender/editors/io/CMakeLists.txt | 42 | ||||
-rw-r--r-- | source/blender/editors/io/io_collada.c | 280 | ||||
-rwxr-xr-x | source/blender/editors/io/io_collada.h | 35 | ||||
-rwxr-xr-x | source/blender/editors/io/io_ops.c | 38 | ||||
-rwxr-xr-x | source/blender/editors/io/io_ops.h | 31 | ||||
-rw-r--r-- | source/blender/editors/space_api/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/space_api/spacetypes.c | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 242 | ||||
-rw-r--r-- | source/creator/CMakeLists.txt | 1 |
11 files changed, 433 insertions, 242 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 67ed77bcc4b..084006ce277 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -24,6 +24,7 @@ if(WITH_BLENDER) add_subdirectory(curve) add_subdirectory(gpencil) add_subdirectory(interface) + add_subdirectory(io) add_subdirectory(mask) add_subdirectory(mesh) add_subdirectory(metaball) diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt new file mode 100755 index 00000000000..ceacf8f4ad1 --- /dev/null +++ b/source/blender/editors/io/CMakeLists.txt @@ -0,0 +1,42 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Gaia Clary. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenfont + ../../blenkernel + ../../blenlib + ../../blenloader + ../../bmesh + ../../makesdna + ../../makesrna + ../../windowmanager + ../../collada +) + +set(SRC + io_collada.c + io_ops.c + + io_collada.h + io_ops.h +) + +blender_add_lib(bf_editor_io "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c new file mode 100644 index 00000000000..699b89fd42e --- /dev/null +++ b/source/blender/editors/io/io_collada.c @@ -0,0 +1,280 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/collada.c + * \ingroup collada + */ + +#include "DNA_scene_types.h" + +#include "BLF_translation.h" + +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_report.h" + +#include "ED_screen.h" +#include "ED_object.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "../../collada/collada.h" + +static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + char filepath[FILE_MAX]; + + if (G.main->name[0] == 0) + BLI_strncpy(filepath, "untitled", sizeof(filepath)); + else + BLI_strncpy(filepath, G.main->name, sizeof(filepath)); + + BLI_replace_extension(filepath, sizeof(filepath), ".dae"); + RNA_string_set(op->ptr, "filepath", filepath); + } + + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_export_exec(bContext *C, wmOperator *op) +{ + char filepath[FILE_MAX]; + int apply_modifiers; + int export_mesh_type; + int selected; + int include_children; + int include_armatures; + int deform_bones_only; + int use_object_instantiation; + int sort_by_name; + int second_life; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filepath); + BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); + + /* Options panel */ + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); + 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"); + deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only"); + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); + second_life = RNA_boolean_get(op->ptr, "second_life"); + + /* get editmode results */ + ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + + if (collada_export( + CTX_data_scene(C), + filepath, + apply_modifiers, + export_mesh_type, + selected, + include_children, + include_armatures, + deform_bones_only, + use_object_instantiation, + sort_by_name, + second_life)) { + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) +{ + uiLayout *box, *row, *col, *sub, *split; + + /* Export Options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); + + row = uiLayoutRow(box, 0); + col = uiLayoutColumn(row, 0); + split = uiLayoutSplit(col, 0.5f, 0); + uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); + sub = uiLayoutRow(split, 0); + uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); + uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers")); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); + + row = uiLayoutRow(box, 0); + col = uiLayoutColumn(row, 0); + split = uiLayoutSplit(col, 0.1f, 0); + sub = uiLayoutRow(split, 0); + uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + row = uiLayoutRow(box, 0); + col = uiLayoutColumn(row, 0); + split = uiLayoutSplit(col, 0.1f, 0); + sub = uiLayoutRow(split, 0); + uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE); + uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); + + + // Armature options + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); + + /* Collada options: */ + box = uiLayoutBox(layout); + row = uiLayoutRow(box, 0); + uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); + + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); + row = uiLayoutRow(box, 0); + uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); + +} + +static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) +{ + PointerRNA ptr; + + RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); + uiCollada_exportSettings(op->layout, &ptr); +} + +void WM_OT_collada_export(wmOperatorType *ot) +{ + static EnumPropertyItem prop_bc_export_mesh_type[] = { + {BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"}, + {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, + {0, NULL, 0, NULL, NULL} + }; + + ot->name = "Export COLLADA"; + ot->description = "Save a Collada file"; + ot->idname = "WM_OT_collada_export"; + + ot->invoke = wm_collada_export_invoke; + ot->exec = wm_collada_export_exec; + ot->poll = WM_operator_winactive; + + ot->flag |= OPTYPE_PRESET; + + ot->ui = wm_collada_export_draw; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + + RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers"); + + RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, + "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); + + RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, 0, + "Resolution", "Modifier resolution for export"); + + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", + "Export only selected elements"); + + RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", + "Export all children of selected objects (even if not selected)"); + + RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", + "Export related armatures (even if not selected)"); + + RNA_def_boolean(ot->srna, "deform_bones_only", 0, "Deform Bones only", + "Only export deforming bones with armatures"); + + + RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", + "Instantiate multiple Objects from same Data"); + + RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", + "Sort exported data by Object name"); + + RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", + "Compatibility mode for Second Life"); +} + + +/* function used for WM_OT_save_mainfile too */ +static int wm_collada_import_exec(bContext *C, wmOperator *op) +{ + char filename[FILE_MAX]; + + if (!RNA_struct_property_is_set(op->ptr, "filepath")) { + BKE_report(op->reports, RPT_ERROR, "No filename given"); + return OPERATOR_CANCELLED; + } + + RNA_string_get(op->ptr, "filepath", filename); + if (collada_import(C, filename)) return OPERATOR_FINISHED; + + BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); + + return OPERATOR_FINISHED; +} + +void WM_OT_collada_import(wmOperatorType *ot) +{ + ot->name = "Import COLLADA"; + ot->description = "Load a Collada file"; + ot->idname = "WM_OT_collada_import"; + + ot->invoke = WM_operator_filesel; + ot->exec = wm_collada_import_exec; + ot->poll = WM_operator_winactive; + + WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); +}
\ No newline at end of file diff --git a/source/blender/editors/io/io_collada.h b/source/blender/editors/io/io_collada.h new file mode 100755 index 00000000000..4f53ec99de0 --- /dev/null +++ b/source/blender/editors/io/io_collada.h @@ -0,0 +1,35 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +#include "WM_types.h" +#include "WM_api.h" + +extern void WM_OT_collada_export(wmOperatorType *ot); +extern void WM_OT_collada_import(wmOperatorType *ot); diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c new file mode 100755 index 00000000000..ed9b134b546 --- /dev/null +++ b/source/blender/editors/io/io_ops.c @@ -0,0 +1,38 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2008 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/io/io_ops.c + * \ingroup collada + */ + +#include "io_collada.h" + +void ED_operatortypes_io(void) +{ + // Collada operators: + WM_operatortype_append(WM_OT_collada_export); + WM_operatortype_append(WM_OT_collada_import); +} diff --git a/source/blender/editors/io/io_ops.h b/source/blender/editors/io/io_ops.h new file mode 100755 index 00000000000..a3af47c3928 --- /dev/null +++ b/source/blender/editors/io/io_ops.h @@ -0,0 +1,31 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2007 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editor/io/io_collada.h + * \ingroup editor/io + */ + +extern void ED_operatortypes_io(void);
\ No newline at end of file diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt index 137cda9c285..0abdd134046 100644 --- a/source/blender/editors/space_api/CMakeLists.txt +++ b/source/blender/editors/space_api/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../io ../../blenkernel ../../blenlib ../../blenloader diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index fa77249a7a1..e4fd3dca570 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -64,6 +64,8 @@ #include "ED_clip.h" #include "ED_mask.h" +#include "IO_ops.h" + /* only call once on startup, storage is global in BKE kernel listbase */ void ED_spacetypes_init(void) { @@ -113,6 +115,7 @@ void ED_spacetypes_init(void) ED_operatortypes_render(); ED_operatortypes_logic(); ED_operatortypes_mask(); + ED_operatortypes_io(); UI_view2d_operatortypes(); UI_buttons_operatortypes(); diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index 2a1a1d5649d..275aeb3317c 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../blenlib ../blenloader ../editors/include + ../editors/io ../gpu ../imbuf ../makesdna diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index bc004e189ea..639039baaa7 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2134,242 +2134,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } -/* XXX: move these collada operators to a more appropriate place */ -#ifdef WITH_COLLADA - -#include "../../collada/collada.h" - -static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) -{ - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - char filepath[FILE_MAX]; - - if (G.main->name[0] == 0) - BLI_strncpy(filepath, "untitled", sizeof(filepath)); - else - BLI_strncpy(filepath, G.main->name, sizeof(filepath)); - - BLI_replace_extension(filepath, sizeof(filepath), ".dae"); - RNA_string_set(op->ptr, "filepath", filepath); - } - - WM_event_add_fileselect(C, op); - - return OPERATOR_RUNNING_MODAL; -} - -/* function used for WM_OT_save_mainfile too */ -static int wm_collada_export_exec(bContext *C, wmOperator *op) -{ - char filepath[FILE_MAX]; - int apply_modifiers; - int export_mesh_type; - int selected; - int include_children; - int include_armatures; - int deform_bones_only; - int use_object_instantiation; - int sort_by_name; - int second_life; - - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - BKE_report(op->reports, RPT_ERROR, "No filename given"); - return OPERATOR_CANCELLED; - } - - RNA_string_get(op->ptr, "filepath", filepath); - BLI_ensure_extension(filepath, sizeof(filepath), ".dae"); - - /* Options panel */ - apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - export_mesh_type = RNA_enum_get(op->ptr, "export_mesh_type_selection"); - 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"); - deform_bones_only = RNA_boolean_get(op->ptr, "deform_bones_only"); - use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); - sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name"); - second_life = RNA_boolean_get(op->ptr, "second_life"); - - /* get editmode results */ - ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - - if (collada_export( - CTX_data_scene(C), - filepath, - apply_modifiers, - export_mesh_type, - selected, - include_children, - include_armatures, - deform_bones_only, - use_object_instantiation, - sort_by_name, - second_life)) { - return OPERATOR_FINISHED; - } - else { - return OPERATOR_CANCELLED; - } -} - - -void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) -{ - uiLayout *box, *row, *col, *sub, *split; - - /* Export Options: */ - box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); - uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); - - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.5f, 0); - uiItemR(split, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); - sub = uiLayoutRow(split, 0); - uiItemR(sub, imfptr, "export_mesh_type_selection", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); - uiLayoutSetEnabled(sub, RNA_boolean_get(imfptr, "apply_modifiers")); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); - - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.1f, 0); - sub = uiLayoutRow(split, 0); - uiItemR(split, imfptr, "include_children", 0, NULL, ICON_NONE); - uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - - row = uiLayoutRow(box, 0); - col = uiLayoutColumn(row, 0); - split = uiLayoutSplit(col, 0.1f, 0); - sub = uiLayoutRow(split, 0); - uiItemR(split, imfptr, "include_armatures", 0, NULL, ICON_NONE); - uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - - - // Armature options - box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); - uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "second_life", 0, NULL, ICON_NONE); - - /* Collada options: */ - box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); - uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); - - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); - row = uiLayoutRow(box, 0); - uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); - -} - -static void wm_collada_export_draw(bContext *UNUSED(C), wmOperator *op) -{ - PointerRNA ptr; - - RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); - uiCollada_exportSettings(op->layout, &ptr); -} - -static void WM_OT_collada_export(wmOperatorType *ot) -{ - static EnumPropertyItem prop_bc_export_mesh_type[] = { - {BC_MESH_TYPE_VIEW, "view", 0, "View", "Apply modifier's view settings"}, - {BC_MESH_TYPE_RENDER, "render", 0, "Render", "Apply modifier's render settings"}, - {0, NULL, 0, NULL, NULL} - }; - - ot->name = "Export COLLADA"; - ot->description = "Save a Collada file"; - ot->idname = "WM_OT_collada_export"; - - ot->invoke = wm_collada_export_invoke; - ot->exec = wm_collada_export_exec; - ot->poll = WM_operator_winactive; - - ot->flag |= OPTYPE_PRESET; - - ot->ui = wm_collada_export_draw; - - WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - - RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", - "Apply modifiers"); - - RNA_def_int(ot->srna, "export_mesh_type", 0, INT_MIN, INT_MAX, - "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX); - - RNA_def_enum(ot->srna, "export_mesh_type_selection", prop_bc_export_mesh_type, 0, - "Resolution", "Modifier resolution for export"); - - RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", - "Export only selected elements"); - - RNA_def_boolean(ot->srna, "include_children", 0, "Include Children", - "Export all children of selected objects (even if not selected)"); - - RNA_def_boolean(ot->srna, "include_armatures", 0, "Include Armatures", - "Export related armatures (even if not selected)"); - - RNA_def_boolean(ot->srna, "deform_bones_only", 0, "Deform Bones only", - "Only export deforming bones with armatures"); - - - RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instances", - "Instantiate multiple Objects from same Data"); - - RNA_def_boolean(ot->srna, "sort_by_name", 0, "Sort by Object name", - "Sort exported data by Object name"); - - RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", - "Compatibility mode for Second Life"); -} - - -/* function used for WM_OT_save_mainfile too */ -static int wm_collada_import_exec(bContext *C, wmOperator *op) -{ - char filename[FILE_MAX]; - - if (!RNA_struct_property_is_set(op->ptr, "filepath")) { - BKE_report(op->reports, RPT_ERROR, "No filename given"); - return OPERATOR_CANCELLED; - } - - RNA_string_get(op->ptr, "filepath", filename); - if (collada_import(C, filename)) return OPERATOR_FINISHED; - - BKE_report(op->reports, RPT_ERROR, "Errors found during parsing COLLADA document. Please see console for error log."); - - return OPERATOR_FINISHED; -} - -static void WM_OT_collada_import(wmOperatorType *ot) -{ - ot->name = "Import COLLADA"; - ot->description = "Load a Collada file"; - ot->idname = "WM_OT_collada_import"; - - ot->invoke = WM_operator_filesel; - ot->exec = wm_collada_import_exec; - ot->poll = WM_operator_winactive; - - WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); -} - -#endif - - -/* *********************** */ - static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) { ot->name = "Toggle Fullscreen"; @@ -3903,12 +3667,6 @@ void wm_operatortype_init(void) #if defined(WIN32) WM_operatortype_append(WM_OT_console_toggle); #endif - -#ifdef WITH_COLLADA - /* XXX: move these */ - WM_operatortype_append(WM_OT_collada_export); - WM_operatortype_append(WM_OT_collada_import); -#endif } /* circleselect-like modal operators */ diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 0e1a597386f..e8b951f3680 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -824,6 +824,7 @@ endif() bf_editor_animation bf_editor_datafiles bf_editor_mask + bf_editor_io bf_render bf_intern_opennl |