示例#1
0
        public void Awake()
        {
            this.m_Server      = new SimpleTcpServer();
            this.m_Environment = GetComponent <VirtualEnvironment>();

            RenderSingleCamera(-1);
        }
        private static void CreateVirtualEnvironment(MenuCommand command, bool stereo)
        {
            VirtualEnvironment environment = null;

            environment = VirtualUtility.CreateEnvironment(VirtualEnvironment.GetDefaultDimensions(), stereo,
                                                           Vector3.forward * 0.5f * VirtualEnvironment.GetDefaultDimensions().z);

            GameObjectUtility.SetParentAndAlign(environment.gameObject, command.context as GameObject);
            Undo.RegisterCreatedObjectUndo(environment, "Create " + environment.name);
            Selection.activeObject = environment;
        }
示例#3
0
        /// <summary>
        /// Collects the calibration data of every camera in the environment.
        /// </summary>
        /// <param name="environment"></param>
        /// <returns>All camera calibrations of the specified environment.</returns>
        public static VirtualCamera.Calibration[] CollectCalibrations(VirtualEnvironment environment)
        {
            var cameras      = environment.cameras;
            var calibrations = new VirtualCamera.Calibration[cameras.Length];

            for (int i = 0; i < cameras.Length; ++i)
            {
                calibrations[i] = cameras[i].GetCalibration();
            }

            return(calibrations);
        }
        public static void DrawDimensionsGizmos(VirtualEnvironment environment, GizmoType type)
        {
            Gizmos.color = Color.yellow;

            var transform  = environment.transform;
            var dimensions = environment.dimensions;

            var ba = transform.TransformPoint(new Vector3(dimensions.x * -0.5f, 0f, dimensions.z * 0.5f));
            var bb = transform.TransformPoint(new Vector3(dimensions.x * 0.5f, 0f, dimensions.z * 0.5f));
            var bc = transform.TransformPoint(new Vector3(dimensions.x * -0.5f, 0f, dimensions.z * -0.5f));
            var bd = transform.TransformPoint(new Vector3(dimensions.x * 0.5f, 0f, dimensions.z * -0.5f));
            var ta = transform.TransformPoint(new Vector3(dimensions.x * -0.5f, dimensions.y, dimensions.z * 0.5f));
            var tb = transform.TransformPoint(new Vector3(dimensions.x * 0.5f, dimensions.y, dimensions.z * 0.5f));
            var tc = transform.TransformPoint(new Vector3(dimensions.x * -0.5f, dimensions.y, dimensions.z * -0.5f));
            var td = transform.TransformPoint(new Vector3(dimensions.x * 0.5f, dimensions.y, dimensions.z * -0.5f));

            Gizmos.DrawRay(ba, Vector3.ClampMagnitude(bb - ba, 0.4f));
            Gizmos.DrawRay(ba, Vector3.ClampMagnitude(bc - ba, 0.4f));
            Gizmos.DrawRay(ba, Vector3.ClampMagnitude(ta - ba, 0.4f));

            Gizmos.DrawRay(bb, Vector3.ClampMagnitude(ba - bb, 0.4f));
            Gizmos.DrawRay(bb, Vector3.ClampMagnitude(bd - bb, 0.4f));
            Gizmos.DrawRay(bb, Vector3.ClampMagnitude(tb - bb, 0.4f));

            Gizmos.DrawRay(bc, Vector3.ClampMagnitude(bd - bc, 0.4f));
            Gizmos.DrawRay(bc, Vector3.ClampMagnitude(ba - bc, 0.4f));
            Gizmos.DrawRay(bc, Vector3.ClampMagnitude(tc - bc, 0.4f));

            Gizmos.DrawRay(bd, Vector3.ClampMagnitude(bc - bd, 0.4f));
            Gizmos.DrawRay(bd, Vector3.ClampMagnitude(bb - bd, 0.4f));
            Gizmos.DrawRay(bd, Vector3.ClampMagnitude(td - bd, 0.4f));

            Gizmos.DrawRay(ta, Vector3.ClampMagnitude(tb - ta, 0.4f));
            Gizmos.DrawRay(ta, Vector3.ClampMagnitude(tc - ta, 0.4f));
            Gizmos.DrawRay(ta, Vector3.ClampMagnitude(ba - ta, 0.4f));

            Gizmos.DrawRay(tb, Vector3.ClampMagnitude(ta - tb, 0.4f));
            Gizmos.DrawRay(tb, Vector3.ClampMagnitude(td - tb, 0.4f));
            Gizmos.DrawRay(tb, Vector3.ClampMagnitude(bb - tb, 0.4f));

            Gizmos.DrawRay(tc, Vector3.ClampMagnitude(td - tc, 0.4f));
            Gizmos.DrawRay(tc, Vector3.ClampMagnitude(ta - tc, 0.4f));
            Gizmos.DrawRay(tc, Vector3.ClampMagnitude(bc - tc, 0.4f));

            Gizmos.DrawRay(td, Vector3.ClampMagnitude(tc - td, 0.4f));
            Gizmos.DrawRay(td, Vector3.ClampMagnitude(tb - td, 0.4f));
            Gizmos.DrawRay(td, Vector3.ClampMagnitude(bd - td, 0.4f));
        }
示例#5
0
        /// <summary>
        /// Matches and applies the new calibrations to the cameras
        /// in the environment.
        /// </summary>
        /// <param name="environment">The target environment.</param>
        /// <param name="calibrations">The new calibrations.</param>
        public static void MatchAndApplyCalibrations(VirtualEnvironment environment,
                                                     VirtualCamera.Calibration[] calibrations)
        {
            var cameras = environment.cameras;

            for (int i = 0; i < calibrations.Length; ++i)
            {
                for (int j = 0; j < cameras.Length; ++j)
                {
                    if (cameras[j].name == calibrations[i].name)
                    {
                        cameras[j].ApplyCalibration(calibrations[i]);
                        break;
                    }
                }
            }
        }
示例#6
0
        public static VirtualCamera CreateCamera(VirtualEnvironment environment,
                                                 VirtualScreen.Kind kind, VirtualEyes.StereoTarget target)
        {
            var camera = new GameObject($"Virtual Camera {kind}")
                         .AddComponent <VirtualCamera>();

            if (target != VirtualEyes.StereoTarget.Mono)
            {
                camera.name += target == VirtualEyes.StereoTarget.Left ? " L" : " R";
            }

            camera.stereoTarget       = target;
            camera.screenKind         = kind;
            camera.transform.parent   = environment.transform;
            camera.transform.position = environment.eyes.transform.position;
            camera.transform.rotation = environment.transform.rotation * VirtualScreen.GetLocalRotation(kind);

            return(camera);
        }