unreal.UsdConversionContext
¶
- class unreal.UsdConversionContext(outer: Object | None = None, name: Name | str = 'None')¶
Bases:
Object
Wraps the UnrealToUsd component conversion functions from the USDUtilities module so that they can be used by scripting languages.
This is an instanceable object instead of just static functions so that the USDStage to use for the conversions can be provided and cached between function calls, which is helpful because we’re forced to provide at most prim and layer file paths (as opposed to direct pxr::UsdPrim objects).
We can’t provide the pxr::UsdPrim object directly because USD types can’t be part of C++ function signatures that are automatically exposed to scripting languages. Lucikly we can use UsdUtils’ stage cache to make sure that C++ and e.g. Python are still referencing the same USD Stage in memory, so that we can e.g. use these functions to convert data within stages created via Python.
C++ Source:
Plugin: USDImporter
Module: USDExporter
File: USDConversionBlueprintContext.h
- cleanup() None ¶
Discards the currently opened stage. This is critical when using this class via scripting: The C++ destructor will not be called when the python object runs out of scope, so we would otherwise keep a strong reference to the stage
- convert_cine_camera_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Cine Camera Component
- Parameters:
component (CineCameraComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_directional_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Directional Light Component
- Parameters:
component (DirectionalLightComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_draw_mode_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Draw Mode Component
- Parameters:
component (UsdDrawModeComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_hism_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Hism Component
- Parameters:
component (HierarchicalInstancedStaticMeshComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_instanced_foliage_actor(actor, prim_path, instances_level=None, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Instanced Foliage Actor
- Parameters:
actor (InstancedFoliageActor) –
prim_path (str) –
instances_level (Level) –
time_code (float) –
- Return type:
- convert_landscape_proxy_actor_material(actor, prim_path, properties_to_bake, default_texture_size, textures_dir, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Landscape Proxy Actor Material
- Parameters:
actor (LandscapeProxy) –
prim_path (str) –
properties_to_bake (Array[PropertyEntry]) –
default_texture_size (IntPoint) –
textures_dir (DirectoryPath) –
time_code (float) –
- Return type:
- convert_landscape_proxy_actor_mesh(actor, prim_path, lowest_lod, highest_lod, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Landscape Proxy Actor Mesh
- Parameters:
actor (LandscapeProxy) –
prim_path (str) –
lowest_lod (int32) –
highest_lod (int32) –
time_code (float) –
- Return type:
- convert_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Note: We use FLT_MAX on these functions because Usd.TimeCode.Default().GetValue() is actually a nan, and nan arguments are automatically sanitized to 0.0f. We manually convert the FLT_MAX value into Usd.TimeCode.Default().GetValue() within the functions though, so if you want the Default timecode just omit the argument We are also forced to copypaste the FLT_MAX value (3.402823466e+38F) in here as the default arguments are parsed before the preprocessor replaces the defines
- Parameters:
component (LightComponentBase) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_material_overrides(mesh_asset, material_overrides, prim_path, lowest_lod, highest_lod) bool ¶
Convert Material Overrides
- Parameters:
mesh_asset (Object) –
material_overrides (Array[MaterialInterface]) –
prim_path (str) –
lowest_lod (int32) –
highest_lod (int32) –
- Return type:
- convert_mesh_component(component, prim_path) bool ¶
Convert Mesh Component
- Parameters:
component (MeshComponent) –
prim_path (str) –
- Return type:
- convert_point_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Point Light Component
- Parameters:
component (PointLightComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_rect_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Rect Light Component
- Parameters:
component (RectLightComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_scene_component(component, prim_path) bool ¶
Convert Scene Component
- Parameters:
component (SceneComponent) –
prim_path (str) –
- Return type:
- convert_sky_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Sky Light Component
- Parameters:
component (SkyLightComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- convert_spot_light_component(component, prim_path, time_code=340282346638528859811704183484516925440.000000) bool ¶
Convert Spot Light Component
- Parameters:
component (SpotLightComponent) –
prim_path (str) –
time_code (float) –
- Return type:
- get_edit_target() FilePath ¶
Gets the filepath of the current edit target layer of our internal stage
- Return type:
- get_prim_asset_info(prim_path) UsdUnrealAssetInfo ¶
Retrieves from Prim the assetInfo metadata values that we use as export metadata, when exporting Unreal assets
- Parameters:
prim_path (str) –
- Return type:
- get_prim_metadata(prim_path, blocked_prefix_filter, invert_filter, collect_from_entire_subtrees) UsdCombinedPrimMetadata ¶
Extracts metadata from the prim at PrimPath using the provided filters and returns it
- get_stage_root_layer() FilePath ¶
Gets the file path of the root layer of our current stage
- Return type:
- get_usd_stage_num_frames() int32 ¶
Returns how many frames of animation the stage would generate if imported
- Return type:
int32
- replace_unreal_materials_with_baked(layer_to_author_in, baked_materials, is_asset_layer, use_payload, remove_unreal_materials=False) None ¶
Traverses the context’s stage and authors material binding attributes for all unrealMaterials that were baked into USD material assets.
- Parameters:
layer_to_author_in (FilePath) – File path to the layer where the material binding opinions are authored
baked_materials (Map[str, str]) – Maps from material path names to file paths where they were baked Example: { “/Game/MyMaterials/Red.Red”: “C:/MyFolder/Red.usda” }
is_asset_layer (bool) – True when we’re exporting a single mesh/animation asset. False when we’re exporting a level. Dictates minor behaviors when authoring the material binding relationships, e.g. whether we author them inside variants or not
use_payload (bool) – Should be True if the Stage was exported using payload files to store the actual Mesh prims. Also dictates minor behaviors when authoring the material binding relationships.
remove_unreal_materials (bool) – No longer used.
- set_edit_target(edit_target_layer_path) None ¶
Sets the current edit target of our internal stage. When calling the conversion functions, prims and attributes will be authored on this edit target only
- Parameters:
edit_target_layer_path (FilePath) –
- set_prim_asset_info(prim_path, info) None ¶
Adds to Prim the assetInfo metadata the values described in Info
- Parameters:
prim_path (str) –
info (UsdUnrealAssetInfo) –
- set_prim_metadata(prim_path, metadata, blocked_prefix_filter, invert_filter) None ¶
Applies Metadata to the prim specified at PrimPath, using the provided filters
- Parameters:
prim_path (str) –
metadata (UsdCombinedPrimMetadata) –
invert_filter (bool) –
- set_prim_metadata_from_user_data(prim_path, user_data, blocked_prefix_filter, invert_filter) None ¶
Applies all the metadata contained in UserData to the prim specified at PrimPath, using the provided filters
- Parameters:
prim_path (str) –
user_data (UsdAssetUserData) –
invert_filter (bool) –
- set_stage_root_layer(stage_root_layer_path) None ¶
Opens or creates a USD stage using StageRootLayerPath as root layer, creating the root layer if needed. All future conversions will fetch prims and get/set USD data to/from this stage. Note: You must remember to call Cleanup() when done, or else this object will permanently hold a reference to the opened stage!
- Parameters:
stage_root_layer_path (FilePath) –