7 #ifdef WITH_IO_WAVEFRONT_OBJ
42 {
DAG_EVAL_RENDER,
"DAG_EVAL_RENDER", 0,
"Render",
"Export objects as they appear in render"},
47 "Export objects as they appear in the viewport"},
66 BLI_strncpy(filepath,
"untitled",
sizeof(filepath));
98 export_params.export_eval_mode =
RNA_enum_get(op->
ptr,
"export_eval_mode");
100 export_params.export_selected_objects =
RNA_boolean_get(op->
ptr,
"export_selected_objects");
106 export_params.export_triangulated_mesh =
RNA_boolean_get(op->
ptr,
"export_triangulated_mesh");
107 export_params.export_curves_as_nurbs =
RNA_boolean_get(op->
ptr,
"export_curves_as_nurbs");
109 export_params.export_object_groups =
RNA_boolean_get(op->
ptr,
"export_object_groups");
110 export_params.export_material_groups =
RNA_boolean_get(op->
ptr,
"export_material_groups");
111 export_params.export_vertex_groups =
RNA_boolean_get(op->
ptr,
"export_vertex_groups");
112 export_params.export_smooth_groups =
RNA_boolean_get(op->
ptr,
"export_smooth_groups");
113 export_params.smooth_groups_bitflags =
RNA_boolean_get(op->
ptr,
"smooth_group_bitflags");
136 uiItemR(sub, imfptr,
"export_selected_objects", 0,
IFACE_(
"Selected Only"), ICON_NONE);
137 uiItemR(sub, imfptr,
"scaling_factor", 0,
NULL, ICON_NONE);
147 uiItemR(sub, imfptr,
"apply_modifiers", 0,
IFACE_(
"Apply Modifiers"), ICON_NONE);
148 uiItemR(sub, imfptr,
"export_eval_mode", 0,
IFACE_(
"Properties"), ICON_NONE);
151 uiItemR(sub, imfptr,
"path_mode", 0,
IFACE_(
"Path Mode"), ICON_NONE);
158 uiItemR(sub, imfptr,
"export_uv", 0,
IFACE_(
"UV Coordinates"), ICON_NONE);
159 uiItemR(sub, imfptr,
"export_normals", 0,
IFACE_(
"Normals"), ICON_NONE);
160 uiItemR(sub, imfptr,
"export_colors", 0,
IFACE_(
"Colors"), ICON_NONE);
161 uiItemR(sub, imfptr,
"export_materials", 0,
IFACE_(
"Materials"), ICON_NONE);
162 uiItemR(sub, imfptr,
"export_triangulated_mesh", 0,
IFACE_(
"Triangulated Mesh"), ICON_NONE);
163 uiItemR(sub, imfptr,
"export_curves_as_nurbs", 0,
IFACE_(
"Curves as NURBS"), ICON_NONE);
170 uiItemR(sub, imfptr,
"export_object_groups", 0,
IFACE_(
"Object Groups"), ICON_NONE);
171 uiItemR(sub, imfptr,
"export_material_groups", 0,
IFACE_(
"Material Groups"), ICON_NONE);
172 uiItemR(sub, imfptr,
"export_vertex_groups", 0,
IFACE_(
"Vertex Groups"), ICON_NONE);
173 uiItemR(sub, imfptr,
"export_smooth_groups", 0,
IFACE_(
"Smooth Groups"), ICON_NONE);
176 uiItemR(sub, imfptr,
"smooth_group_bitflags", 0,
IFACE_(
"Smooth Group Bitflags"), ICON_NONE);
183 uiItemR(sub, imfptr,
"export_animation", 0,
NULL, ICON_NONE);
185 uiItemR(sub, imfptr,
"start_frame", 0,
IFACE_(
"Frame Start"), ICON_NONE);
186 uiItemR(sub, imfptr,
"end_frame", 0,
IFACE_(
"End"), ICON_NONE);
194 ui_obj_export_settings(op->
layout, &
ptr);
204 bool changed =
false;
217 if (start == INT_MIN) {
221 if (end == INT_MAX) {
243 if ((forward % 3) == (up % 3)) {
254 if ((forward % 3) == (up % 3)) {
263 ot->
name =
"Export Wavefront OBJ";
268 ot->
exec = wm_obj_export_exec;
270 ot->
ui = wm_obj_export_draw;
271 ot->
check = wm_obj_export_check;
288 "Export multiple frames instead of the current frame only");
295 "The first frame to be exported",
304 "The last frame to be exported",
319 "Upscale the object by this factor",
324 ot->
srna,
"apply_modifiers",
true,
"Apply Modifiers",
"Apply modifiers to exported meshes");
327 io_obj_export_evaluation_mode,
330 "Determines properties like object visibility, modifiers etc., where they differ "
331 "for Render and Viewport");
333 "export_selected_objects",
335 "Export Selected Objects",
336 "Export only selected objects instead of all supported objects");
342 "Export per-face normals if the face is flat-shaded, per-face-per-loop "
343 "normals if smooth-shaded");
349 "Export MTL library. There must be a Principled-BSDF node for image textures to "
350 "be exported to the MTL file");
356 "Method used to reference paths");
358 "export_triangulated_mesh",
360 "Export Triangulated Mesh",
361 "All ngons with four or more vertices will be triangulated. Meshes in "
362 "the scene will not be affected. Behaves like Triangulate Modifier with "
363 "ngon-method: \"Beauty\", quad-method: \"Shortest Diagonal\", min vertices: 4");
365 "export_curves_as_nurbs",
367 "Export Curves as NURBS",
368 "Export curves in parametric form instead of exporting as mesh");
371 "export_object_groups",
373 "Export Object Groups",
374 "Append mesh name to object name, separated by a '_'");
376 "export_material_groups",
378 "Export Material Groups",
379 "Generate an OBJ group for each part of a geometry using a different material");
382 "export_vertex_groups",
384 "Export Vertex Groups",
385 "Export the name of the vertex group of a face. It is approximated "
386 "by choosing the vertex group with the most members among the vertices of a face");
389 "export_smooth_groups",
391 "Export Smooth Groups",
392 "Every smooth-shaded face is assigned group \"1\" and every flat-shaded face \"off\"");
394 ot->
srna,
"smooth_group_bitflags",
false,
"Generate Bitflags for Smooth Groups",
"");
414 import_params.import_vertex_groups =
RNA_boolean_get(op->
ptr,
"import_vertex_groups");
417 import_params.clear_selection =
true;
428 for (
int i = 0; i < files_len; i++) {
432 import_params.filepath,
sizeof(import_params.filepath), dir_only, file_only);
433 import_params.clear_selection = (i == 0);
465 uiItemR(sub, imfptr,
"clamp_size", 0,
NULL, ICON_NONE);
485 ui_obj_import_settings(op->
layout, &
ptr);
492 ot->
name =
"Import Wavefront OBJ";
498 ot->
exec = wm_obj_import_exec;
500 ot->
ui = wm_obj_import_draw;
516 "Clamp Bounding Box",
517 "Resize the objects to keep bounding box under this value. Value 0 disables clamping",
526 "import_vertex_groups",
529 "Import OBJ groups as vertex groups");
534 "Check imported mesh objects for invalid data (slow)");
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BLI_path_extension_ensure(char *path, size_t maxlen, const char *ext) ATTR_NONNULL()
bool BLI_path_extension_replace(char *path, size_t maxlen, const char *ext) ATTR_NONNULL()
bool BLI_path_extension_check(const char *str, const char *ext) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BLI_join_dirfile(char *__restrict dst, size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
void ED_outliner_select_sync_from_object_tag(struct 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.
uiLayout * uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *heading)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemL(uiLayout *layout, const char *name, int icon)
uiLayout * uiLayoutBox(uiLayout *layout)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
int main(int argc, char *argv[])
void WM_OT_obj_import(struct wmOperatorType *ot)
void WM_OT_obj_export(struct wmOperatorType *ot)
const EnumPropertyItem io_transform_axis[]
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_collection_length(PointerRNA *ptr, const char *name)
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)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
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)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_update_runtime(PropertyRNA *prop, const void *func)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
char file_base_for_tests[FILE_MAX]
bool export_smooth_groups
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* ui)(struct bContext *, struct wmOperator *)
bool(* check)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
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)