Blender V5.0
usd.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <memory>
8
10
11#include "DEG_depsgraph.hh"
12
13#include "DNA_modifier_types.h"
14#include "RNA_types.hh"
15
16struct bContext;
18struct CacheReader;
19struct ListBase;
20struct Mesh;
21struct Object;
22struct ReportList;
24
25namespace blender::bke {
26struct GeometrySet;
27}
28
29namespace blender::io::usd {
30
39
40/* Enums specifying the USD material purpose,
41 * corresponding to #pxr::UsdShadeTokens 'allPurpose',
42 * 'preview', and 'render', respectively. */
48
59
69
78
90
96
106
115
126
128 bool export_animation = false;
130
131 bool export_meshes = true;
132 bool export_lights = true;
133 bool export_cameras = true;
134 bool export_curves = true;
135 bool export_points = true;
136 bool export_volumes = true;
137 bool export_hair = true;
138 bool export_uvmaps = true;
139 bool rename_uvmaps = true;
140 bool export_normals = true;
142 bool export_materials = true;
143
144 bool export_armatures = true;
145 bool export_shapekeys = true;
146 bool only_deform_bones = false;
147
149 bool merge_parent_xform = false;
150
151 bool use_instancing = false;
154 bool allow_unicode = true;
155
158
161 bool export_textures = false;
163 bool relative_paths = true;
164 bool use_original_paths = false;
165
166 bool triangulate_meshes = false;
169
174
177
178 std::string root_prim_path = "";
179 char collection[MAX_ID_NAME - 2] = "";
181
184
188};
189
247
253 double motion_sample_time; /* USD TimeCode in frames. */
254 int read_flags; /* MOD_MESHSEQ_xxx value that is set from MeshSeqCacheModifierData.read_flag. */
255};
256
257USDMeshReadParams create_mesh_read_params(double motion_sample_time, int read_flags);
258
268bool USD_export(const bContext *C,
269 const char *filepath,
270 const USDExportParams *params,
271 bool as_background_job,
272 ReportList *reports);
273
274bool USD_import(const bContext *C,
275 const char *filepath,
276 const USDImportParams *params,
277 bool as_background_job,
278 ReportList *reports);
279
280int USD_get_version();
281
282/* USD Import and Mesh Cache interface. */
283
284/* Similar to BLI_path_abs(), but also invokes the USD asset resolver
285 * to determine the absolute path. This is necessary for resolving
286 * paths with URIs that BLI_path_abs() would otherwise alter when
287 * attempting to normalize the path. */
288void USD_path_abs(char *path, const char *basepath, bool for_import);
289
290CacheArchiveHandle *USD_create_handle(Main *bmain, const char *filepath, ListBase *object_paths);
291
293
294void USD_get_transform(CacheReader *reader, float r_mat[4][4], float time, float scale);
295
297void USD_read_geometry(CacheReader *reader,
298 const Object *ob,
299 blender::bke::GeometrySet &geometry_set,
301 const char **r_err_str);
302
304 const Object *ob,
305 const Mesh *existing_mesh,
306 double time,
307 const char **r_err_str);
308
310 CacheReader *reader,
311 Object *object,
312 const char *object_path);
313
315
317struct USDHook {
318
319 /* Identifier used for class name. */
320 char idname[64];
321 /* Identifier used as label. */
322 char name[64];
323 /* Short help/description. */
324 char description[/*RNA_DYN_DESCR_MAX*/ 1024];
325
326 /* rna_ext.data points to the USDHook class PyObject. */
328};
329
330void USD_register_hook(std::unique_ptr<USDHook> hook);
335void USD_unregister_hook(const USDHook *hook);
336USDHook *USD_find_hook_name(const char idname[]);
337
339
340}; // namespace blender::io::usd
eEvaluationMode
@ DAG_EVAL_VIEWPORT
#define MAX_ID_NAME
Definition DNA_ID.h:373
#define MAX_IDPROP_NAME
Definition DNA_ID.h:186
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
@ MOD_TRIANGULATE_NGON_BEAUTY
eIOAxis
@ IO_AXIS_Y
@ IO_AXIS_NEGATIVE_Z
#define C
Definition RandGen.cpp:29
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void USD_unregister_hook(const USDHook *hook)
Definition usd_hook.cc:82
CacheArchiveHandle * USD_create_handle(Main *, const char *filepath, ListBase *object_paths)
CacheReader * CacheReader_open_usd_object(CacheArchiveHandle *handle, CacheReader *reader, Object *object, const char *object_path)
@ USD_TEX_IMPORT_NONE
Definition usd.hh:65
@ USD_TEX_IMPORT_PACK
Definition usd.hh:66
@ USD_TEX_IMPORT_COPY
Definition usd.hh:67
@ USD_XFORM_OP_TRS
Definition usd.hh:92
@ USD_XFORM_OP_TOS
Definition usd.hh:93
@ USD_XFORM_OP_MAT
Definition usd.hh:94
@ USD_SCENE_UNITS_CUSTOM
Definition usd.hh:117
@ USD_SCENE_UNITS_MILLIMETERS
Definition usd.hh:121
@ USD_SCENE_UNITS_METERS
Definition usd.hh:118
@ USD_SCENE_UNITS_CENTIMETERS
Definition usd.hh:120
@ USD_SCENE_UNITS_KILOMETERS
Definition usd.hh:119
@ USD_SCENE_UNITS_FEET
Definition usd.hh:123
@ USD_SCENE_UNITS_YARDS
Definition usd.hh:124
@ USD_SCENE_UNITS_INCHES
Definition usd.hh:122
bool USD_mesh_topology_changed(CacheReader *reader, const Object *ob, const Mesh *existing_mesh, const double time, const char **r_err_str)
USDMeshReadParams create_mesh_read_params(const double motion_sample_time, const int read_flags)
void USD_register_hook(std::unique_ptr< USDHook > hook)
Definition usd_hook.cc:71
void USD_get_transform(CacheReader *reader, float r_mat_world[4][4], float time, float scale)
void USD_read_geometry(CacheReader *reader, const Object *ob, blender::bke::GeometrySet &geometry_set, const USDMeshReadParams params, const char **r_err_str)
@ USD_MTL_PURPOSE_FULL
Definition usd.hh:46
@ USD_MTL_PURPOSE_ALL
Definition usd.hh:44
@ USD_MTL_PURPOSE_PREVIEW
Definition usd.hh:45
bool USD_import(const bContext *C, const char *filepath, const USDImportParams *params, bool as_background_job, ReportList *reports)
eUSDTexNameCollisionMode
Definition usd.hh:74
@ USD_TEX_NAME_COLLISION_USE_EXISTING
Definition usd.hh:75
@ USD_TEX_NAME_COLLISION_OVERWRITE
Definition usd.hh:76
eUSDPropertyImportMode
Definition usd.hh:54
@ USD_ATTR_IMPORT_USER
Definition usd.hh:56
@ USD_ATTR_IMPORT_ALL
Definition usd.hh:57
@ USD_ATTR_IMPORT_NONE
Definition usd.hh:55
void USD_path_abs(char *path, const char *basepath, bool for_import)
@ USD_SUBDIV_TESSELLATE
Definition usd.hh:83
@ USD_SUBDIV_BEST_MATCH
Definition usd.hh:88
@ USD_SUBDIV_IGNORE
Definition usd.hh:81
bool USD_export(const bContext *C, const char *filepath, const USDExportParams *params, bool as_background_job, ReportList *reports)
void USD_free_handle(CacheArchiveHandle *handle)
void USD_CacheReader_free(CacheReader *reader)
@ USD_TEX_EXPORT_KEEP
Definition usd.hh:111
@ USD_TEX_EXPORT_PRESERVE
Definition usd.hh:112
@ USD_TEX_EXPORT_NEW_PATH
Definition usd.hh:113
eUSDMtlNameCollisionMode
Definition usd.hh:35
@ USD_MTL_NAME_COLLISION_MAKE_UNIQUE
Definition usd.hh:36
@ USD_MTL_NAME_COLLISION_REFERENCE_EXISTING
Definition usd.hh:37
double get_meters_per_unit(const USDExportParams &params)
USDHook * USD_find_hook_name(const char idname[])
Definition usd_hook.cc:88
eUSDZTextureDownscaleSize
Definition usd.hh:97
@ USD_TEXTURE_SIZE_256
Definition usd.hh:100
@ USD_TEXTURE_SIZE_CUSTOM
Definition usd.hh:98
@ USD_TEXTURE_SIZE_2048
Definition usd.hh:103
@ USD_TEXTURE_SIZE_4096
Definition usd.hh:104
@ USD_TEXTURE_SIZE_KEEP
Definition usd.hh:99
@ USD_TEXTURE_SIZE_1024
Definition usd.hh:102
@ USD_TEXTURE_SIZE_512
Definition usd.hh:101
eUSDXformOpMode xform_op_mode
Definition usd.hh:173
char collection[MAX_ID_NAME - 2]
Definition usd.hh:179
char custom_properties_namespace[MAX_IDPROP_NAME]
Definition usd.hh:180
eUSDZTextureDownscaleSize usdz_downscale_size
Definition usd.hh:175
enum eEvaluationMode evaluation_mode
Definition usd.hh:157
eUSDSceneUnits convert_scene_units
Definition usd.hh:182
eSubdivExportMode export_subdiv
Definition usd.hh:156
wmJobWorkerStatus * worker_status
Definition usd.hh:187
ExtensionRNA rna_ext
Definition usd.hh:327
char description[1024]
Definition usd.hh:324
eUSDTexImportMode import_textures_mode
Definition usd.hh:234
eUSDMtlNameCollisionMode mtl_name_collision_mode
Definition usd.hh:233
eUSDTexNameCollisionMode tex_name_collision_mode
Definition usd.hh:238
wmJobWorkerStatus * worker_status
Definition usd.hh:245
eUSDPropertyImportMode property_import_mode
Definition usd.hh:239