9#ifdef WITH_IO_WAVEFRONT_OBJ
47 {
DAG_EVAL_RENDER,
"DAG_EVAL_RENDER", 0,
"Render",
"Export objects as they appear in render"},
52 "Export objects as they appear in the viewport"},
53 {0,
nullptr, 0,
nullptr,
nullptr}};
62 {0,
nullptr, 0,
nullptr,
nullptr}};
69 "Create new materials with unique names for each OBJ file"},
74 "Use existing materials with same name instead of creating new ones"},
75 {0,
nullptr, 0,
nullptr,
nullptr}};
183 col = &
col->column(
false);
184 col->enabled_set(export_smooth_groups);
196 col->enabled_set(export_materials);
203 panel = layout->
panel(
C,
"OBJ_export_animation",
true);
209 col->enabled_set(export_animation);
218 ui_obj_export_settings(
C, op->
layout, op->
ptr);
228 bool changed =
false;
241 if (start == INT_MIN) {
242 start = scene->
r.
sfra;
245 if (end == INT_MAX) {
264 ot->name =
"Export Wavefront OBJ";
265 ot->description =
"Save the scene to a Wavefront OBJ file";
266 ot->idname =
"WM_OT_obj_export";
268 ot->invoke = wm_obj_export_invoke;
269 ot->exec = wm_obj_export_exec;
271 ot->ui = wm_obj_export_draw;
272 ot->check = wm_obj_export_check;
289 "Export multiple frames instead of the current frame only");
296 "The first frame to be exported",
305 "The last frame to be exported",
321 "Value by which to enlarge or shrink the objects with respect to the world's origin",
326 ot->srna,
"apply_modifiers",
true,
"Apply Modifiers",
"Apply modifiers to exported meshes");
331 "Apply object transforms to exported vertices");
334 io_obj_export_evaluation_mode,
337 "Determines properties like object visibility, modifiers etc., where they differ "
338 "for Render and Viewport");
340 "export_selected_objects",
342 "Export Selected Objects",
343 "Export only selected objects instead of all supported objects");
349 "Export per-face normals if the face is flat-shaded, per-face-corner "
350 "normals if smooth-shaded");
351 RNA_def_boolean(
ot->srna,
"export_colors",
false,
"Export Colors",
"Export per-vertex colors");
356 "Export MTL library. There must be a Principled-BSDF node for image textures to "
357 "be exported to the MTL file");
359 "export_pbr_extensions",
361 "Export Materials with PBR Extensions",
362 "Export MTL library using PBR extensions (roughness, metallic, sheen, "
363 "coat, anisotropy, transmission)");
369 "Method used to reference paths");
372 "export_triangulated_mesh",
374 "Export Triangulated Mesh",
375 "All ngons with four or more vertices will be triangulated. Meshes in "
376 "the scene will not be affected. Behaves like Triangulate Modifier with "
377 "ngon-method: \"Beauty\", quad-method: \"Shortest Diagonal\", min vertices: 4");
379 "export_curves_as_nurbs",
381 "Export Curves as NURBS",
382 "Export curves in parametric form instead of exporting as mesh");
385 "export_object_groups",
387 "Export Object Groups",
388 "Append mesh name to object name, separated by a '_'");
390 "export_material_groups",
392 "Export Material Groups",
393 "Generate an OBJ group for each part of a geometry using a different material");
396 "export_vertex_groups",
398 "Export Vertex Groups",
399 "Export the name of the vertex group of a face. It is approximated "
400 "by choosing the vertex group with the most members among the vertices of a face");
402 "export_smooth_groups",
404 "Export Smooth Groups",
405 "Generate smooth groups identifiers for each group of smooth faces, as "
406 "unique integer values by default");
409 "smooth_group_bitflags",
411 "Bitflags Smooth Groups",
412 "If exporting smoothgroups, generate 'bitflags' values for the groups, instead of "
413 "unique integer values. The same bitflag value can be re-used for different groups of "
414 "smooth faces, as long as they have no common sharp edges or vertices");
417 prop =
RNA_def_string(
ot->srna,
"filter_glob",
"*.obj;*.mtl", 0,
"Extension Filter",
"");
436 char separator[2] = {};
448 if (paths.is_empty()) {
452 for (
const auto &path : paths) {
499 ui_obj_import_settings(
C, op->
layout, op->
ptr);
506 ot->name =
"Import Wavefront OBJ";
507 ot->description =
"Load a Wavefront OBJ scene";
508 ot->idname =
"WM_OT_obj_import";
512 ot->exec = wm_obj_import_exec;
514 ot->ui = wm_obj_import_draw;
532 "Value by which to enlarge or shrink the objects with respect to the world's origin",
541 "Clamp Bounding Box",
542 "Resize the objects to keep bounding box under this value. Value 0 disables clamping",
554 "Import each OBJ 'o' as a separate object");
559 "Import each OBJ 'g' as a separate object");
561 "import_vertex_groups",
564 "Import OBJ groups as vertex groups");
570 "Ensure the data is valid "
571 "(when disabled, data may be imported which causes crashes displaying or editing)");
573 "close_spline_loops",
575 "Detect Cyclic Curves",
576 "Join curve endpoints if overlapping control points are detected "
577 "(if disabled, no curves will be cyclic)");
580 "collection_separator",
584 "Character used to separate objects name into hierarchical structure");
588 "mtl_name_collision_mode",
589 io_obj_mtl_name_collision_mode,
591 "Material Name Collision",
592 "How to handle naming collisions when importing materials");
595 prop =
RNA_def_string(
ot->srna,
"filter_glob",
"*.obj;*.mtl", 0,
"Extension Filter",
"");
602 auto fh = std::make_unique<blender::bke::FileHandlerType>();
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 STRNCPY_UTF8(dst, 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)
@ OBJ_MTL_NAME_COLLISION_MAKE_UNIQUE
@ OBJ_MTL_NAME_COLLISION_REFERENCE_EXISTING
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)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
std::string RNA_string_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)
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
char collection[MAX_ID_NAME - 2]
bool export_vertex_groups
bool export_pbr_extensions
ePathReferenceMode path_mode
bool export_smooth_groups
eOBJMtlNameCollisionMode mtl_name_collision_mode
bool import_vertex_groups
char collection_separator
void use_property_decorate_set(bool is_sep)
PanelLayout panel(const bContext *C, blender::StringRef idname, bool default_closed)
void label(blender::StringRef name, int icon)
uiLayout & column(bool align)
void use_property_split_set(bool value)
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)