Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
392 changes: 386 additions & 6 deletions Runtime/ActiveSessionView/ActiveSessionView.prefab

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions Runtime/ActiveSessionView/Scripts/DataBatchCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DataBatchCanvas : MonoBehaviour
public Text FixationSendText;
public Text DynamicSendText;
public Text SensorSendText;
public Text BoundarySendText;

void Start()
{
Expand All @@ -28,13 +29,17 @@ private void Core_InitEvent()
FixationRecorder.OnFixationSend += FixationCore_OnFixationSend;
DynamicManager.OnDynamicObjectSend += DynamicManager_OnDynamicObjectSend;
SensorRecorder.OnSensorSend += SensorRecorder_OnSensorSend;
Cognitive3D.Components.Boundary.OnBoundarySend += Boundary_OnBoundarySend;
}



float EventTimeSinceSend = -1;
float GazeTimeSinceSend = -1;
float FixationTimeSinceSend = -1;
float DynamicTimeSinceSend = -1;
float SensorTimeSinceSend = -1;
float BoundaryTimeSinceSend = -1;

public Color noDataColor;
public Color normalColor;
Expand Down Expand Up @@ -115,6 +120,18 @@ private void Update()
}
#endregion

#region Boundary
if (BoundaryTimeSinceSend < 0)
{
BoundarySendText.color = noDataColor;
BoundarySendText.text = neverSentString;
}
else
{
UpdateText(BoundarySendText, ref BoundaryTimeSinceSend);
}
#endregion

timeSinceLastTick = 0;
}

Expand Down Expand Up @@ -171,13 +188,19 @@ private void CustomEvent_OnCustomEventSend(bool ignored)
EventTimeSinceSend = 0;
}

private void Boundary_OnBoundarySend()
{
BoundaryTimeSinceSend = 0;
}

private void OnDestroy()
{
CustomEvent.OnCustomEventSend -= CustomEvent_OnCustomEventSend;
GazeCore.OnGazeSend -= GazeCore_OnGazeSend;
FixationRecorder.OnFixationSend -= FixationCore_OnFixationSend;
DynamicManager.OnDynamicObjectSend -= DynamicManager_OnDynamicObjectSend;
SensorRecorder.OnSensorSend -= SensorRecorder_OnSensorSend;
Components.Boundary.OnBoundarySend -= Boundary_OnBoundarySend;
}

private void Core_EndSessionEvent()
Expand All @@ -187,6 +210,7 @@ private void Core_EndSessionEvent()
FixationRecorder.OnFixationSend -= FixationCore_OnFixationSend;
DynamicManager.OnDynamicObjectSend -= DynamicManager_OnDynamicObjectSend;
SensorRecorder.OnSensorSend -= SensorRecorder_OnSensorSend;
Components.Boundary.OnBoundarySend -= Boundary_OnBoundarySend;
}
}
}
2 changes: 1 addition & 1 deletion Runtime/ActiveSessionView/Scripts/SensorCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Start()
canvasHackObject = canvasHackField.GetValue(null);
}

private void SensorRecorder_OnNewSensorRecorded(string sensorName, float value)
private void SensorRecorder_OnNewSensorRecorded(string sensorName, float value, double time)
{
//reject sensors if there is an allow list and the sensor is not included
if (allowedSensorNames.Count > 0)
Expand Down
30 changes: 29 additions & 1 deletion Runtime/Components/Boundary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ namespace Cognitive3D.Components
[AddComponentMenu("Cognitive3D/Components/Boundary")]
public class Boundary : AnalyticsComponentBase
{
public delegate void onBoundaryRecorded(double time, Vector3 pos, Quaternion rot, Vector3[] points);
//used by active session view
public static event onBoundaryRecorded OnBoundaryRecorded;
internal static void InvokeBoundaryRecorded(double time, Vector3 pos, Quaternion rot, Vector3[] points)
{
if (OnBoundaryRecorded != null)
{
OnBoundaryRecorded.Invoke(time, pos, rot, points);
}
}

public delegate void onBoundarySend();
//used by active session view
public static event onBoundarySend OnBoundarySend;
internal static void InvokeBoundarySend()
{
if (OnBoundarySend != null)
{
OnBoundarySend.Invoke();
}
}

#if ((C3D_OCULUS || C3D_DEFAULT || C3D_VIVEWAVE || C3D_PICOXR) && !UNITY_EDITOR) || C3D_STEAMVR2
/// <summary>
/// Track whether the boundary has been initialized in this session
Expand Down Expand Up @@ -102,6 +124,8 @@ private IEnumerator InitializeBoundaryRecordWithDelay()
CoreInterface.RecordTrackingSpaceTransform(customTransform, Util.Timestamp(Time.frameCount));
lastRecordedTrackingSpacePosition = customTransform.pos;
previousTrackingSpaceRotation = customTransform.rot;

InvokeBoundaryRecorded(Util.Timestamp(Time.frameCount), customTransform.pos, customTransform.rot, currentBoundaryPoints);
}
}

