57 "Use Render settings for object visibility, modifier settings, etc"},
62 "Use Viewport settings for object visibility, modifier settings, etc"},
63 {0,
nullptr, 0,
nullptr,
nullptr},
71 "Import each USD material as a unique Blender material"},
76 "If a material with the same name already exists, reference that instead of importing"},
77 {0,
nullptr, 0,
nullptr,
nullptr},
86 "Import USD attributes in the 'userProperties' namespace as Blender custom "
87 "properties. The namespace will be stripped from the property names"},
92 "Import all USD custom attributes as Blender custom properties. "
93 "Namespaces will be retained in the property names"},
94 {0,
nullptr, 0,
nullptr,
nullptr},
101 {0,
nullptr, 0,
nullptr,
nullptr},
109 "If a file with the same name already exists, use that instead of copying"},
111 {0,
nullptr, 0,
nullptr,
nullptr},
119 "Scheme = None. Export base mesh without subdivision"},
124 "Scheme = None. Export subdivided mesh"},
129 "Scheme = Catmull-Clark, when possible. "
130 "Reverts to exporting the subdivided mesh for the Simple subdivision type"},
131 {0,
nullptr, 0,
nullptr,
nullptr},
138 "Translate, Rotate, Scale",
139 "Export with translate, rotate, and scale Xform operators"},
143 "Translate, Orient, Scale",
144 "Export with translate, orient quaternion, and scale Xform operators"},
146 {0,
nullptr, 0,
nullptr,
nullptr},
157 {0,
nullptr, 0,
nullptr,
nullptr},
166 "Preserve file paths of textures from already imported USD files.\n"
167 "Export remaining textures to a 'textures' folder next to the USD file"},
172 "Export textures to a 'textures' folder next to the USD file"},
173 {0,
nullptr, 0,
nullptr,
nullptr}};
180 "Attempt to import 'allPurpose' materials."},
185 "Attempt to import 'preview' materials. "
186 "Load 'allPurpose' materials as a fallback"},
191 "Attempt to import 'full' materials. "
192 "Load 'allPurpose' or 'preview' materials, in that order, as a fallback"},
193 {0,
nullptr, 0,
nullptr,
nullptr},
203 "Scene meters per unit to 0.01"},
208 "Scene meters per unit to 0.001"},
216 "Specify a custom scene meters per unit value"},
217 {0,
nullptr, 0,
nullptr,
nullptr},
222struct USDOperatorOptions {
223 bool as_background_job;
226static void free_operator_customdata(
wmOperator *op)
237static void process_prim_path(std::string &prim_path)
239 if (prim_path.empty()) {
244 if (prim_path ==
"/") {
248 else if (prim_path[0] !=
'/') {
249 prim_path.insert(0, 1,
'/');
258 options->as_background_job =
true;
272 free_operator_customdata(op);
276 const USDOperatorOptions *
options =
static_cast<USDOperatorOptions *
>(op->
customdata);
277 const bool as_background_job = (
options !=
nullptr &&
options->as_background_job);
278 free_operator_customdata(op);
285 bool export_textures =
false;
286 bool use_original_paths =
false;
288 switch (textures_mode) {
290 export_textures =
false;
291 use_original_paths =
true;
294 export_textures =
true;
295 use_original_paths =
false;
298 export_textures =
false;
299 use_original_paths =
false;
341 params.export_textures = export_textures;
342 params.use_original_paths = use_original_paths;
362 process_prim_path(
params.root_prim_path);
390 sub = &
col->column(
true,
IFACE_(
"Blender Data"));
393 props_col->
prop(
ptr,
"custom_properties_namespace",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
398 sub = &
col->column(
true,
IFACE_(
"File References"));
401 col = &panel->column(
false);
404 col->prop(
ptr,
"export_global_forward_selection",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
415 col = &panel->column(
false);
476 col->use_property_split_set(
true);
494 if (
uiLayout *panel = layout->
panel(
C,
"USD_export_experimental",
true,
IFACE_(
"Experimental")))
503 free_operator_customdata(op);
524 if ((forward % 3) == (up % 3)) {
533 if ((forward % 3) == (up % 3)) {
534 RNA_enum_set(
ptr,
"export_global_forward_selection", (forward + 1) % 6);
540 ot->name =
"Export USD";
541 ot->description =
"Export current scene in a USD archive";
542 ot->idname =
"WM_OT_usd_export";
544 ot->invoke = wm_usd_export_invoke;
545 ot->exec = wm_usd_export_exec;
547 ot->ui = wm_usd_export_draw;
548 ot->cancel = wm_usd_export_cancel;
549 ot->check = wm_usd_export_check;
565 "selected_objects_only",
568 "Only export selected objects. Unselected parents of selected objects are "
569 "exported as empty transform");
579 "Export all frames in the render frame range, rather than only the current frame");
581 ot->srna,
"export_hair",
false,
"Hair",
"Export hair particle systems as USD curves");
583 ot->srna,
"export_uvmaps",
true,
"UV Maps",
"Include all mesh UV maps in the export");
588 "Rename active render UV map to \"st\" to match USD conventions");
590 "export_mesh_colors",
593 "Include mesh color attributes in the export");
598 "Include normals of exported meshes in the export");
603 "Export viewport settings of materials as USD preview materials, and export "
604 "material assignments as geometry subsets");
607 "export_subdivision",
608 rna_enum_usd_export_subdiv_mode_items,
611 "Choose how subdivision modifiers will be mapped to the USD subdivision scheme "
618 "Export armatures and meshes with armature modifiers as USD skeletons and "
625 "Only export deform bones and their parents");
628 ot->srna,
"export_shapekeys",
true,
"Shape Keys",
"Export shape keys as USD blend shapes");
634 "Export instanced objects as references in USD rather than real objects");
638 rna_enum_usd_export_evaluation_mode_items,
641 "Determines visibility of objects, modifier settings, and other areas where there "
642 "are different settings for viewport and rendering");
645 "generate_preview_surface",
647 "USD Preview Surface Network",
648 "Generate an approximate USD Preview Surface shader "
649 "representation of a Principled BSDF node network");
652 "generate_materialx_network",
655 "Generate a MaterialX network representation of the materials");
659 "convert_orientation",
661 "Convert Orientation",
662 "Convert orientation axis to a different convention to match other applications");
665 "export_global_forward_selection",
677 "export_textures_mode",
678 rna_enum_usd_tex_export_mode_items,
681 "Texture export method");
684 "overwrite_textures",
686 "Overwrite Textures",
687 "Overwrite existing files when exporting textures");
693 "Use relative paths to reference external files (i.e. textures, volumes) in "
694 "USD, otherwise use absolute paths");
698 rna_enum_usd_xform_op_mode_items,
701 "The type of transform operators to write");
708 "If set, add a transform primitive with the given path to the stage "
709 "as the parent of all exported data");
712 "export_custom_properties",
715 "Export custom properties as USD attributes");
718 "custom_properties_namespace",
722 "If set, add the given namespace as a prefix to exported custom property names. "
723 "This only applies to property names that do not already have a prefix "
724 "(e.g., it would apply to name 'bar' but not 'foo:bar') and does not apply "
725 "to blender object and data names which are always exported in the "
726 "'userProperties:blender' namespace");
729 "author_blender_name",
732 "Author USD custom attributes containing the original Blender object and "
733 "object data names");
737 "convert_world_material",
740 "Convert the world material to a USD dome light. "
741 "Currently works for simple materials, consisting of an environment texture "
742 "connected to a background shader, with an optional vector multiply of the texture color");
749 "Preserve UTF-8 encoded characters when writing USD prim and property names "
750 "(requires software utilizing USD 24.03 or greater when opening the resulting files)");
756 RNA_def_boolean(
ot->srna,
"export_cameras",
true,
"Cameras",
"Export all cameras");
760 RNA_def_boolean(
ot->srna,
"export_points",
true,
"Point Clouds",
"Export all point clouds");
762 RNA_def_boolean(
ot->srna,
"export_volumes",
true,
"Volumes",
"Export all volumes");
765 "triangulate_meshes",
767 "Triangulate Meshes",
768 "Triangulate meshes during export");
775 "Method for splitting the quads into triangles");
782 "Method for splitting the n-gons into triangles");
785 "usdz_downscale_size",
786 rna_enum_usdz_downscale_size,
788 "USDZ Texture Downsampling",
789 "Choose a maximum size for all exported textures");
792 "usdz_downscale_custom_size",
796 "USDZ Custom Downscale Size",
797 "Custom size for downscaling exported textures",
802 "merge_parent_xform",
804 "Merge parent Xform",
805 "Merge USD primitives with their Xform parent if possible. USD does not allow "
806 "nested UsdGeomGprims, intermediary Xform prims will be defined to keep the USD "
807 "file valid when encountering object hierarchies.");
810 "convert_scene_units",
811 rna_enum_usd_convert_scene_units_items,
814 "Set the USD Stage meters per unit to the chosen measurement, or a custom value");
822 "Custom value for meters per unit in the USD Stage",
832 options->as_background_job =
true;
842 free_operator_customdata(op);
846 const USDOperatorOptions *
options =
static_cast<USDOperatorOptions *
>(op->
customdata);
847 const bool as_background_job = (
options !=
nullptr &&
options->as_background_job);
848 free_operator_customdata(op);
861 if (read_mesh_colors) {
864 if (read_mesh_attributes) {
873 params.mesh_read_flag = mesh_read_flag;
877 params.is_sequence =
false;
940 free_operator_customdata(op);
960 col = &panel->column(
false);
988 col = &panel->column(
true,
IFACE_(
"Display Purpose"));
993 col = &panel->column(
true,
IFACE_(
"Material Purpose"));
1004 col = &panel->column(
false);
1037 row = &
col->row(
true);
1044 C,
"USD_import_instancing",
true,
IFACE_(
"Particles and Instancing")))
1053 ot->name =
"Import USD";
1054 ot->description =
"Import USD stage into current scene";
1055 ot->idname =
"WM_OT_usd_import";
1057 ot->invoke = wm_usd_import_invoke;
1058 ot->exec = wm_usd_import_exec;
1059 ot->cancel = wm_usd_import_cancel;
1061 ot->ui = wm_usd_import_draw;
1083 "Value by which to enlarge or shrink the objects with respect to the world's origin",
1091 "Update the scene's start and end frame to match those of the USD archive");
1105 "import_subdivision",
1107 "Import Subdivision Scheme",
1108 "Create subdivision surface modifiers based on the USD "
1109 "SubdivisionScheme attribute");
1112 "support_scene_instancing",
1115 "Import USD scene graph instances as collection instances");
1118 "import_visible_only",
1120 "Visible Primitives Only",
1121 "Do not import invisible USD primitives. "
1122 "Only applies to primitives with a non-animated visibility attribute. "
1123 "Primitives with animated visibility will always be imported");
1126 "create_collection",
1128 "Create Collection",
1129 "Add all imported objects to a new collection");
1131 RNA_def_boolean(
ot->srna,
"read_mesh_uvs",
true,
"UV Coordinates",
"Read mesh UV coordinates");
1134 ot->srna,
"read_mesh_colors",
true,
"Color Attributes",
"Read mesh color attributes");
1137 "read_mesh_attributes",
1140 "Read USD Primvars as mesh attributes");
1147 "Import only the primitive at the given path and its descendants. "
1148 "Multiple paths may be specified in a list delimited by commas or semicolons");
1150 RNA_def_boolean(
ot->srna,
"import_guide",
false,
"Guide",
"Import guide geometry");
1152 RNA_def_boolean(
ot->srna,
"import_proxy",
false,
"Proxy",
"Import proxy geometry");
1154 RNA_def_boolean(
ot->srna,
"import_render",
true,
"Render",
"Import final render geometry");
1157 "import_all_materials",
1159 "Import All Materials",
1160 "Also import materials that are not used by any geometry. "
1161 "Note that when this option is false, materials referenced "
1162 "by geometry will still be imported");
1165 "import_usd_preview",
1167 "Import USD Preview",
1168 "Convert UsdPreviewSurface shaders to Principled BSDF shader networks");
1171 "set_material_blend",
1173 "Set Material Blend",
1174 "If the Import USD Preview option is enabled, "
1175 "the material blend method will automatically be set based on the "
1176 "shader's opacity and opacityThreshold inputs");
1179 "light_intensity_scale",
1183 "Light Intensity Scale",
1184 "Scale for the intensity of imported lights",
1190 rna_enum_usd_mtl_purpose_items,
1193 "Attempt to import materials with the given purpose. "
1194 "If no material with this purpose is bound to the primitive, "
1195 "fall back on loading any other bound material");
1199 "mtl_name_collision_mode",
1200 rna_enum_usd_mtl_name_collision_mode_items,
1202 "Material Name Collision",
1203 "Behavior when the name of an imported material conflicts with an existing material");
1206 "import_textures_mode",
1207 rna_enum_usd_tex_import_mode_items,
1210 "Behavior when importing textures from a USDZ archive");
1213 "import_textures_dir",
1216 "Textures Directory",
1217 "Path to the directory where imported textures will be copied");
1221 "tex_name_collision_mode",
1222 rna_enum_usd_tex_name_collision_mode_items,
1224 "File Name Collision",
1225 "Behavior when the name of an imported texture file conflicts with an existing file");
1228 "property_import_mode",
1229 rna_enum_usd_property_import_mode_items,
1231 "Custom Properties",
1232 "Behavior when importing USD attributes as Blender custom properties");
1239 "Ensure the data is valid "
1240 "(when disabled, data may be imported which causes crashes displaying or editing)");
1243 "create_world_material",
1246 "Convert the first discovered USD dome light to a world background shader");
1249 "import_defined_only",
1251 "Defined Primitives Only",
1252 "Import only defined USD primitives. When disabled this allows importing USD "
1253 "primitives which are not defined, such as those with an override specifier");
1256 "merge_parent_xform",
1258 "Merge parent Xform",
1259 "Allow USD primitives to merge with their Xform parent "
1260 "if they are the only child in the hierarchy");
1264 "apply_unit_conversion_scale",
1266 "Apply Unit Conversion Scale",
1267 "Scale the scene objects by the USD stage's meters per unit value. "
1268 "This scaling is applied in addition to the value specified in the Scale option");
1274 auto fh = std::make_unique<blender::bke::FileHandlerType>();
1278 STRNCPY_UTF8(fh->label,
"Universal Scene Description");
1279 STRNCPY_UTF8(fh->file_extensions_str,
".usd;.usda;.usdc;.usdz");
SpaceFile * CTX_wm_space_file(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
bool BLI_path_extension_check_n(const char *path,...) ATTR_NONNULL(1) ATTR_SENTINEL(0)
#define STRNCPY_UTF8(dst, src)
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
@ MOD_MESHSEQ_READ_ATTRIBUTES
@ MOD_TRIANGULATE_NGON_BEAUTY
void ED_fileselect_ensure_default_filepath(bContext *C, wmOperator *op, const char *extension)
Read Guarded memory(de)allocation.
CCL_NAMESPACE_BEGIN struct Options options
void WM_OT_usd_import(wmOperatorType *ot)
void WM_OT_usd_export(wmOperatorType *ot)
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void file_handler_add(std::unique_ptr< FileHandlerType > file_handler)
bool poll_file_object_drop(const bContext *C, blender::bke::FileHandlerType *)
wmOperatorStatus filesel_drop_import_invoke(bContext *C, wmOperator *op, const wmEvent *)
void usd_file_handler_add()
bool mode_set(bContext *C, eObjectMode mode)
@ USD_SCENE_UNITS_MILLIMETERS
@ USD_SCENE_UNITS_CENTIMETERS
@ USD_SCENE_UNITS_KILOMETERS
@ USD_MTL_PURPOSE_PREVIEW
bool USD_import(const bContext *C, const char *filepath, const USDImportParams *params, bool as_background_job, ReportList *reports)
@ USD_TEX_NAME_COLLISION_USE_EXISTING
@ USD_TEX_NAME_COLLISION_OVERWRITE
bool USD_export(const bContext *C, const char *filepath, const USDExportParams *params, bool as_background_job, ReportList *reports)
@ USD_TEX_EXPORT_PRESERVE
@ USD_TEX_EXPORT_NEW_PATH
@ USD_MTL_NAME_COLLISION_MAKE_UNIQUE
@ USD_MTL_NAME_COLLISION_REFERENCE_EXISTING
eUSDZTextureDownscaleSize
@ USD_TEXTURE_SIZE_CUSTOM
const EnumPropertyItem io_transform_axis[]
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)
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)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
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)
const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[]
const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[]
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 active_set(bool active)
void enabled_set(bool enabled)
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_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)