GameEngine as a SceneIndex plugin

Hey,

In my spare time (…) I’m experimenting with “behaviours” all described in a usd file, and then handled by a “game engine” which is actually a SceneIndex plugin.

Initially I thought about writing all in a custom app, which then changes the status of various usd-prims and then just use hydra for rendering, but then I thought that the whole logic has to be written in the custom app, and OpenUSD and Hydra were going to be just a storage and a renderer.

In this case, if the logic (the actual engine) is a SceneIndex plugin, you could actually “play” a scene in usdview or any other host that supports Hydra-2.0 basically.

I’ve got some basic things going so far, like, I can go through doors that open when the “character” (camera or a specific prim) gets close to them, or lights changing intensity/exposure based on distance to the character or shooting new assets in the scene.
This works in my simple usdviewer and in the default usdview (the “shooting” is triggered via api, setting a primvar on a root “/game” prim, and everything else is like based on current-camera update.

I was wondering pros and cons of something like this, and one thing that got to my mind is that there is no way currently to serialize the Hydra scene to a file on disk.

The usd file describes just the “initial state” of the game, and all that happens is hydra-modifications, but not having the ability to serialize the status of the hydra scene on disk, feels an important limitation.

Will there ever be a way to serialize Hydra to disk ?
( This would actually deserve its own topic, as it could be pretty useful for offline-renders too ).

One first question I have is about editing transforms: is there a better way than using a generic DataSource editor for xforms ? I’ve seen a MaterialNetwork, but couldn’t find a xform one.

I’m currently doing this, inspired by one of the Overlay examples, and it seems to be working as expected:

matrixContainer =
    HdContainerDataSourceEditor()
        .Set(L("matrix"), HdRetainedTypedSampledDataSource<GfMatrix4d>::New(newMatrix))
        .Finish();

prim.dataSource = 
    HdContainerDataSourceEditor(prim.dataSource)
        .Overlay(L("xform"), matrixContainer)
        .Finish();

Cheers!

Hi Paolo. Our team plans to contribute a PR for a text hydra delegate.

Thanks @nvmkuruc nice.
that’s just output from Hydra right ? a delegate dumping hdprims in text, am I understanding that correctly ?
I was wondering if a hydra serialize/deserialize would be useful, in a way to also skip usd-composition entirely, and just “render” a scene.

In my case, I’m writing out a json file to read it back it as the “state of the game”, but I guess my original question was really generic, and I think I will start a new thread about that :slight_smile: