Exemple #1
0
        /// <summary>
        /// Copyies the current sample values to the given camera.
        /// </summary>
        public void CopyToCamera(UnityEngine.Camera camera, bool setTransform)
        {
            // GfCamera is a gold mine of camera math.
            pxr.GfCamera c = new pxr.GfCamera(UnityTypeConverter.ToGfMatrix(transform),
                                              projection == ProjectionType.Perspective ? pxr.GfCamera.Projection.Perspective
                                                   : pxr.GfCamera.Projection.Orthographic,
                                              this.horizontalAperture,
                                              this.verticalAperture,
                                              this.horizontalApertureOffset,
                                              this.verticalApertureOffset,
                                              this.focalLength);

            camera.orthographic  = c.GetProjection() == pxr.GfCamera.Projection.Orthographic;
            camera.fieldOfView   = c.GetFieldOfView(pxr.GfCamera.FOVDirection.FOVVertical);
            camera.aspect        = c.GetAspectRatio();
            camera.nearClipPlane = clippingRange.x;
            camera.farClipPlane  = clippingRange.y;

            if (camera.orthographic)
            {
                // Note that USD default scale is cm and aperture is in mm.
                // Also Unity ortho size is the half aperture, so divide USD by 2.
                camera.orthographicSize = (verticalAperture / 10.0f) / 2.0f;
            }

            if (setTransform)
            {
                var tr = camera.transform;
                var xf = transform;
                UnityTypeConverter.SetTransform(xf, tr);
            }
        }
Exemple #2
0
        /// <summary>
        /// Copyies the current sample values to the given camera.
        /// </summary>
        public void CopyToCamera(UnityEngine.Camera camera)
        {
            // GfCamera is a gold mine of camera math.
            pxr.GfCamera c = new pxr.GfCamera(UnityTypeConverter.ToGfMatrix(transform));

            camera.orthographic  = c.GetProjection() == pxr.GfCamera.Projection.Orthographic;
            camera.fieldOfView   = c.GetFieldOfView(pxr.GfCamera.FOVDirection.FOVVertical);
            camera.aspect        = c.GetAspectRatio();
            camera.nearClipPlane = c.GetClippingRange().GetMin();
            camera.farClipPlane  = c.GetClippingRange().GetMax();

            var tr = camera.transform;
            var xf = transform;

            UnityTypeConverter.SetTransform(xf, tr);
        }