Beispiel #1
0
        internal static void WriteControllerManifestEntry(DynamicData data)
        {
            DynamicObjectManifestEntry dome = new DynamicObjectManifestEntry(data.Id, data.Name, data.MeshName);

            dome.controllerType = data.ControllerType;
            dome.isController   = true;
            if (data.IsRightHand)
            {
                dome.Properties = "\"controller\": \"right\"";
            }
            else
            {
                dome.Properties = "\"controller\": \"left\"";
            }
            dome.HasProperties = true;

            queuedManifest.Enqueue(dome);
            tempsnapshots++;
            if (tempsnapshots > CognitiveVR_Preferences.S_DynamicSnapshotCount)
            {
                if (Time.time > NextMinSendTime || tempsnapshots > CognitiveVR_Preferences.S_DynamicExtremeSnapshotCount)
                {
                    NextMinSendTime = Time.time + CognitiveVR_Preferences.S_DynamicSnapshotMinTimer;
                    //check lastSendTimer and extreme batch size
                    tempsnapshots    = 0;
                    ReadyToWriteJson = true; //mark the coroutine as ready to pull from the queue
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// put data into dynamic manifest
        /// </summary>
        /// <param name="data"></param>
        internal static void WriteDynamicManifestEntry(DynamicData data)
        {
            DynamicObjectManifestEntry dome = new DynamicObjectManifestEntry(data.Id, data.Name, data.MeshName);

            queuedManifest.Enqueue(dome);
            tempsnapshots++;
            if (tempsnapshots > CognitiveVR_Preferences.S_DynamicSnapshotCount)
            {
                tempsnapshots    = 0;
                ReadyToWriteJson = true; //mark the coroutine as ready to pull from the queue
            }
        }
Beispiel #3
0
        /// <summary>
        /// put data into dynamic manifest
        /// </summary>
        /// <param name="data"></param>
        internal static void WriteDynamicManifestEntry(DynamicData data)
        {
            DynamicObjectManifestEntry dome = new DynamicObjectManifestEntry(data.Id, data.Name, data.MeshName);

            queuedManifest.Enqueue(dome);
            tempsnapshots++;
            if (tempsnapshots > CognitiveVR_Preferences.S_DynamicSnapshotCount)
            {
                if (Time.time > NextMinSendTime || tempsnapshots > CognitiveVR_Preferences.S_DynamicExtremeSnapshotCount)
                {
                    NextMinSendTime = Time.time + CognitiveVR_Preferences.S_DynamicSnapshotMinTimer;
                    //check lastSendTimer and extreme batch size
                    tempsnapshots    = 0;
                    ReadyToWriteJson = true; //mark the coroutine as ready to pull from the queue
                }
            }
        }
Beispiel #4
0
        static void SetManifestEntry(DynamicObjectManifestEntry entry, StringBuilder builder)
        {
            builder.Append("\"");
            builder.Append(entry.Id);
            builder.Append("\":{");


            if (!string.IsNullOrEmpty(entry.Name))
            {
                JsonUtil.SetString("name", entry.Name, builder);
                builder.Append(",");
            }
            JsonUtil.SetString("mesh", entry.MeshName, builder);
            builder.Append(",");
            JsonUtil.SetString("fileType", DynamicObjectManifestEntry.FileType, builder);

            if (entry.isVideo)
            {
                JsonUtil.SetString("externalVideoSource", entry.videoURL, builder);
            }

            if (entry.isController)
            {
                builder.Append(",");
                JsonUtil.SetString("controllerType", entry.controllerType, builder);
            }

            //properties should already be formatted, just need to append them here
            if (!string.IsNullOrEmpty(entry.Properties))
            {
                //properties are an array of a single object? weird
                builder.Append(",\"properties\":[{");
                builder.Append(entry.Properties);
                builder.Append("}]");
            }

            builder.Append("}"); //close manifest entry
        }
        //writes manifest entry and object snapshot to string then send http request
        public IEnumerator Thread_StringThenSend(Queue <DynamicObjectManifestEntry> SendObjectManifest, Queue <DynamicObjectSnapshot> SendObjectSnapshots, CognitiveVR_Preferences.SceneSettings trackingSettings, string uniqueid, double sessiontimestamp, string sessionid)
        {
            //save and clear snapshots and manifest entries
            DynamicObjectManifestEntry[] tempObjectManifest = new DynamicObjectManifestEntry[SendObjectManifest.Count];
            SendObjectManifest.CopyTo(tempObjectManifest, 0);
            SendObjectManifest.Clear();


            DynamicObjectSnapshot[] tempSnapshots = new DynamicObjectSnapshot[SendObjectSnapshots.Count];
            SendObjectSnapshots.CopyTo(tempSnapshots, 0);

            //for (int i = 0; i<tempSnapshots.Length; i++)
            //{
            //    var s = DynamicObject.SetSnapshot(tempSnapshots[i]);
            //    Debug.Log(">>>>>>>>>>>>>queue snapshot  " + s);
            //}


            //write manifest entries to thread
            List <string> manifestEntries = new List <string>();
            bool          done            = true;

            if (tempObjectManifest.Length > 0)
            {
                done = false;
                new System.Threading.Thread(() =>
                {
                    for (int i = 0; i < tempObjectManifest.Length; i++)
                    {
                        manifestEntries.Add(DynamicObject.SetManifestEntry(tempObjectManifest[i]));
                    }
                    done = true;
                }).Start();

                while (!done)
                {
                    yield return(null);
                }
            }



            List <string> snapshots = new List <string>();

            if (tempSnapshots.Length > 0)
            {
                done = false;
                new System.Threading.Thread(() =>
                {
                    for (int i = 0; i < tempSnapshots.Length; i++)
                    {
                        snapshots.Add(DynamicObject.SetSnapshot(tempSnapshots[i]));
                    }
                    //System.GC.Collect();
                    done = true;
                }).Start();

                while (!done)
                {
                    yield return(null);
                }
            }

            while (SendObjectSnapshots.Count > 0)
            {
                SendObjectSnapshots.Dequeue().ReturnToPool();
            }

            DynamicObject.SendSavedSnapshots(manifestEntries, snapshots, trackingSettings, uniqueid, sessiontimestamp, sessionid);
        }