USD: add export option that adds a Root 'Xform' node #104506
|
@ -137,6 +137,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
|||
const bool export_textures = RNA_boolean_get(op->ptr, "export_textures");
|
||||
const bool overwrite_textures = RNA_boolean_get(op->ptr, "overwrite_textures");
|
||||
const bool relative_paths = RNA_boolean_get(op->ptr, "relative_paths");
|
||||
const bool add_root = RNA_boolean_get(op->ptr, "add_root");
|
||||
|
||||
struct USDExportParams params = {
|
||||
export_animation,
|
||||
|
@ -152,6 +153,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
|||
export_textures,
|
||||
overwrite_textures,
|
||||
relative_paths,
|
||||
add_root,
|
||||
};
|
||||
|
||||
bool ok = USD_export(C, filename, ¶ms, as_background_job);
|
||||
|
@ -179,6 +181,7 @@ static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op)
|
|||
uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "add_root", 0, NULL, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(box, true);
|
||||
uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE);
|
||||
|
@ -334,6 +337,12 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
|
|||
"Relative Paths",
|
||||
"Use relative paths to reference external files (i.e. textures, volumes) in "
|
||||
"USD, otherwise use absolute paths");
|
||||
|
||||
RNA_def_boolean(ot->srna,
|
||||
"add_root",
|
||||
false,
|
||||
"Add Root",
|
||||
"Add a Root 'Scope' node to the stage.");
|
||||
|
||||
}
|
||||
|
||||
/* ====== USD Import ====== */
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <pxr/usd/usd/primRange.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usdGeom/tokens.h>
|
||||
#include <pxr/usd/usdGeom/scope.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -111,6 +112,10 @@ static void export_startjob(void *customdata,
|
|||
usd_stage->SetEndTimeCode(scene->r.efra);
|
||||
}
|
||||
|
||||
if (data->params.add_root) {
|
||||
pxr::UsdGeomScope::Define(usd_stage, pxr::SdfPath("/Root"));
|
||||
}
|
||||
|
||||
USDHierarchyIterator iter(data->bmain, data->depsgraph, usd_stage, data->params);
|
||||
|
||||
if (data->params.export_animation) {
|
||||
|
|
|
@ -77,8 +77,15 @@ const pxr::UsdTimeCode &USDHierarchyIterator::get_export_time_code() const
|
|||
|
||||
USDExporterContext USDHierarchyIterator::create_usd_export_context(const HierarchyContext *context)
|
||||
{
|
||||
pxr::SdfPath path;
|
||||
if (params_.add_root) {
|
||||
path = pxr::SdfPath("/Root" + context->export_path);
|
||||
} else {
|
||||
path = pxr::SdfPath(context->export_path);
|
||||
}
|
||||
|
||||
return USDExporterContext{
|
||||
bmain_, depsgraph_, stage_, pxr::SdfPath(context->export_path), this, params_};
|
||||
bmain_, depsgraph_, stage_, path, this, params_};
|
||||
}
|
||||
|
||||
AbstractHierarchyWriter *USDHierarchyIterator::create_transform_writer(
|
||||
|
|
|
@ -50,6 +50,7 @@ struct USDExportParams {
|
|||
bool export_textures;
|
||||
bool overwrite_textures;
|
||||
bool relative_paths;
|
||||
bool add_root;
|
||||
};
|
||||
|
||||
struct USDImportParams {
|
||||
|
|
Loading…
Reference in New Issue
I think this would be more clear:
I'm not sure that this would be an accurate description, as the node is just grouping all the other nodes, not changing their transformations.
It's not changing the transform, but as I understand it, the purpose is that it can then be used later on somewhere to transform the primitives? If so, perhaps:
Any reason not to use
root_transform
,Root Transform
, and the more detailedthat can be used in other applications to transform all primitives in the stage
description?Many things in USD files are nodes, I don't think it's necessary to put that in the name of the option.
Yep, you're probably right.