Expand All @@ -123,6 +147,7 @@ private void Cognitive3D_Manager_OnTick()
CoreInterface.RecordTrackingSpaceTransform(customTransform, Util.Timestamp(Time.frameCount));
lastRecordedTrackingSpacePosition = customTransform.pos;
previousTrackingSpaceRotation = customTransform.rot;
InvokeBoundaryRecorded(Util.Timestamp(Time.frameCount), customTransform.pos, customTransform.rot, BoundaryUtil.GetCurrentBoundaryPoints());
}
}

Expand All @@ -134,6 +159,7 @@ private void Cognitive3D_Manager_OnTick()
{
previousBoundaryPoints = currentBoundaryPoints;
CoreInterface.RecordBoundaryShape(currentBoundaryPoints, Util.Timestamp(Time.frameCount));
InvokeBoundaryRecorded(Util.Timestamp(Time.frameCount), customTransform.pos, customTransform.rot, currentBoundaryPoints);
}
}
}
Expand All @@ -150,6 +176,8 @@ internal static void RecordRecenterBoundary()
Quaternion.Euler(trackingSpaceTransform.rot.x, GameplayReferences.HMD.rotation.y, trackingSpaceTransform.rot.z));
CoreInterface.RecordTrackingSpaceTransform(recenteredTransform, Util.Timestamp(Time.frameCount));
CoreInterface.RecordBoundaryShape(BoundaryUtil.GetCurrentBoundaryPoints(), Util.Timestamp(Time.frameCount));

InvokeBoundaryRecorded(Util.Timestamp(Time.frameCount), recenteredTransform.pos, recenteredTransform.rot, BoundaryUtil.GetCurrentBoundaryPoints());
}

private void Cognitive3D_Manager_OnPreSessionEnd()
Expand All @@ -161,7 +189,7 @@ private void Cognitive3D_Manager_OnPreSessionEnd()
}
#endif

#region Inspector Utils
#region Inspector Utils
public override bool GetWarning()
{
#if C3D_OCULUS || C3D_DEFAULT || C3D_VIVEWAVE || C3D_PICOXR || C3D_STEAMVR2
Expand Down
33 changes: 33 additions & 0 deletions Runtime/Internal/DynamicManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ public static class DynamicManager
//this can track up to 16 dynamic objects that appear in a session without a custom id. this helps session json reduce the number of entries in the manifest
internal static DynamicObjectId[] DynamicObjectIdArray = new DynamicObjectId[16];

public delegate void onDynamicRecorded(string name, string mesh, double time, Vector3 pos, Quaternion rot, Vector3 scale);
//used by active session view
public static event onDynamicRecorded OnDynamicRecorded;
internal static void InvokeDynamicRecorded(string name, string mesh, double time, Vector3 pos, Quaternion rot, Vector3 scale)
{
if (OnDynamicRecorded != null)
{
OnDynamicRecorded.Invoke(name, mesh, time, pos, rot, scale);
}
}

internal static void Initialize()
{
Cognitive3D_Manager.OnUpdate -= OnUpdate;
Expand All @@ -30,7 +41,10 @@ internal static void Initialize()
for(int i = 0; i< ActiveDynamicObjectsArray.Length;i++)
{
if (ActiveDynamicObjectsArray[i].active)
{
CoreInterface.WriteDynamicManifestEntry(ActiveDynamicObjectsArray[i]);
InvokeDynamicRecorded(ActiveDynamicObjectsArray[i].Id, ActiveDynamicObjectsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveDynamicObjectsArray[i].LastPosition, ActiveDynamicObjectsArray[i].LastRotation, ActiveDynamicObjectsArray[i].LastScale);
}
}
}

Expand Down Expand Up @@ -135,7 +149,10 @@ internal static void RegisterDynamicObject(DynamicData data)
ActiveDynamicObjectsArray[nextFreeIndex] = data;
}
if (Cognitive3D_Manager.IsInitialized)
{
CoreInterface.WriteDynamicManifestEntry(data);
InvokeDynamicRecorded(data.Id, data.MeshName, Util.Timestamp(Time.frameCount), data.LastPosition, data.LastRotation, data.LastScale);
}
}

