// Update is called once per frame void Update() { transform.position = new Vector3(0, 0, -10); if (Input.GetKeyDown(KeyCode.M)) { this.GetComponent <Renderer>().enabled = true; } if (this.GetComponent <Renderer>().enabled) { RaycastHit hit; FoveInterface foveInterface = transform.parent.GetComponent <FoveInterface>(); Ray ray = new Ray(foveInterface.transform.position, foveInterface.transform.forward); if (Physics.Raycast(ray, out hit, 10.0f)) { transform.position = hit.point; } else { transform.position = foveInterface.transform.position + foveInterface.transform.forward * 10f; } } if (Input.GetKeyUp(KeyCode.M)) { this.GetComponent <Renderer>().enabled = false; Vector3 loc = transform.localPosition; Fove.Managed.SFVR_Vec3 driftLocation; driftLocation.x = loc.x; driftLocation.y = loc.y; driftLocation.z = loc.z; FoveInterfaceBase.GetFVRHeadset().ManualDriftCorrection3D(driftLocation); } }
public void Initialize() { if (FocusSizeFromCenter == null) { Reset(); } #if UNITY_EDITOR || DEVELOPMENT_BUILD VISFixationEnds.Add("discard", new List <Fixation>()); VISFixationEnds.Add("out of range", new List <Fixation>()); VISFixationEnds.Add("microsleep", new List <Fixation>()); VISFixationEnds.Add("off transform", new List <Fixation>()); var viewer = FindObjectOfType <FixationVisualizer>(); if (viewer != null) { viewer.SetTarget(this); } var saccade = FindObjectOfType <SaccadeDrawer>(); if (saccade != null) { saccade.SetTarget(this); } //gameObject.AddComponent<FixationVisualizer>().SetTarget(this); if (DebugMaterial != null) { lastEyeTrackingPointer = GameObject.CreatePrimitive(PrimitiveType.Sphere); lastEyeTrackingPointer.transform.localScale = Vector3.one * 0.2f; lastEyeTrackingPointer.GetComponent <MeshRenderer>().material = DebugMaterial; Destroy(lastEyeTrackingPointer.GetComponent <SphereCollider>()); } #endif ActiveFixation = new Fixation(); for (int i = 0; i < CachedEyeCaptures; i++) { EyeCaptures[i] = new EyeCapture() { Discard = true }; } #if CVR_FOVE fovebase = FindObjectOfType <FoveInterfaceBase>(); #elif CVR_TOBIIVR if (EyeTracker == null) { EyeTracker = FindObjectOfType <Tobii.Research.Unity.VREyeTracker>(); } #elif CVR_AH ah_calibrator = Calibrator.Instance; eyetracker = EyeTracker.Instance; #endif }
public FoveCameraPair(FVRCompositor compositor, FoveInterfaceBase xface) { left = null; right = null; var createInfo = new SFVR_CompositorLayerCreateInfo { alphaMode = EFVR_AlphaMode.Auto, disableDistortion = xface.DistortionDisabled, disableTimewarp = xface.TimewarpDisabled, disableFading = xface.FadingDisabled, type = xface.LayerType }; var err = compositor.CreateLayer(createInfo, out layer); if (err != EFVR_ErrorCode.None) { Debug.LogError("[FOVE] Error getting layer: " + err); } Debug.Log("[FOVE] Layer requested no distortion? " + createInfo.disableDistortion); }
void Start() { _headset = FoveInterfaceBase.GetFVRHeadset(); _lastScale = resolutionScale; _lastAA = antiAliasing; FoveCameraPair myPair = GetNextLayerPair(whichEye, this); myPair.SetCamera(whichEye, this); SFVR_CompositorLayer layer = myPair.layer; SFVR_Vec2i res = layer.idealResolutionPerEye; var rt = new RenderTexture((int)(res.x * resolutionScale), (int)(res.y * resolutionScale), 24); rt.antiAliasing = antiAliasing; _cam = gameObject.GetComponent <Camera>(); _cam.targetTexture = rt; _cam.enabled = false; switch (whichEye) { case EFVR_Eye.Left: SetSubmitBounds(ref _layerSubmitInfo.left); _layerSubmitInfo.left.texInfo.colorSpace = EFVR_ColorSpace.Linear; break; case EFVR_Eye.Right: SetSubmitBounds(ref _layerSubmitInfo.right); _layerSubmitInfo.left.texInfo.colorSpace = EFVR_ColorSpace.Linear; break; } _layerSubmitInfo.layerId = myPair.layer.layerId; }
// Currently does not support editing of multiple objects at once. // I do not anticipate any problems with this since you should only // ever really have one per scene anyway. public sealed override void OnInspectorGUI() { // A decent style. Light grey text inside a border. helpStyle = new GUIStyle(GUI.skin.box); helpStyle.wordWrap = true; helpStyle.alignment = TextAnchor.UpperLeft; helpStyle.normal.textColor = Color.red; // Update the serializedobject serializedObject.Update(); EditorGUILayout.PropertyField(_worldScale); // Cache the editor's playing state so we can prevent editing fields that shouldn't update during // a live play session. bool isPlaying = EditorApplication.isPlaying; EditorGUILayout.Space(); EditorGUILayout.LabelField("Client uses...", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_gaze); EditorGUILayout.PropertyField(_orientation); EditorGUILayout.PropertyField(_position); EditorGUI.indentLevel--; } if (EditorGUI.EndChangeCheck()) { FoveInterfaceBase xface = target as FoveInterfaceBase; if (xface != null) { xface.ReloadFoveClient(); } } EditorGUILayout.Space(); EditorGUILayout.PropertyField(_skipAutoCalibrationCheck); EditorGUILayout.PropertyField(_oversamplingRatio); GUI.enabled = true; _showOverrides = EditorGUILayout.Foldout(_showOverrides, "Headset Overrides"); if (_showOverrides) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_useCustomPositionScaling); GUI.enabled = _useCustomPositionScaling.boolValue; { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_posScales); EditorGUI.indentLevel--; } GUI.enabled = true; EditorGUILayout.PropertyField(_usesCustomPlacement); GUI.enabled = _usesCustomPlacement.boolValue; // & !isPlaying; // not modifiable in play mode { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_IOD); EditorGUILayout.PropertyField(_eyeHeight); EditorGUILayout.PropertyField(_eyeForward); EditorGUI.indentLevel--; } GUI.enabled = true; EditorGUILayout.PropertyField(_suppressProjectionUpdates); EditorGUI.indentLevel--; } GUI.enabled = true; _showCompositorAttribs = EditorGUILayout.Foldout(_showCompositorAttribs, "Compositor options"); if (_showCompositorAttribs) { GUI.enabled = !isPlaying; EditorGUI.indentLevel++; EditorGUILayout.PropertyField(_compositorLayerType); EditorGUILayout.PropertyField(_compositorDisableTimewarp); EditorGUILayout.PropertyField(_compositorDisableDistortion); EditorGUI.indentLevel--; } GUI.enabled = true; if (isPlaying && GUILayout.Button("Ensure calibration")) { Debug.Log("Manually triggering eye tracking calibration check from inspector..."); FoveInterface.EnsureEyeTrackingCalibration(); } if (Application.targetFrameRate != -1) { GUILayout.Label( "WARNING: Your target framerate is set to " + Application.targetFrameRate + ". Having a target framerate can artificially slow down FOVE frame submission. We recommend disabling this." , helpStyle , GUILayout.ExpandWidth(true)); } DrawLocalGUIEditor(); serializedObject.ApplyModifiedProperties(); // Tell a live FoveInterfaceBase object to try to update itself if (isPlaying && GUI.changed) { FoveInterfaceBase xface = target as FoveInterfaceBase; if (xface != null) { xface.RefreshSetup(); } } }