I'm trying to dynamically select a camera that I know will exist somewhere in the USD tree (under /cameras/**) but I do not know its exact location or name. I was hoping that I could use the expression `/cameras/** & %type:Camera` but that only seems to work on the primitive paths in Solaris, not on OBJ level nodes like LopImportCamera.
Any suggestions for alternate ways to do this sort of fuzzy primitive lookup in the OBJ context?
Does Lop Import not support primitive path patterns?
1974 4 2-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
-
- antc
- Member
- 322 posts
- Joined: Nov. 2013
- Offline
LopImportCamera can only represent a single camera and a fuzzy lookup might match multiple. In lops you could try creating a reference to the first camera found under /cameras, that then gives you a fixed/known name to use in the obj node. Something like this in python lop might work.
and then point the LopImportCamera node at /obj_cam
node = hou.pwd() stage = node.editableStage() cameras = stage.GetPrimAtPath('/cameras') for prim in Usd.PrimRange(cameras): if UsdGeom.Camera(prim): stage.DefinePrim('/obj_cam').GetReferences().AddInternalReference(prim.GetPath()) break
and then point the LopImportCamera node at /obj_cam
Edited by antc - June 17, 2022 17:04:22
-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
Yeah, I figured it was probably due to something like that. I was just hoping that there might be a way to limit the result to the first match returned or something.
Still, using an internal reference is an interesting idea. Do you know if that would cause issues with the USD structure? Would that reference then show up in exported .usd files?
Still, using an internal reference is an interesting idea. Do you know if that would cause issues with the USD structure? Would that reference then show up in exported .usd files?
-
- antc
- Member
- 322 posts
- Joined: Nov. 2013
- Offline
AshenIt depends what branch you export. The LopImportCamera requires a lop node so you could have the node that's adding the reference live outside the branch you plan to export. You could also use a context option to switch off these kinds of extras during export.
Would that reference then show up in exported .usd files?
One thing to watch for is if you have a more complex transform hierarchy above the camera. Referencing just the camera prim won't magically bring along the parent transforms (or any other inherited attributes) so make sure to reference the appropriate parent prim if needed.
Edited by antc - June 17, 2022 20:30:50
-
- cwhite
- Staff
- 745 posts
- Joined: Oct. 2012
- Offline
-
- Quick Links