Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into ashubin/calibratio…
Browse files Browse the repository at this point in the history
…n_check

# Conflicts:
#	Assets/MirageXR/Player/Scripts/Moodle/MoodleManager.cs
  • Loading branch information
cawke committed Oct 25, 2023
2 parents 7c3e3a7 + 285dccf commit b03cc6e
Show file tree
Hide file tree
Showing 15 changed files with 600 additions and 391 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit.Utilities;
using MirageXR;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Microsoft.MixedReality.Toolkit.Utilities;
using MirageXR;
using UnityEngine;
using Microsoft.MixedReality.Toolkit.Input;

public class GhostRecorder
{
public bool IsRecording => _isRecording;
public GhostDataFrame LastFrame => _lastFrame;

private IMixedRealityHandJointService handJointService;

private readonly List<GhostDataFrame> _ghostFrames = new List<GhostDataFrame>();

private GhostDataFrame _lastFrame;
Expand Down Expand Up @@ -90,6 +93,8 @@ public void Start(Transform anchor, Transform camera, float? cooldown = null)
_ghostFrames.Clear();
_isRecording = true;

handJointService = CoreServices.GetInputSystemDataProvider<IMixedRealityHandJointService>();

StartAsync();
}

Expand Down Expand Up @@ -137,18 +142,60 @@ private void RecordFrame()
lowerSpine = CreateLocalPose(_anchor, GetLowerSpinPosition(_cameraTransform), cameraRotation),
};

var zeroPose = new Pose{position = Vector3.zero,rotation = Quaternion.identity};

if (InputRayUtils.TryGetHandRay(Handedness.Right, out var rightHandRay))
{
var rotation = Quaternion.LookRotation(rightHandRay.direction, Vector3.up);
_lastFrame.rightHand = CreateLocalPose(_anchor, rightHandRay.origin, rotation);

if (handJointService != null)
{
_lastFrame.rightThumbTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.ThumbTip, Handedness.Right));
_lastFrame.rightIndexTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.IndexTip, Handedness.Right));
_lastFrame.rightMiddleTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.MiddleTip, Handedness.Right));
_lastFrame.rightRingTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.RingTip, Handedness.Right));
_lastFrame.rightPinkyTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.PinkyTip, Handedness.Right));
}
else
{
_lastFrame.rightThumbTip = zeroPose;
_lastFrame.rightIndexTip = zeroPose;
_lastFrame.rightMiddleTip = zeroPose;
_lastFrame.rightRingTip = zeroPose;
_lastFrame.rightPinkyTip = zeroPose;
}
}

if (InputRayUtils.TryGetHandRay(Handedness.Left, out var leftHandRay))
{
var rotation = Quaternion.LookRotation(leftHandRay.direction, Vector3.up);
_lastFrame.leftHand = CreateLocalPose(_anchor, leftHandRay.origin, rotation);

if (handJointService != null)
{
_lastFrame.leftThumbTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.ThumbTip, Handedness.Left));
_lastFrame.leftIndexTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.IndexTip, Handedness.Left));
_lastFrame.leftMiddleTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.MiddleTip, Handedness.Left));
_lastFrame.leftRingTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.RingTip, Handedness.Left));
_lastFrame.leftPinkyTip = CreateLocalPose(_anchor, handJointService.RequestJointTransform(TrackedHandJoint.PinkyTip, Handedness.Left));

Debug.Log("Left index " + _lastFrame.leftIndexTip.position);
Debug.Log("Left thumb " + _lastFrame.leftThumbTip.position);
Debug.Log("Left Pinky " + _lastFrame.leftPinkyTip.position);
}
else
{
_lastFrame.leftThumbTip = zeroPose;
_lastFrame.leftIndexTip = zeroPose;
_lastFrame.leftMiddleTip = zeroPose;
_lastFrame.leftRingTip = zeroPose;
_lastFrame.leftPinkyTip = zeroPose;
}
}



_ghostFrames.Add(_lastFrame);
}

Expand All @@ -161,6 +208,15 @@ private static Pose CreateLocalPose(Transform anchor, Vector3 position, Quaterni
};
}

private static Pose CreateLocalPose(Transform anchor, Transform transform)
{
return new Pose
{
position = anchor.InverseTransformPoint(transform.position),
rotation = Quaternion.Inverse(anchor.parent.localRotation) * transform.rotation,
};
}

