63static CLG_LogRef
LOG = {
"io.alembic"};
70 "Use Render settings for object visibility, modifier settings, etc"},
75 "Use Viewport settings for object visibility, modifier settings, etc"},
76 {0,
nullptr, 0,
nullptr,
nullptr},
110 params.frame_samples_xform =
RNA_int_get(op->ptr,
"xsamples");
111 params.frame_samples_shape =
RNA_int_get(op->ptr,
"gsamples");
127 params.export_particles =
RNA_boolean_get(op->ptr,
"export_particles");
128 params.export_custom_properties =
RNA_boolean_get(op->ptr,
"export_custom_properties");
132 params.quad_method =
RNA_enum_get(op->ptr,
"quad_method");
133 params.ngon_method =
RNA_enum_get(op->ptr,
"ngon_method");
136 params.global_scale =
RNA_float_get(op->ptr,
"global_scale");
142 if (params.frame_start == INT_MIN) {
143 params.frame_start = scene->r.sfra;
145 if (params.frame_end == INT_MIN) {
146 params.frame_end = scene->r.efra;
149 const bool as_background_job =
RNA_boolean_get(op->ptr,
"as_background_job");
150 bool ok =
ABC_export(scene,
C, filepath, ¶ms, as_background_job);
157 layout.use_property_split_set(
true);
158 layout.use_property_decorate_set(
false);
164 col = &panel->column(
false);
179 sub = &col->column(
true);
183 sub = &col->column(
true);
195 ptr,
"export_custom_properties",
UI_ITEM_NONE,
IFACE_(
"Custom Properties"), ICON_NONE);
196 col->prop(ptr,
"flatten",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
198 col = &panel->column(
true);
199 col->prop(ptr,
"evaluation_mode",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
209 row.prop(ptr,
"packuv",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
211 col->prop(ptr,
"normals",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
212 col->prop(ptr,
"vcolors",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
213 col->prop(ptr,
"orcos",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
214 col->prop(ptr,
"face_sets",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
215 col->prop(ptr,
"curves_as_mesh",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
223 col = &panel->column(
false);
224 col->prop(ptr,
"triangulate",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
225 sub = &col->column(
false);
233 C,
"ABC_export_particles",
false,
IFACE_(
"Particle Systems")))
237 col.prop(ptr,
"export_particles",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
246 if (scene !=
nullptr &&
RNA_boolean_get(op->ptr,
"init_scene_frame_range")) {
253 ui_alembic_export_settings(
C, *op->layout, op->ptr);
272 ot->name =
"Export Alembic";
273 ot->description =
"Export current scene in an Alembic archive";
274 ot->idname =
"WM_OT_alembic_export";
276 ot->invoke = wm_alembic_export_invoke;
277 ot->exec = wm_alembic_export_exec;
279 ot->ui = wm_alembic_export_draw;
280 ot->check = wm_alembic_export_check;
300 "Start frame of the export, use the default value to "
301 "take the start frame of the current scene",
311 "End frame of the export, use the default value to "
312 "take the end frame of the current scene",
322 "Number of times per frame transformations are sampled",
332 "Number of times per frame object data are sampled",
342 "Time at which the shutter is open",
352 "Time at which the shutter is closed",
357 ot->srna,
"selected",
false,
"Selected Objects Only",
"Export only selected objects");
363 "Do not preserve objects' parent/children relationship");
368 RNA_def_boolean(ot->srna,
"uvs",
true,
"UV Coordinates",
"Export UV coordinates");
372 RNA_def_boolean(ot->srna,
"normals",
true,
"Normals",
"Export normals");
374 RNA_def_boolean(ot->srna,
"vcolors",
false,
"Color Attributes",
"Export color attributes");
379 "Generated Coordinates",
380 "Export undeformed mesh vertex coordinates");
383 ot->srna,
"face_sets",
false,
"Face Sets",
"Export per face shading group assignments");
388 "Use Subdivision Schema",
389 "Export meshes using Alembic's subdivision schema");
394 "Apply Subdivision Surface",
395 "Export subdivision surfaces as meshes");
401 "Export curves and NURBS surfaces as meshes");
407 "Export data of duplicated objects as Alembic instances; speeds up the export "
408 "and can be disabled for compatibility with other software");
417 "Value by which to enlarge or shrink the objects with respect to the world's origin",
425 "Export polygons (quads and n-gons) as triangles");
432 "Method for splitting the quads into triangles");
439 "Method for splitting the n-gons into triangles");
445 "Exports hair particle systems as animated curves");
447 ot->srna,
"export_particles",
true,
"Export Particles",
"Exports non-hair particle systems");
450 "export_custom_properties",
452 "Export Custom Properties",
453 "Export custom properties to Alembic .userProperties");
459 "Run as Background Job",
460 "Enable this to run the import in the background, disable to block Blender while importing. "
461 "This option is deprecated; EXECUTE this operator to run in the foreground, and INVOKE it "
462 "to run as a background job");
466 rna_enum_abc_export_evaluation_mode_items,
469 "Determines visibility of objects, modifier settings, and other areas where there "
470 "are different settings for viewport and rendering");
483 CacheFrame *next, *
prev;
487static int get_sequence_len(
const char *filepath,
int *ofs)
499 if (dirpath[0] ==
'\0') {
508 if (dir ==
nullptr) {
510 "Error opening directory '%s': %s",
512 errno ? strerror(errno) :
"unknown error");
516 const char *ext =
".abc";
518 const int len = strlen(basename) - (numdigit + strlen(ext));
523 while ((fname =
readdir(dir)) !=
nullptr) {
525 if (!strstr(fname->
d_name, ext)) {
533 CacheFrame cache_frame{};
537 frames.append(cache_frame);
543 frames, [](
const CacheFrame &a,
const CacheFrame &
b) {
return a.framenr <
b.framenr; });
545 if (frames.is_empty()) {
549 int frame_curr = frames.first().framenr;
552 for (CacheFrame &cache_frame : frames) {
553 if (cache_frame.framenr != frame_curr) {
559 return frame_curr - (*ofs);
566 layout->use_property_split_set(
true);
567 layout->use_property_decorate_set(
false);
577 col.prop(ptr,
"set_frame_range",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
578 col.prop(ptr,
"is_sequence",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
579 col.prop(ptr,
"validate_meshes",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
580 col.prop(ptr,
"always_add_cache_reader",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
586 ui_alembic_import_settings(
C, op->layout, op->ptr);
601 if (paths.is_empty()) {
608 const bool set_frame_range =
RNA_boolean_get(op->ptr,
"set_frame_range");
609 const bool validate_meshes =
RNA_boolean_get(op->ptr,
"validate_meshes");
610 const bool always_add_cache_reader =
RNA_boolean_get(op->ptr,
"always_add_cache_reader");
611 const bool as_background_job =
RNA_boolean_get(op->ptr,
"as_background_job");
613 int sequence_min_frame = std::numeric_limits<int>::max();
614 int sequence_max_frame = std::numeric_limits<int>::min();
617 for (
const std::string &path : paths) {
619 int sequence_len = get_sequence_len(path.c_str(), &offset);
620 if (sequence_len < 0) {
624 sequence_min_frame = std::min(sequence_min_frame, offset);
625 sequence_max_frame = std::max(sequence_max_frame, offset + (sequence_len - 1));
636 params.
paths = std::move(paths);
637 params.global_scale =
scale;
638 params.sequence_min_frame = sequence_min_frame;
639 params.sequence_max_frame = sequence_max_frame;
640 params.is_sequence = is_sequence;
641 params.set_frame_range = set_frame_range;
642 params.validate_meshes = validate_meshes;
643 params.always_add_cache_reader = always_add_cache_reader;
645 bool ok =
ABC_import(
C, ¶ms, as_background_job);
652 ot->name =
"Import Alembic";
653 ot->description =
"Load an Alembic archive";
654 ot->idname =
"WM_OT_alembic_import";
657 ot->invoke = wm_alembic_import_invoke;
658 ot->exec = wm_alembic_import_exec;
660 ot->ui = wm_alembic_import_draw;
681 "Value by which to enlarge or shrink the objects with respect to the world's origin",
690 "If checked, update scene's start and end frame to match those of the Alembic archive");
697 "Ensure the data is valid "
698 "(when disabled, data may be imported which causes crashes displaying or editing)");
701 "always_add_cache_reader",
703 "Always Add Cache Reader",
704 "Add cache modifiers and constraints to imported objects even if they are not "
705 "animated so that they can be updated when reloading the Alembic archive");
711 "Set to true if the cache is split into separate files");
717 "Run as Background Job",
718 "Enable this to run the export in the background, disable to block Blender while exporting. "
719 "This option is deprecated; EXECUTE this operator to run in the foreground, and INVOKE it "
720 "to run as a background job");
726 auto fh = std::make_unique<bke::FileHandlerType>();
728 STRNCPY_UTF8(fh->import_operator,
"WM_OT_alembic_import");
729 STRNCPY_UTF8(fh->export_operator,
"WM_OT_alembic_export");
#define STRNCPY_UTF8(dst, src)
Compatibility-like things for windows.
struct dirent * readdir(DIR *dp)
DIR * opendir(const char *path)
#define CTX_IFACE_(context, msgid)
#define BLT_I18NCONTEXT_ID_CAMERA
#define CLOG_ERROR(clg_ref,...)
Object is a sort of wrapper for general info.
#define STREQLEN(a, b, n)
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, bke::FileHandlerType *)
void alembic_file_handler_add()
Vector< std::string > paths_from_operator_properties(PointerRNA *ptr)
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool mode_set(bContext *C, eObjectMode mode)
SymEdge< T > * prev(const SymEdge< T > *se)
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)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void WM_OT_alembic_export(wmOperatorType *ot)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
bool RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, bool use_ghost)
int RNA_int_get(PointerRNA *ptr, const char *name)
void WM_OT_alembic_import(wmOperatorType *ot)
const char * BKE_main_blendfile_path_from_global()
bool BLI_path_frame_get(const char *path, int *r_frame, int *r_digits_len) ATTR_NONNULL(1
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)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
void void BLI_path_split_dir_part(const char *filepath, char *dir, size_t dir_maxncpy) ATTR_NONNULL(1
void BKE_report(ReportList *reports, eReportType type, const char *message)
const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]
@ MOD_TRIANGULATE_NGON_BEAUTY
Object * CTX_data_edit_object(const bContext *C)
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
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 ABC_import(struct bContext *C, const struct AlembicImportParams *params, bool as_background_job)
bool WM_operator_winactive(bContext *C)
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
bool ABC_export(struct Scene *scene, struct bContext *C, const char *filepath, const struct AlembicExportParams *params, bool as_background_job)
SpaceFile * CTX_wm_space_file(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, 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)
float RNA_float_get(PointerRNA *ptr, const char *name)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
Vector< std::string > paths
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)