9#ifdef WITH_IO_WAVEFRONT_OBJ
45 {
DAG_EVAL_RENDER,
"DAG_EVAL_RENDER", 0,
"Render",
"Export objects as they appear in render"},
50 "Export objects as they appear in the viewport"},
51 {0,
nullptr, 0,
nullptr,
nullptr}};
60 {0,
nullptr, 0,
nullptr,
nullptr}};
166 col = &
col->column(
false);
186 panel = layout->
panel(
C,
"OBJ_export_animation",
true);
201 ui_obj_export_settings(
C, op->
layout, op->
ptr);
211 bool changed =
false;
224 if (start == INT_MIN) {
225 start = scene->
r.
sfra;
228 if (end == INT_MAX) {
247 ot->name =
"Export Wavefront OBJ";
248 ot->description =
"Save the scene to a Wavefront OBJ file";
249 ot->idname =
"WM_OT_obj_export";
251 ot->invoke = wm_obj_export_invoke;
252 ot->exec = wm_obj_export_exec;
254 ot->ui = wm_obj_export_draw;
255 ot->check = wm_obj_export_check;
272 "Export multiple frames instead of the current frame only");
279 "The first frame to be exported",
288 "The last frame to be exported",
304 "Value by which to enlarge or shrink the objects with respect to the world's origin",
309 ot->srna,
"apply_modifiers",
true,
"Apply Modifiers",
"Apply modifiers to exported meshes");
312 io_obj_export_evaluation_mode,
315 "Determines properties like object visibility, modifiers etc., where they differ "
316 "for Render and Viewport");
318 "export_selected_objects",
320 "Export Selected Objects",
321 "Export only selected objects instead of all supported objects");
327 "Export per-face normals if the face is flat-shaded, per-face-corner "
328 "normals if smooth-shaded");
329 RNA_def_boolean(
ot->srna,
"export_colors",
false,
"Export Colors",
"Export per-vertex colors");
334 "Export MTL library. There must be a Principled-BSDF node for image textures to "
335 "be exported to the MTL file");
337 "export_pbr_extensions",
339 "Export Materials with PBR Extensions",
340 "Export MTL library using PBR extensions (roughness, metallic, sheen, "
341 "coat, anisotropy, transmission)");
347 "Method used to reference paths");
350 "export_triangulated_mesh",
352 "Export Triangulated Mesh",
353 "All ngons with four or more vertices will be triangulated. Meshes in "
354 "the scene will not be affected. Behaves like Triangulate Modifier with "
355 "ngon-method: \"Beauty\", quad-method: \"Shortest Diagonal\", min vertices: 4");
357 "export_curves_as_nurbs",
359 "Export Curves as NURBS",
360 "Export curves in parametric form instead of exporting as mesh");
363 "export_object_groups",
365 "Export Object Groups",
366 "Append mesh name to object name, separated by a '_'");
368 "export_material_groups",
370 "Export Material Groups",
371 "Generate an OBJ group for each part of a geometry using a different material");
374 "export_vertex_groups",
376 "Export Vertex Groups",
377 "Export the name of the vertex group of a face. It is approximated "
378 "by choosing the vertex group with the most members among the vertices of a face");
380 "export_smooth_groups",
382 "Export Smooth Groups",
383 "Generate smooth groups identifiers for each group of smooth faces, as "
384 "unique integer values by default");
387 "smooth_group_bitflags",
389 "Bitflags Smooth Groups",
390 "If exporting smoothgroups, generate 'bitflags' values for the groups, instead of "
391 "unique integer values. The same bitflag value can be re-used for different groups of "
392 "smooth faces, as long as they have no common sharp edges or vertices");
395 prop =
RNA_def_string(
ot->srna,
"filter_glob",
"*.obj;*.mtl", 0,
"Extension Filter",
"");
414 char separator[2] = {};
424 if (paths.is_empty()) {
428 for (
const auto &path : paths) {
470 ui_obj_import_settings(
C, op->
layout, op->
ptr);
477 ot->name =
"Import Wavefront OBJ";
478 ot->description =
"Load a Wavefront OBJ scene";
479 ot->idname =
"WM_OT_obj_import";
483 ot->exec = wm_obj_import_exec;
485 ot->ui = wm_obj_import_draw;
503 "Value by which to enlarge or shrink the objects with respect to the world's origin",
512 "Clamp Bounding Box",
513 "Resize the objects to keep bounding box under this value. Value 0 disables clamping",
525 "Import each OBJ 'o' as a separate object");
530 "Import each OBJ 'g' as a separate object");
532 "import_vertex_groups",
535 "Import OBJ groups as vertex groups");
541 "Ensure the data is valid "
542 "(when disabled, data may be imported which causes crashes displaying or editing)");
544 "close_spline_loops",
546 "Detect Cyclic Curves",
547 "Join curve endpoints if overlapping control points are detected "
548 "(if disabled, no curves will be cyclic)");
551 "collection_separator",
555 "Character used to separate objects name into hierarchical structure");
558 prop =
RNA_def_string(
ot->srna,
"filter_glob",
"*.obj;*.mtl", 0,
"Extension Filter",
"");
565 auto fh = std::make_unique<blender::bke::FileHandlerType>();
566 STRNCPY(fh->idname,
"IO_FH_obj");
567 STRNCPY(fh->import_operator,
"WM_OT_obj_import");
568 STRNCPY(fh->export_operator,
"WM_OT_obj_export");
569 STRNCPY(fh->label,
"Wavefront OBJ");
570 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
char * STRNCPY(char(&dst)[N], const char *src)
#define BLT_I18NCONTEXT_EDITOR_FILEBROWSER
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)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
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)
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
void obj_file_handler_add()
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_translation_context(PropertyRNA *prop, const char *context)
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 collection[MAX_IDPROP_NAME]
bool export_triangulated_mesh
eEvaluationMode export_eval_mode
bool export_curves_as_nurbs
bool export_material_groups
bool smooth_groups_bitflags
const char * blen_filepath
bool export_selected_objects
char file_base_for_tests[FILE_MAX]
bool export_object_groups
bool export_vertex_groups
bool export_pbr_extensions
ePathReferenceMode path_mode
bool export_smooth_groups
bool import_vertex_groups
char collection_separator
PanelLayout panel(const bContext *C, blender::StringRef idname, bool default_closed)
void label(blender::StringRef name, int icon)
uiLayout & column(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
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)