Exemplo n.º 1
0
        /// <summary>
        /// Starts a CognitiveVR session. Records hardware info, creates network manager
        /// </summary>
        public static Error Init(Transform HMDCamera)
        {
            _hmd = HMDCamera;
            CognitiveStatics.Initialize();
            CustomEvent.Initialize();

            Error error = Error.None;

            // Have we already initialized CognitiveVR?
            if (IsInitialized)
            {
                Util.logWarning("CognitiveVR has already been initialized, no need to re-initialize");
                error = Error.AlreadyInitialized;
            }

            if (error == Error.None)
            {
                SetSessionProperty("c3d.app.name", Application.productName);
                SetSessionProperty("c3d.app.version", Application.version);
                SetSessionProperty("c3d.app.engine.version", Application.unityVersion);
                SetSessionProperty("c3d.device.type", SystemInfo.deviceType.ToString());
                SetSessionProperty("c3d.device.cpu", SystemInfo.processorType);
                SetSessionProperty("c3d.device.model", SystemInfo.deviceModel);
                SetSessionProperty("c3d.device.gpu", SystemInfo.graphicsDeviceName);
                SetSessionProperty("c3d.device.os", SystemInfo.operatingSystem);
                SetSessionProperty("c3d.device.memory", Mathf.RoundToInt(SystemInfo.systemMemorySize / 1024));

                DeviceId = UnityEngine.SystemInfo.deviceUniqueIdentifier;
                SetSessionProperty("c3d.deviceid", DeviceId);

                //initialize Network Manager early, before gameplay actually starts
                var temp = NetworkManager.Sender;

                DynamicManager.Initialize();
                DynamicObjectCore.Initialize();

                _timestamp = Util.Timestamp();
                //set session timestamp
                if (string.IsNullOrEmpty(_sessionId))
                {
                    _sessionId = (int)SessionTimeStamp + "_" + DeviceId;
                }

                IsInitialized = true;
            }

            return(error);
        }
Exemplo n.º 2
0
        void SendResponsesAsTransaction()
        {
            var exitpoll = new CustomEvent("cvr.exitpoll");

            exitpoll.SetProperty("userId", CognitiveVR.Core.UniqueID);
            exitpoll.SetProperty("questionSetId", QuestionSetId);
            exitpoll.SetProperty("hook", RequestQuestionHookName);

            var scenesettings = Core.TrackingScene;

            if (scenesettings != null && !string.IsNullOrEmpty(scenesettings.SceneId))
            {
                exitpoll.SetProperty("sceneId", scenesettings.SceneId);
            }

            foreach (var property in transactionProperties)
            {
                exitpoll.SetProperty(property.Key, property.Value);
            }
            exitpoll.Send(CurrentExitPollPanel.transform.position);
            Core.SendDataEvent();
        }
Exemplo n.º 3
0
        void SendResponsesAsTransaction()
        {
            var exitpollEvent = new CustomEvent("cvr.exitpoll");

            exitpollEvent.SetProperty("userId", CognitiveVR.Core.DeviceId);
            exitpollEvent.SetProperty("questionSetId", QuestionSetId);
            exitpollEvent.SetProperty("hook", myparameters.Hook);
            exitpollEvent.SetProperty("duration", Util.Timestamp() - StartTime);

            var scenesettings = Core.TrackingScene;

            if (scenesettings != null && !string.IsNullOrEmpty(scenesettings.SceneId))
            {
                exitpollEvent.SetProperty("sceneId", scenesettings.SceneId);
            }

            foreach (var property in transactionProperties)
            {
                exitpollEvent.SetProperty(property.Key, property.Value);
            }
            exitpollEvent.Send(CurrentExitPollPanel.transform.position);
            Core.InvokeSendDataEvent();
        }
Exemplo n.º 4
0
        private void CognitiveVR_Manager_TickEvent()
        {
            if (!IsVideo)
            {
                return;
            }
            if (WasPlaying)
            {
                if (!VideoPlayer.isPlaying)
                {
                    if (VideoPlayer.frame == 0)
                    {
                        //stopped event
                        CustomEvent.SendCustomEvent("cvr.media.stop", new List <KeyValuePair <string, object> >()
                        {
                            new KeyValuePair <string, object>("videoTime", lastFrame), new KeyValuePair <string, object>("mediaId", MediaSource)
                        }, transform.position);
                    }
                    else
                    {
                        //paused event
                        CustomEvent.SendCustomEvent("cvr.media.pause", new List <KeyValuePair <string, object> >()
                        {
                            new KeyValuePair <string, object>("videoTime", VideoPlayer.frame), new KeyValuePair <string, object>("mediaId", MediaSource)
                        }, transform.position);
                    }
                    WasPlaying = false;
                }
                lastFrame = VideoPlayer.frame;
            }
            else
            {
                if (VideoPlayer.isPlaying)
                {
                    //play event
                    CustomEvent.SendCustomEvent("cvr.media.play", new List <KeyValuePair <string, object> >()
                    {
                        new KeyValuePair <string, object>("videoTime", VideoPlayer.frame), new KeyValuePair <string, object>("mediaId", MediaSource)
                    }, transform.position);
                    WasPlaying = true;
                }
            }
            //register to prepare_complete to see if video has finished buffering
            //how to tell if video starts buffering again?

            if (wasPrepared)
            {
                if (!VideoPlayer.isPrepared) //started buffering. possibly stopped
                {
                    wasPrepared = false;
                    CustomEvent.SendCustomEvent("cvr.media.videoBuffer", new List <KeyValuePair <string, object> >()
                    {
                        new KeyValuePair <string, object>("videoTime", VideoPlayer.frame), new KeyValuePair <string, object>("mediaId", MediaSource)
                    }, transform.position);
                }
            }
            else
            {
                if (VideoPlayer.isPrepared) //finishing buffering
                {
                    wasPrepared = true;
                }
            }
        }