Hi,
In my extension I am trying to create multiple objects and move them regularly accoording to some third party simulation results. For now the objects should only be shown for visualization purposes and they do not need to saved to a usd file. Because the number of objects can reach a couple of hundred or maybe even thousand I am looking for an efficient method to move them to keep the framerate acceptable. From the documentation/forums I figured that for my purposes I should probably be using the usdrt API instead of the default usd one.
I tested the steps described in Working with OmniHydra Transforms and they are working fine in the script editor of the usd composer. But this example requires the prim that should be moved to be already present in the stage. So I adjusted the example to create the prim from the script:
import omni.usd
from usdrt import Usd, Rt, Gf, Sdf, UsdGeom
stage = Usd.Stage.Attach(omni.usd.get_context().get_stage_id())
if not stage:
print("Failed to attach stage")
else:
prim = UsdGeom.Cone.Define(stage, Sdf.Path("/World/Cone")).GetPrim()
if not prim:
print("Failed to create prim")
else:
xformable = Rt.Xformable(prim)
xformable.CreateWorldPositionAttr(Gf.Vec3d(0, 200, 0))
stage.WriteToStage()
print("Cone created successfully")
When I run this “Cone created successfully” is printed but I do not see the cone in the viewport or the stage view.
So when I make changes to the stage with usdrt what is necessary to make these changes visible in the viewport and stage view of the usd composer or any other kit app? I thought stage.WriteToStage()
might be doing that but I cannot see any effect here.