Esempio n. 1
0
        void ExportCamera(Scene scene, GameObject go, ExportPlan exportPlan)
        {
            CameraSample sample = (CameraSample)exportPlan.sample;
            Camera       camera = go.GetComponent <Camera>();

            sample.CopyFromCamera(camera);
            scene.Write(exportPlan.path, sample);
        }
Esempio n. 2
0
        public static void ExportCamera(ObjectContext objContext, ExportContext exportContext)
        {
            UnityEngine.Profiling.Profiler.BeginSample("USD: Camera Conversion");

            CameraSample sample      = (CameraSample)objContext.sample;
            Camera       camera      = objContext.gameObject.GetComponent <Camera>();
            var          path        = objContext.path;
            var          scene       = exportContext.scene;
            bool         fastConvert = exportContext.basisTransform == BasisTransformation.FastWithNegativeScale;

            // If doing a fast conversion, do not let the constructor do the change of basis for us.
            sample.CopyFromCamera(camera, convertTransformToUsd: !fastConvert);

            if (fastConvert)
            {
                // Partial change of basis.
                var basisChange = Matrix4x4.identity;
                // Invert the forward vector.
                basisChange[2, 2] = -1;
                // Full change of basis would be b*t*b-1, but here we're placing only a single inversion
                // at the root of the hierarchy, so all we need to do is get the camera into the same
                // space.
                sample.transform = sample.transform * basisChange;

                // Is this also a root path?
                // If so the partial basis conversion must be completed on the camera itself.
                if (path.LastIndexOf("/") == 0)
                {
                    sample.transform = basisChange * sample.transform;
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();

            UnityEngine.Profiling.Profiler.BeginSample("USD: Camera Write");
            scene.Write(path, sample);
            UnityEngine.Profiling.Profiler.EndSample();
        }