PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.45k stars 1.13k forks source link

Usdview doesn't work with UsdPhysics Schema? #3029

Closed xiahongchi closed 1 month ago

xiahongchi commented 1 month ago

Description of Issue

As I use usdview to a .usda file, it seems that it doesn't simulate physical effect.

Steps to Reproduce

  1. Copy the same code as what it is from the example here: https://docs.omniverse.nvidia.com/kit/docs/omni_usd_schema_physics/latest/index.html

I use the Box on Box example.

#usda 1.0
#Very basic example for using the Physics USD schema.
#Should show a box shaped rigid body that will fall on a flat 
#static box when simulated.
(
    defaultPrim = "World"
    endTimeCode = 100
    metersPerUnit = 0.01
    startTimeCode = 0
    timeCodesPerSecond = 24
    upAxis = "Z"
    #new mass scaling
    kilogramsPerUnit = 1.0
)
def Xform "World"
{
    #Scene mandatory for simulation.  By If rigid bodies don't explicitly
    #specify a scene, they implicitly belong to this one.
    #by default, the scene will have earth gravity.
    def PhysicsScene "PhysicsScene"
    {
    }
    #This cube becomes a rigid body and a collider thanks to two applied 
    #schemas.
    def Cube "BoxActor" (
        prepend apiSchemas = ["PhysicsCollisionAPI", "PhysicsRigidBodyAPI"]
    )
    {
        #optional non zero starting velocities.  
        #All other physics behavior is left at defaults.
        vector3f physics:velocity = (2, 1, 2)
        vector3f physics:angularVelocity = (1, 0, 0)
        color3f[] primvars:displayColor = [(0.2784314, 0.4117647, 1)]
        double size = 25
        double3 xformOp:translate = (0, 0, 500)
        uniform token[] xformOpOrder = ["xformOp:translate"]
    }
    #This cube becomes a static ground box because it only has a collider
    #but no rigid body.
    def Cube "Ground" (
        prepend apiSchemas = ["PhysicsCollisionAPI"]
    )
    {
        color3f[] primvars:displayColor = [(0.5, 0.5, 0.5)]
        #scale the cube to be flat
        float3 xformOp:scale = (750, 750, 10)
        uniform token[] xformOpOrder = ["xformOp:scale"]
    }
    #just to make this scene render pretty, not relevant for physics
    def SphereLight "SphereLight"
    {
        float intensity = 30000
        float radius = 150
        double3 xformOp:translate = (650, 0, 1150)
        uniform token[] xformOpOrder = ["xformOp:translate"]
    }
}
  1. usdview that .usda file.

  2. click Play bottom, but nothing happens. The box should fall down as the description says.

System Information (OS, Hardware)

Windows 11. NV 4060. Intel i9

Package Versions

24.03

Build Flags

no extra flags, just include a install dir.

jesschimein commented 1 month ago

Filed as internal issue #USD-9514

asluk commented 1 month ago

This is expected-- usdview currently does not ship with a UsdPhysics implementation (i.e., its own physics engine).

spiffmon commented 1 month ago

Yes, good note, @xiahongchi , but as @asluk said, this is currently a "limitation by design" of the OpenUSD distribution. There are a couple of challenging problems we would need to tackle for usdview to provide builtin physics interactions, which we may want to tackle eventually, but in a far enough timeframe that I'd like to close this issue for now if that's OK?

  1. There is no "reference" or "correct" simulator out there - they all make different decisions that affect the results you get, and were OpenUSD to ship with one of them, that would be promoting a specific one. We'd need to minimally craft a plugin API specific to simulation so that people could adapt other simulators to OpenUSD, and that would be a good-sized project.
  2. usdview is first and foremost a viewer and debugging tool for authored or cached animation, and introducing live behaviors presents some "modality" problems to solve - i.e. the meaning of "time" changes when you're working with interactive physics sims, vs playing back crafted animation.