Blender V4.5
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;
23struct wmJobWorkerStatus;
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;
131
132 bool export_meshes = true;
133 bool export_lights = true;
134 bool export_cameras = true;
135 bool export_curves = true;
136 bool export_points = true;
137 bool export_volumes = true;
138 bool export_hair = true;
139 bool export_uvmaps = true;
140 bool rename_uvmaps = true;
141 bool export_normals = true;
143 bool export_materials = true;
144
145 bool export_armatures = true;
146 bool export_shapekeys = true;
147 bool only_deform_bones = false;
148
150 bool merge_parent_xform = false;
151
152 bool use_instancing = false;
155 bool allow_unicode = false;
156
159
162 bool export_textures = false;
164 bool relative_paths = true;
165 bool use_original_paths = false;
166
167 bool triangulate_meshes = false;
170
175
178
179 char root_prim_path[1024] = ""; /* FILE_MAX */
182
185
188 wmJobWorkerStatus *worker_status = nullptr;
189};
190
248
254 double motion_sample_time; /* USD TimeCode in frames. */
255 int read_flags; /* MOD_MESHSEQ_xxx value that is set from MeshSeqCacheModifierData.read_flag. */
256};
257
258USDMeshReadParams create_mesh_read_params(double motion_sample_time, int read_flags);
259
269bool USD_export(const bContext *C,
270 const char *filepath,
271 const USDExportParams *params,
272 bool as_background_job,
274
275bool USD_import(const bContext *C,
276 const char *filepath,
277 const USDImportParams *params,
278 bool as_background_job,
280
281int USD_get_version();
282
283/* USD Import and Mesh Cache interface. */
284
285/* Similar to BLI_path_abs(), but also invokes the USD asset resolver
286 * to determine the absolute path. This is necessary for resolving
287 * paths with URIs that BLI_path_abs() would otherwise alter when
288 * attempting to normalize the path. */
289void USD_path_abs(char *path, const char *basepath, bool for_import);
290
291CacheArchiveHandle *USD_create_handle(Main *bmain, const char *filepath, ListBase *object_paths);
292
294
295void USD_get_transform(CacheReader *reader, float r_mat[4][4], float time, float scale);
296
298void USD_read_geometry(CacheReader *reader,
299 const Object *ob,
300 blender::bke::GeometrySet &geometry_set,
302 const char **r_err_str);
303
305 const Object *ob,
306 const Mesh *existing_mesh,
307 double time,
308 const char **r_err_str);
309
311 CacheReader *reader,
312 Object *object,
313 const char *object_path);
314
316
318struct USDHook {
319
320 /* Identifier used for class name. */
321 char idname[64];
322 /* Identifier used as label. */
323 char name[64];
324 /* Short help/description. */
325 char description[1024]; /* #RNA_DYN_DESCR_MAX */
326
327 /* rna_ext.data points to the USDHook class PyObject. */
329};
330
331void USD_register_hook(std::unique_ptr<USDHook> hook);
336void USD_unregister_hook(USDHook *hook);
337USDHook *USD_find_hook_name(const char idname[]);
338
340
341}; // namespace blender::io::usd
eEvaluationMode
@ DAG_EVAL_VIEWPORT
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
@ MOD_TRIANGULATE_NGON_BEAUTY
eIOAxis
@ IO_AXIS_Y
@ IO_AXIS_NEGATIVE_Z
#define C
Definition RandGen.cpp:29
ReportList * reports
Definition WM_types.hh:1025
#define MAX_IDPROP_NAME
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
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)
void USD_unregister_hook(USDHook *hook)
Definition usd_hook.cc:82
@ 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)
@ 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_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
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:174
char custom_properties_namespace[MAX_IDPROP_NAME]
Definition usd.hh:181
eUSDZTextureDownscaleSize usdz_downscale_size
Definition usd.hh:176
enum eEvaluationMode evaluation_mode
Definition usd.hh:158
char collection[MAX_IDPROP_NAME]
Definition usd.hh:180
eUSDSceneUnits convert_scene_units
Definition usd.hh:183
eSubdivExportMode export_subdiv
Definition usd.hh:157
wmJobWorkerStatus * worker_status
Definition usd.hh:188
ExtensionRNA rna_ext
Definition usd.hh:328
char description[1024]
Definition usd.hh:325
eUSDTexImportMode import_textures_mode
Definition usd.hh:236
eUSDAttrImportMode attr_import_mode
Definition usd.hh:240
eUSDMtlNameCollisionMode mtl_name_collision_mode
Definition usd.hh:235
eUSDTexNameCollisionMode tex_name_collision_mode
Definition usd.hh:239
wmJobWorkerStatus * worker_status
Definition usd.hh:246