How To Add Existing Material To An Object In Existing USD File Thru Code

I have an engine shape in usd file. Its an existing model without any parameters. I want to add material to the model thru connector sample. I have added the image of model in attachment(s). Guide me on how to do it thru code.

I modified HelloWorld.cpp to assign a material from the MDL library and even set a shader input parameter.

See this video that walks through the process: Omniverse Connect Sample C++ HelloWorld Assigning MDL to Prim - YouTube

Also, here’s the USDA file I used in the video and the modified HelloWorld source:

matExNothing.usda (2.6 KB)

helloWorld.cpp (10.9 KB)

1 Like

Thank you so much LouRohan. The tutorial and example file provided is really useful. But I have another doubt LouRohan. In the example provided it shows only with one object and added with one material. What if there is around 40 - 50 objects. And I have to assign different material from the MDL Library for each objects. I will have two separate arrays with object id and material name . How to add them in a ‘for’ loop to do the process? Cuz in the example I find out it shows only for first usdGeoMesh. I will attach the usd file with multiple objects that i have here.
Trial_2_Ori.usda (2.0 MB)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.