9#ifdef WITH_IO_WAVEFRONT_OBJ
48 {
DAG_EVAL_RENDER,
"DAG_EVAL_RENDER", 0,
"Render",
"Export objects as they appear in render"},
53 "Export objects as they appear in the viewport"},
54 {0,
nullptr, 0,
nullptr,
nullptr}};
63 {0,
nullptr, 0,
nullptr,
nullptr}};
93 export_params.export_selected_objects =
RNA_boolean_get(op->
ptr,
"export_selected_objects");
99 export_params.export_triangulated_mesh =
RNA_boolean_get(op->
ptr,
"export_triangulated_mesh");
100 export_params.export_curves_as_nurbs =
RNA_boolean_get(op->
ptr,
"export_curves_as_nurbs");
101 export_params.export_pbr_extensions =
RNA_boolean_get(op->
ptr,
"export_pbr_extensions");
103 export_params.export_object_groups =
RNA_boolean_get(op->
ptr,
"export_object_groups");
104 export_params.export_material_groups =
RNA_boolean_get(op->
ptr,
"export_material_groups");
105 export_params.export_vertex_groups =
RNA_boolean_get(op->
ptr,
"export_vertex_groups");
106 export_params.export_smooth_groups =
RNA_boolean_get(op->
ptr,
"export_smooth_groups");
107 export_params.smooth_groups_bitflags =
RNA_boolean_get(op->
ptr,
"smooth_group_bitflags");
109 export_params.reports = op->
reports;
153 "export_triangulated_mesh",
155 IFACE_(
"Triangulated Mesh"),
174 "smooth_group_bitflags",
176 IFACE_(
"Smooth Group Bitflags"),
194 panel =
uiLayoutPanel(C, layout,
"OBJ_export_animation",
true);
209 ui_obj_export_settings(C, op->
layout, op->
ptr);
219 bool changed =
false;
232 if (start == INT_MIN) {
233 start = scene->r.sfra;
236 if (end == INT_MAX) {
255 ot->
name =
"Export Wavefront OBJ";
260 ot->
exec = wm_obj_export_exec;
262 ot->
ui = wm_obj_export_draw;
263 ot->
check = wm_obj_export_check;
280 "Export multiple frames instead of the current frame only");
287 "The first frame to be exported",
296 "The last frame to be exported",
312 "Value by which to enlarge or shrink the objects with respect to the world's origin",
317 ot->
srna,
"apply_modifiers",
true,
"Apply Modifiers",
"Apply modifiers to exported meshes");
320 io_obj_export_evaluation_mode,
323 "Determines properties like object visibility, modifiers etc., where they differ "
324 "for Render and Viewport");
326 "export_selected_objects",
328 "Export Selected Objects",
329 "Export only selected objects instead of all supported objects");
335 "Export per-face normals if the face is flat-shaded, per-face-per-loop "
336 "normals if smooth-shaded");
342 "Export MTL library. There must be a Principled-BSDF node for image textures to "
343 "be exported to the MTL file");
345 "export_pbr_extensions",
347 "Export Materials with PBR Extensions",
348 "Export MTL library using PBR extensions (roughness, metallic, sheen, "
349 "coat, anisotropy, transmission)");
355 "Method used to reference paths");
357 "export_triangulated_mesh",
359 "Export Triangulated Mesh",
360 "All ngons with four or more vertices will be triangulated. Meshes in "
361 "the scene will not be affected. Behaves like Triangulate Modifier with "
362 "ngon-method: \"Beauty\", quad-method: \"Shortest Diagonal\", min vertices: 4");
364 "export_curves_as_nurbs",
366 "Export Curves as NURBS",
367 "Export curves in parametric form instead of exporting as mesh");
370 "export_object_groups",
372 "Export Object Groups",
373 "Append mesh name to object name, separated by a '_'");
375 "export_material_groups",
377 "Export Material Groups",
378 "Generate an OBJ group for each part of a geometry using a different material");
381 "export_vertex_groups",
383 "Export Vertex Groups",
384 "Export the name of the vertex group of a face. It is approximated "
385 "by choosing the vertex group with the most members among the vertices of a face");
388 "export_smooth_groups",
390 "Export Smooth Groups",
391 "Every smooth-shaded face is assigned group \"1\" and every flat-shaded face \"off\"");
393 ot->
srna,
"smooth_group_bitflags",
false,
"Generate Bitflags for Smooth Groups",
"");
412 import_params.import_vertex_groups =
RNA_boolean_get(op->
ptr,
"import_vertex_groups");
414 char separator[2] = {};
416 import_params.collection_separator = separator[0];
418 import_params.clear_selection =
true;
420 import_params.reports = op->
reports;
424 if (paths.is_empty()) {
428 for (
const auto &path : paths) {
429 STRNCPY(import_params.filepath, path.c_str());
432 import_params.clear_selection =
false;
469 ui_obj_import_settings(C, op->
layout, op->
ptr);
476 ot->
name =
"Import Wavefront OBJ";
482 ot->
exec = wm_obj_import_exec;
484 ot->
ui = wm_obj_import_draw;
502 "Value by which to enlarge or shrink the objects with respect to the world's origin",
511 "Clamp Bounding Box",
512 "Resize the objects to keep bounding box under this value. Value 0 disables clamping",
524 "Import each OBJ 'o' as a separate object");
529 "Import each OBJ 'g' as a separate object");
531 "import_vertex_groups",
534 "Import OBJ groups as vertex groups");
540 "Ensure the data is valid "
541 "(when disabled, data may be imported which causes crashes displaying or editing)");
544 "collection_separator",
548 "Character used to separate objects name into hierarchical structure");
558 auto fh = std::make_unique<blender::bke::FileHandlerType>();
559 STRNCPY(fh->idname,
"IO_FH_obj");
560 STRNCPY(fh->import_operator,
"WM_OT_obj_import");
561 STRNCPY(fh->export_operator,
"WM_OT_obj_export");
562 STRNCPY(fh->label,
"Wavefront OBJ");
563 STRNCPY(fh->file_extensions_str,
".obj");
SpaceFile * CTX_wm_space_file(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
bool BKE_reports_contain(ReportList *reports, eReportType level)
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
#define STRNCPY(dst, src)
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
void ED_outliner_select_sync_from_object_tag(bContext *C)
@ PATH_REFERENCE_RELATIVE
@ PATH_REFERENCE_ABSOLUTE
void OBJ_import(bContext *C, const OBJImportParams *import_params)
void OBJ_export(bContext *C, const OBJExportParams *export_params)
Read Guarded memory(de)allocation.
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
PanelLayout uiLayoutPanel(const bContext *C, uiLayout *layout, const char *idname, bool default_closed)
uiLayout * uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *heading)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
void WM_OT_obj_import(wmOperatorType *ot)
void WM_OT_obj_export(wmOperatorType *ot)
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, blender::bke::FileHandlerType *)
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
void obj_file_handler_add()
int filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
const EnumPropertyItem io_transform_axis[]
void io_ui_forward_axis_update(Main *, Scene *, PointerRNA *ptr)
void io_ui_up_axis_update(Main *, Scene *, PointerRNA *ptr)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_update_runtime(PropertyRNA *prop, RNAPropertyUpdateFunc func)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
char file_base_for_tests[FILE_MAX]
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
bool(* check)(bContext *C, wmOperator *op)
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
struct ReportList * reports
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
bool WM_operator_winactive(bContext *C)