void ConvertRecursive(Transform t, string path)
        {
            path = (string)path.Clone();
            if (path.Length > 0)
            {
                path += "/";
            }
            path += t.name;

            var cmp = t.GetComponent <UsdIComponent>();

            if (cmp != null)
            {
                m_reporter.Write("converting " + cmp.schema.primName + " ...\n");
                var schema = cmp.schema;
                m_rcpTimeScale = 1.0f / schema.stream.timeUnit.scale;
                ConvertXform(schema as UsdXform, path);
                ConvertCamera(schema as UsdCamera, path);
                ConvertMesh(schema as UsdMesh, path);
                ConvertPoints(schema as UsdPoints, path);
            }

            int nchildren = t.childCount;

            for (int i = 0; i < nchildren; ++i)
            {
                ConvertRecursive(t.GetChild(i), path);
            }
        }
Beispiel #2
0
        void Generate()
        {
            usdi.ProgressReporter reporter = new usdi.ProgressReporter();
            UsdStream             stream   = null;

            int ndone = 0;

            if (m_stream != null)
            {
                reporter.Open();
                stream = m_stream;
                var meshes  = new List <usdi.Mesh>();
                var results = new List <bool>();
                usdi.usdiPreComputeNormalsAll(m_stream.usdiContext, s_genTangents, s_overwrite, (usdi.Mesh mesh, Bool done) => {
                    meshes.Add(mesh);
                    results.Add(done);
                    if (done)
                    {
                        ++ndone;
                        reporter.Write("done: " + usdi.usdiPrimGetNameS(mesh) + "\n");
                    }
                    else
                    {
                        reporter.Write("skipped: " + usdi.usdiPrimGetNameS(mesh) + "\n");
                    }
                });
                for (int i = 0; i < meshes.Count; ++i)
                {
                    var mesh = meshes[i];
                    if (results[i])
                    {
                        Debug.Log("Precompute done: " + usdi.usdiPrimGetNameS(mesh));
                    }
                    else
                    {
                        Debug.Log("Precompute skipped: " + usdi.usdiPrimGetNameS(mesh));
                    }
                }
            }
            else if (m_mesh != null)
            {
                stream = m_mesh.stream;
                var mesh = m_mesh.nativeMeshPtr;
                var ret  = usdi.usdiMeshPreComputeNormals(mesh, s_genTangents, s_overwrite);
                if (ret)
                {
                    Debug.Log("Precompute done: " + usdi.usdiPrimGetPathS(mesh));
                    ++ndone;
                }
                else
                {
                    Debug.Log("Precompute skipped: " + usdi.usdiPrimGetPathS(mesh));
                }
            }

            if (stream != null && ndone > 0)
            {
                reporter.Write("flushing to file ... ");
                stream.usdiSave();
                stream.usdiReload();
                reporter.Write("done.\n");
            }
            reporter.Close();
        }