Ejemplo n.º 1
0
        public static void Open(UsdStream stream)
        {
            var window = (UsdPrecomputeNormalsWindow)EditorWindow.GetWindow(typeof(UsdPrecomputeNormalsWindow));

            window.titleContent = new GUIContent("Precompute");
            window.m_stream     = stream;
            window.m_mesh       = null;
            window.Show();
        }
Ejemplo n.º 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();
        }