private static Vector3 GetHeadPosition(Transform camera)
{
return camera.position;
Expand All @@ -185,4 +241,5 @@ private static Vector3 GetLowerSpinPosition(Transform camera)
{
return camera.position + (camera.up * -0.45f);
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Microsoft.MixedReality.Toolkit.UI;
using Microsoft.MixedReality.Toolkit.UI.BoundsControl;
using System;
using System.Collections;
using System.IO;
using Microsoft.MixedReality.Toolkit.UI;
using Microsoft.MixedReality.Toolkit.UI.BoundsControl;
using UnityEngine;
using UnityEngine.UI;

Expand Down Expand Up @@ -189,6 +189,13 @@ private IEnumerator LoadMyModel(string MyModelID)
while (newModel == null)
{
newModel = GameObject.Find(MyModelID);

yield return null;
}

//wait for model component to be added
while (!newModel.GetComponentInChildren<Model>())
{
yield return null;
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/MirageXR/Common/Scripts/DataModel/ContentType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ public static string GetPredicate(this ContentType type)
public static ContentType ParsePredicate(string predicate)
{
var predicateLowCase = predicate.ToLower();
if (predicateLowCase.StartsWith(PREDICATE_IMAGEMARKER))
return ContentType.IMAGEMARKER;
if (predicateLowCase.StartsWith(PREDICATE_IMAGE))
return ContentType.IMAGE;
if (predicateLowCase.StartsWith(PREDICATE_VIDEO))
Expand All @@ -205,8 +207,6 @@ public static ContentType ParsePredicate(string predicate)
return ContentType.CHARACTER;
if (predicateLowCase.StartsWith(PREDICATE_PICKANDPLACE) || predicateLowCase.StartsWith(PREDICATE_PICKANDPLACE_V2))
return ContentType.PICKANDPLACE;
if (predicateLowCase.StartsWith(PREDICATE_IMAGEMARKER))
return ContentType.IMAGEMARKER;
if (predicateLowCase.StartsWith(PREDICATE_PLUGIN))
return ContentType.PLUGIN;
if (predicateLowCase.StartsWith(PREDICATE_DRAWING))
Expand Down
13 changes: 13 additions & 0 deletions Assets/MirageXR/Common/Scripts/DataModel/GhostDataFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@ public struct GhostDataFrame
public Pose rightHand;
public Pose upperSpine;
public Pose lowerSpine;

public Pose leftThumbTip;
public Pose leftIndexTip;
public Pose leftMiddleTip;
public Pose leftRingTip;
public Pose leftPinkyTip;

public Pose rightThumbTip;
public Pose rightIndexTip;
public Pose rightMiddleTip;
public Pose rightRingTip;
public Pose rightPinkyTip;

}
}
7 changes: 6 additions & 1 deletion Assets/MirageXR/Player/Prefabs/Glyphs/Allow.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: -0, y: 0.13006982, z: 0.047869273}
m_LocalScale: {x: 8.694114, y: 1.1370173, z: 8.694114}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4344669209980684}
m_RootOrder: 1
Expand All @@ -51,6 +52,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -110,6 +112,7 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4919262433461562}
- {fileID: 4509004889423960}
Expand All @@ -127,7 +130,7 @@ SphereCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.1
m_Radius: 0.088
m_Center: {x: 0, y: 0.13, z: 0.05}
--- !u!114 &4489515686483770652
MonoBehaviour:
Expand Down Expand Up @@ -171,6 +174,7 @@ Transform:
m_LocalRotation: {x: 6.123234e-17, y: 1, z: -6.123234e-17, w: -6.123234e-17}
m_LocalPosition: {x: 0.0018114226, y: 0.13064528, z: 0.036404494}
m_LocalScale: {x: 1.0969888, y: 1.0969888, z: 1.0969888}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4344669209980684}
m_RootOrder: 0
Expand All @@ -194,6 +198,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down
13 changes: 11 additions & 2 deletions Assets/MirageXR/Player/Prefabs/Glyphs/Highlight.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Transform:
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 1.0735172, y: 0.36896116, z: 1.0735172}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4445959038434004}
m_RootOrder: 0
Expand All @@ -51,6 +52,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -109,6 +111,7 @@ Transform:
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 0.102197826, y: 0.102197826, z: 0.102197826}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4445959038434004}
m_RootOrder: 2
Expand All @@ -132,6 +135,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -190,6 +194,7 @@ Transform:
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 0.1419927, y: 0.011449032, z: 0.1419927}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4445959038434004}
m_RootOrder: 1
Expand All @@ -213,6 +218,7 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
Expand Down Expand Up @@ -269,6 +275,7 @@ Transform:
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalScale: {x: 6, y: 6, z: 6}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4434641981235558}
- {fileID: 4931138640069592}
Expand Down Expand Up @@ -305,14 +312,15 @@ Transform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 6.734729, y: -27.978905, z: 65.44355}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4445959038434004}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!95 &95786942195654902
Animator:
serializedVersion: 3
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
Expand All @@ -325,6 +333,7 @@ Animator:
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
Expand All @@ -340,7 +349,7 @@ SphereCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.11
m_Radius: 0.102
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1213084481959375109
MonoBehaviour:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using i5.Toolkit.Core.VerboseLogging;
using System.Collections;
using System.Collections;
using UnityEngine;

namespace MirageXR
Expand Down Expand Up @@ -192,20 +191,19 @@ private static IEnumerator ActivateTrigger(AudioSource audioSource, Trigger trig
var triggerDuration = trigger.duration;
yield return new WaitForSeconds(triggerDuration);

if (!activityManager.IsLastAction(activityManager.ActiveAction))
{
if (activityManager.ActiveAction != null)
{
activityManager.ActiveAction.isCompleted = true;
}

if (int.TryParse(trigger.value, out var stepNumber))
{
activityManager.ActivateActionByIndex(stepNumber - 1);
}
if (activityManager.ActiveAction != null)
{
activityManager.ActiveAction.isCompleted = true;
}

TaskStationDetailMenu.Instance.SelectedButton = null;
if (int.TryParse(trigger.value, out var stepNumber))
{
activityManager.ActivateActionByIndex(stepNumber - 1);
}

TaskStationDetailMenu.Instance.SelectedButton = null;

}
}

Expand Down
Loading

0 comments on commit b03cc6e

Please sign in to comment.