コード例 #1
0
        private void CognitiveVR_Manager_OnTick()
        {
            if (CognitiveVR_Manager.HMD != null)
            {
                periodicRenderer = CognitiveVR_Manager.HMD.GetComponent <PlayerTrackerHelper>();

                if (periodicRenderer == null)
                {
                    periodicRenderer         = CognitiveVR_Manager.HMD.gameObject.AddComponent <PlayerTrackerHelper>();
                    periodicRenderer.enabled = false;
                }
                cam = CognitiveVR_Manager.HMD.GetComponent <Camera>();
                cam.depthTextureMode = DepthTextureMode.Depth;
            }

            if (!headsetPresent || CognitiveVR_Manager.HMD == null)
            {
                return;
            }

            RenderTexture rt = null;

            if (CognitiveVR_Preferences.Instance.TrackGazePoint)
            {
                periodicRenderer.enabled = true;
                rt = periodicRenderer.DoRender(new RenderTexture(width, height, 0));
                periodicRenderer.enabled = false;
            }

            PlayerSnapshot snapshot = new PlayerSnapshot();

            snapshot.Properties.Add("position", cam.transform.position);
            snapshot.Properties.Add("gazeDirection", cam.transform.forward);
            snapshot.Properties.Add("nearDepth", cam.nearClipPlane);
            snapshot.Properties.Add("farDepth", cam.farClipPlane);
            snapshot.Properties.Add("time", Time.time);
            snapshot.Properties.Add("renderDepth", rt);

#if CVR_STEAMVR
            if (Valve.VR.OpenVR.Chaperone != null)
            {
                snapshot.Properties.Add("chaperoneVisible", Valve.VR.OpenVR.Chaperone.AreBoundsVisible());
            }
#endif
            playerSnapshots.Add(snapshot);
            if (playerSnapshots.Count >= CognitiveVR_Preferences.Instance.SnapshotThreshold)
            {
                SendData();
            }
        }
コード例 #2
0
        /// <returns>{gaze point}</returns>
        public static string SetGazePont(PlayerSnapshot snap)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();
            builder.Append("{");

            builder.Append(SetObject("time", snap.timestamp));
            builder.Append(",");
            builder.Append(SetPos("p", (Vector3)snap.Properties["position"]));
            builder.Append(",");
            builder.Append(SetPos("g", (Vector3)snap.Properties["gazePoint"]));

            builder.Append("}");

            return(builder.ToString());
        }