2

I have a few scenes in Unity that I am trying to export using the USD package. That package has various options for export (from the Menu, over the recorder, via API calls), and I have tried them all, but the resulting file (inspected with usdview) – while it has all the graphics pieces inside - doesn’t respect the hierarchical transformations that I have set up.

This small example explains the problem, I have a cube and two sphere on a plane. The spheres are centered in local coordinates on 0,0,0, but they have parent “SphereHolder” GameObjects that have a transform that moves them to different places. When I export the scene, I can see with usdview that all the pieces were exported, and the “SphereHolder” primitives even have their transformations, but they are not being applied to the child objects.

I am new to USD and can’t tell from the documentation is this is correct behavior, but I think it probably is. But there still must be a way to get these transforms to behave hierarchically?

So this is my scene in Unity: enter image description here

Here it is again in usdview - note that the two spheres are rendered on top of one another: enter image description here

Here is a relevant exerpt from the usda file:

def "SphereHolder2"
    {
        matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 3.119999885559082, 1) )
        uniform token[] xformOpOrder = ["xformOp:transform"]

        def Mesh "Sphere"
        {
            uniform bool doubleSided
            float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
            int[] faceVertexCounts = [3, ..., 3]
            int[] faceVertexIndices = [177,... 510]
            rel material:binding = </SimpleScene/Materials/Yellow_22846>
            normal3f[] normals = [(0.57735026, ...-0.6960511)]
            uniform token orientation
            point3f[] points = [(0.28782713, ...-0.34812742)]
            color4f[] primvars:colors (
                elementSize = 1
                interpolation = "constant"
            )
            color3f[] primvars:displayColor = [(1, 1, 0)] (
                interpolation = "constant"
            )
            float[] primvars:displayOpacity = [1] (
                interpolation = "constant"
            )
            float2[] primvars:st = [(0.37379926, ...  0.72115314)] (
                elementSize = 1
                interpolation = "constant"
            )
            float4[] primvars:tangents = [(0.70633, ... -0.24267794, -1)] (
                elementSize = 1
                interpolation = "vertex"
            )
            uniform token purpose
            token visibility
            matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) )
            uniform token[] xformOpOrder = ["xformOp:transform"]
        }
    }

And here is the relevent Unity USD Package export lines:

            ssgo = GameObject.Find("SimpleScene");
            if (ssgo != null)
            {
                context = new ExportContext();
                context.scene = scene;
                context.scene.Time = null;
                context.activePolicy = ActiveExportPolicy.ExportAsVisibility;

                SceneExporter.SyncExportContext(ssgo, context);
                SceneExporter.Export(ssgo, context, zeroRootTransform: false);
            }:

Questions are:

  • Is there a way to specify that usd primtives inherit transformations hierarchically? Then I could at least do a custom exporter (more work but not a huge amount)
  • Why is this an issue just for me? Wouldn't almost any 3D export project run into this?
  • Are there any workarounds I am overlooking? Pushing all the transformations down to the leaves seems like the wrong thing to do.
Mike Wise
  • 22,131
  • 8
  • 81
  • 104

0 Answers0