//this doesn't directly remove a dynamic object - it sets 'remove' so it can be removed on the next tick
Expand Down Expand Up @@ -420,7 +437,10 @@ internal static void RegisterController(XRNode controller, bool isRight, InputUt
}

if (Cognitive3D_Manager.IsInitialized)
{
CoreInterface.WriteControllerManifestEntry(data);
InvokeDynamicRecorded(data.Id, data.MeshName, Util.Timestamp(Time.frameCount), data.LastPosition, data.LastRotation, data.LastScale);
}
}

internal static void RegisterController(DynamicData data)
Expand Down Expand Up @@ -455,7 +475,10 @@ internal static void RegisterController(DynamicData data)
ActiveDynamicObjectsArray[nextFreeIndex] = data;
}
if (Cognitive3D_Manager.IsInitialized)
{
CoreInterface.WriteControllerManifestEntry(data);
InvokeDynamicRecorded(data.Id, data.MeshName, Util.Timestamp(Time.frameCount), data.LastPosition, data.LastRotation, data.LastScale);
}
}

internal static void RegisterHand(XRNode hand, bool isRight, string registerId = "")
Expand Down Expand Up @@ -503,7 +526,10 @@ internal static void RegisterHand(XRNode hand, bool isRight, string registerId =
}

if (Cognitive3D_Manager.IsInitialized)
{
CoreInterface.WriteControllerManifestEntry(data);
InvokeDynamicRecorded(data.Id, data.MeshName, Util.Timestamp(Time.frameCount), data.LastPosition, data.LastRotation, data.LastScale);
}
}

internal static DynamicData GetInputDynamicData(InputUtil.InputType type, bool isRight)
Expand Down Expand Up @@ -673,6 +699,7 @@ internal static void RecordControllerEvent(string id, List<ButtonState> changedI
ActiveDynamicObjectsArray[i].Properties = null;
}
CoreInterface.WriteDynamicController(ActiveDynamicObjectsArray[i], props, writeScale, builder.ToString(),Util.Timestamp(Time.frameCount));
InvokeDynamicRecorded(ActiveInputsArray[i].Id, ActiveInputsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveInputsArray[i].LastPosition, ActiveInputsArray[i].LastRotation, ActiveInputsArray[i].LastScale);
}
}

Expand Down Expand Up @@ -768,6 +795,7 @@ internal static void RecordControllerEvent(bool isRight, List<ButtonState> chang
}

CoreInterface.WriteDynamicController(ActiveInputsArray[i], props, false, builder.ToString(),Util.Timestamp(Time.frameCount));
InvokeDynamicRecorded(ActiveInputsArray[i].Id, ActiveInputsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveInputsArray[i].LastPosition, ActiveInputsArray[i].LastRotation, ActiveInputsArray[i].LastScale);
}
}

Expand Down Expand Up @@ -996,6 +1024,7 @@ internal static void RecordDynamic(string id, bool forceWrite)
ActiveDynamicObjectsArray[i].Properties = null;
}
CoreInterface.WriteDynamic(ActiveDynamicObjectsArray[i], props, writeScale, Util.Timestamp(Time.frameCount));
InvokeDynamicRecorded(id, ActiveDynamicObjectsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveDynamicObjectsArray[i].LastPosition, ActiveDynamicObjectsArray[i].LastRotation, ActiveDynamicObjectsArray[i].LastScale);
}
}
}
Expand Down Expand Up @@ -1161,6 +1190,7 @@ private static void ProcessDynamicArray(ref DynamicData[] array, float deltaTime
}

