Skip to content

Commit 7b5be0e

Browse files
committed
Merge remote-tracking branch 'yliu/fix-omniverse' into fix-omniverse
2 parents b6f95ef + e952717 commit 7b5be0e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

modules/omniverse/omniverse_integration.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@
577577
"\n",
578578
"To download the latest version of USD Composer, you can follow the instructions here to build and launch:\n",
579579
"\n",
580-
"https://github.com/NVIDIA-Omniverse/kit-app-template/tree/main/templates/apps/usd_composer#getting-started.\n",
580+
"https://github.com/NVIDIA-Omniverse/kit-app-template/tree/main/templates/apps/usd_composer#getting-started\n",
581581
"\n",
582582
"![omniverse](./omniverse.png)"
583583
]

modules/omniverse/utility.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,35 +204,37 @@ def convert_mesh_to_usd(input_file, output_file):
204204
# Create a unique path for each mesh
205205
node_path = f"/World/{node_name}"
206206
xform = UsdGeom.Xform.Define(stage, node_path)
207+
# Define the Mesh under the Xform
208+
mesh_path = f"{node_path}/Mesh"
209+
usd_mesh = UsdGeom.Mesh.Define(stage, mesh_path)
207210
# get the geometry of the node
208211
geometry = mesh.geometry[geom_name]
209-
usd_mesh = UsdGeom.Mesh.Define(stage, node_path)
210212

211213
# Create a random color for this mesh
212214
# Using HSV for better color distribution
213215
h = random.random() # Random hue
214216
s = 0.7 + 0.3 * random.random() # Saturation between 0.7-1.0
215217
v = 0.7 + 0.3 * random.random() # Value between 0.7-1.0
216218
r, g, b = colorsys.hsv_to_rgb(h, s, v)
217-
219+
218220
# Create a material with the random color
219221
mat_name = f"{node_name}_material"
220222
mat_path = f"{materials_path}/{mat_name}"
221223
material = UsdShade.Material.Define(stage, mat_path)
222-
224+
223225
# Create shader
224226
shader = UsdShade.Shader.Define(stage, f"{mat_path}/PreviewSurface")
225227
shader.CreateIdAttr("UsdPreviewSurface")
226-
228+
227229
# Set the random color
228230
shader.CreateInput("diffuseColor", Sdf.ValueTypeNames.Color3f).Set(Gf.Vec3f(r, g, b))
229231
shader.CreateInput("roughness", Sdf.ValueTypeNames.Float).Set(0.4)
230-
232+
231233
# Connect shader to material
232234
material_output = material.CreateOutput("surface", Sdf.ValueTypeNames.Token)
233235
shader_output = shader.CreateOutput("surface", Sdf.ValueTypeNames.Token)
234236
material_output.ConnectToSource(shader_output)
235-
237+
236238
# Bind material to mesh
237239
UsdShade.MaterialBindingAPI(usd_mesh).Bind(material)
238240

0 commit comments

Comments
 (0)