Exemplo n.º 1
0
        BeginReading(Scene scene,
                     SdfPath usdRoot,
                     PrimMap map,
                     SceneImportOptions options)
        {
            FindPathsJob.usdRoot = usdRoot;
            FindPathsJob.scene   = scene;
            FindPathsJob.results = new SdfPath[8][];
            FindPathsJob.queries = new FindPathsJob.IQuery[8];

            if (options.ShouldBindMaterials)
            {
                FindPathsJob.queries[0] = (FindPathsJob.IQuery) new FindPathsJob.Query <MaterialSample>();
            }
            if (options.importCameras)
            {
                FindPathsJob.queries[1] = (FindPathsJob.IQuery) new FindPathsJob.Query <CameraSample>();
            }
            if (options.importMeshes)
            {
                FindPathsJob.queries[2] = (FindPathsJob.IQuery) new FindPathsJob.Query <MeshSample>();
                FindPathsJob.queries[3] = (FindPathsJob.IQuery) new FindPathsJob.Query <CubeSample>();
                FindPathsJob.queries[4] = (FindPathsJob.IQuery) new FindPathsJob.Query <SphereSample>();
            }

            FindPathsJob.queries[5] = (FindPathsJob.IQuery) new FindPathsJob.Query <SkelRootSample>();

            if (options.importSkinning)
            {
                FindPathsJob.queries[6] = (FindPathsJob.IQuery) new FindPathsJob.Query <SkeletonSample>();
            }
            if (options.importTransforms)
            {
                FindPathsJob.queries[7] = (FindPathsJob.IQuery) new FindPathsJob.Query <XformSample>();
            }

            var findPathsJob = new FindPathsJob();

#if !UNITY_2017
            var findHandle = findPathsJob.Schedule(FindPathsJob.queries.Length, 1);
            findHandle.Complete();
#else
            findPathsJob.Run();
#endif

            map.Materials = FindPathsJob.results[0];
            map.Cameras   = FindPathsJob.results[1];
            map.Meshes    = FindPathsJob.results[2];
            map.Cubes     = FindPathsJob.results[3];
            map.Spheres   = FindPathsJob.results[4];
            map.SkelRoots = FindPathsJob.results[5];
            map.Skeletons = FindPathsJob.results[6];
            map.Xforms    = FindPathsJob.results[7];

            ReadHierJob.paths     = FindPathsJob.results.Where(i => i != null).SelectMany(i => i).ToArray();
            ReadHierJob.result    = new HierInfo[ReadHierJob.paths.Length];
            ReadHierJob.scene     = scene;
            ReadHierJob.skelCache = map.SkelCache;
            var readHierInfo = new ReadHierJob();
#if !UNITY_2017
            return(readHierInfo.Schedule(ReadHierJob.paths.Length, 8, dependsOn: findHandle));
#else
            readHierInfo.Run();
            return;
#endif
        }
Exemplo n.º 2
0
        static JobHandle BeginReading(Scene scene,
                                      SdfPath usdRoot,
                                      PrimMap map,
                                      SceneImportOptions options)
        {
            FindPathsJob.usdRoot = usdRoot;
            FindPathsJob.scene   = scene;
            FindPathsJob.results = new SdfPath[9][];
            FindPathsJob.queries = new FindPathsJob.IQuery[9];

            if (options.ShouldBindMaterials)
            {
                FindPathsJob.queries[0] = (FindPathsJob.IQuery) new FindPathsJob.Query <MaterialSample>();
            }

            if (options.importCameras)
            {
                FindPathsJob.queries[1] = (FindPathsJob.IQuery) new FindPathsJob.Query <CameraSample>();
            }

            if (options.importMeshes)
            {
                FindPathsJob.queries[2] = (FindPathsJob.IQuery) new FindPathsJob.Query <MeshSample>();
                FindPathsJob.queries[3] = (FindPathsJob.IQuery) new FindPathsJob.Query <CubeSample>();
                FindPathsJob.queries[4] = (FindPathsJob.IQuery) new FindPathsJob.Query <SphereSample>();
            }

            FindPathsJob.queries[5] = (FindPathsJob.IQuery) new FindPathsJob.Query <SkelRootSample>();

            if (options.importSkinning)
            {
                FindPathsJob.queries[6] = (FindPathsJob.IQuery) new FindPathsJob.Query <SkeletonSample>();
            }

            if (options.importTransforms)
            {
                FindPathsJob.queries[7] = (FindPathsJob.IQuery) new FindPathsJob.Query <XformSample>();
            }

            FindPathsJob.queries[8] = (FindPathsJob.IQuery) new FindPathsJob.Query <ScopeSample>();

            var findPathsJob = new FindPathsJob();
            var findHandle   = findPathsJob.Schedule(FindPathsJob.queries.Length, 1);

            findHandle.Complete();

            // Note that Scope prims are taken into account when building the hierarchy but not added to the PrimMap
            // This is because Scopes don't need specific import/export logic for now:
            //   * they don't hold any data ton convert on the way in
            //   * being represented as Xforms in Unity they get automatically exported (as Xform) as part of the parent hierarchy of any
            //     valid prim
            // This will need to change if/when we want proper round tripping.
            map.Materials = FindPathsJob.results[0];
            map.Cameras   = FindPathsJob.results[1];
            map.Meshes    = FindPathsJob.results[2];
            map.Cubes     = FindPathsJob.results[3];
            map.Spheres   = FindPathsJob.results[4];
            map.SkelRoots = FindPathsJob.results[5];
            map.Skeletons = FindPathsJob.results[6];
            map.Xforms    = FindPathsJob.results[7];

            ReadHierJob.paths     = FindPathsJob.results.Where(i => i != null).SelectMany(i => i).ToArray();
            ReadHierJob.result    = new HierInfo[ReadHierJob.paths.Length];
            ReadHierJob.scene     = scene;
            ReadHierJob.skelCache = map.SkelCache;
            var readHierInfo = new ReadHierJob();

            return(readHierInfo.Schedule(ReadHierJob.paths.Length, 8, dependsOn: findHandle));
        }