CoreInterface.WriteDynamic(array[index], props, writeScale, Util.Timestamp(Time.frameCount));
InvokeDynamicRecorded(array[index].Id, array[index].MeshName, Util.Timestamp(Time.frameCount), array[index].LastPosition, array[index].LastRotation, array[index].LastScale);
}

if (array[index].remove)
Expand Down Expand Up @@ -1279,6 +1309,7 @@ private static void ProcessInputDynamicArray(ref DynamicData[] array, InputUtil.
}

CoreInterface.WriteDynamic(array[index], props, false, Util.Timestamp(Time.frameCount));
InvokeDynamicRecorded(array[index].Id, array[index].MeshName, Util.Timestamp(Time.frameCount), array[index].LastPosition, array[index].LastRotation, array[index].LastScale);
}

if (array[index].remove)
Expand Down Expand Up @@ -1351,11 +1382,13 @@ static void OnSceneLoaded(Scene scene, LoadSceneMode mode, bool didChangeSceneId
{
//DynamicObjectCore.WriteControllerManifestEntry(ActiveDynamicObjectsArray[i]);
CoreInterface.WriteControllerManifestEntry(ActiveDynamicObjectsArray[i]);
InvokeDynamicRecorded(ActiveDynamicObjectsArray[i].Id, ActiveDynamicObjectsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveDynamicObjectsArray[i].LastPosition, ActiveDynamicObjectsArray[i].LastRotation, ActiveDynamicObjectsArray[i].LastScale);
}
else
{
//DynamicObjectCore.WriteDynamicManifestEntry(ActiveDynamicObjectsArray[i]);
CoreInterface.WriteDynamicManifestEntry(ActiveDynamicObjectsArray[i]);
InvokeDynamicRecorded(ActiveDynamicObjectsArray[i].Id, ActiveDynamicObjectsArray[i].MeshName, Util.Timestamp(Time.frameCount), ActiveDynamicObjectsArray[i].LastPosition, ActiveDynamicObjectsArray[i].LastRotation, ActiveDynamicObjectsArray[i].LastScale);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Internal/EyeCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class EyeCapture
//this should be true if gazing at sky. within fixation angle, but position will just mess up the average
public bool SkipPositionForFixationAverage = false;
public Vector3 HmdPosition;
public long Time;
public long Time; //unixtime in milliseconds

public bool Discard; //empty or impossible values
public bool EyesClosed; //blinking or eyes closed
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Internal/SensorRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void InitializeSensor(string sensorName, float HzRate = 10, float
CoreInterface.InitializeSensor(sensorName, HzRate);

if (OnNewSensorRecorded != null)
OnNewSensorRecorded(sensorName, initialValue);
OnNewSensorRecorded(sensorName, initialValue, Util.Timestamp(Time.frameCount));
}

/// <summary>
Expand Down Expand Up @@ -200,12 +200,12 @@ public static void RecordDataPoint(string category, float value, double unixTime
CoreInterface.RecordSensor(category, value, unixTimestamp);

if (OnNewSensorRecorded != null)
OnNewSensorRecorded(category, value);
OnNewSensorRecorded(category, value, unixTimestamp);
}
}

//used by active session view
public delegate void onNewSensorRecorded(string sensorName, float sensorValue);
public delegate void onNewSensorRecorded(string sensorName, float sensorValue, double time);
public static event onNewSensorRecorded OnNewSensorRecorded;

//happens after the network has sent the request, before any response
Expand Down
1 change: 1 addition & 0 deletions Runtime/Internal/Serialization/CoreInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ static void WebPost(string requestType, string body, bool cache)
break;
case "boundary":
url = CognitiveStatics.PostBoundaryData(Cognitive3D_Manager.TrackingSceneId, Cognitive3D_Manager.TrackingSceneVersionNumber);
Cognitive3D.Components.Boundary.InvokeBoundarySend();
break;
default: Util.logDevelopment("Invalid Web Post type"); return;
}
Expand Down
Loading