Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.6 #22

Merged
merged 3 commits into from
Apr 28, 2021
Merged

V0.6 #22

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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<GameObject> CreateWidgetsByPrefab(EnrichedGroupItemDTO item)

foreach (string itemTag in item.tags)
{
GameObject itemTagWidgetPrefab = LoadPrefabFromFile(itemtype + itemTag); //Number:Dimension -> Number
GameObject itemTagWidgetPrefab = LoadPrefabFromFile("Widgets/Tags/" + itemTag); //Number:Dimension -> Number

if (itemTagWidgetPrefab != null)
{
Expand Down Expand Up @@ -234,7 +234,7 @@ private void SetParentTransforms()

public void SetServerIPAdress()
{
string adr = GameObject.Find("NativeKeyboardOutputIPAdress").GetComponent<TMPro.TextMeshPro>().text;
string adr = GameObject.Find("ServerIPAdress").GetComponent<TMPro.TextMeshPro>().text;
//string adr = GameObject.Find("KeyboardOutputIPAdress").GetComponent<TMP_InputField>().text;
print(adr);
if (System.Net.IPAddress.TryParse(adr, out var _))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,13 @@ MonoBehaviour:
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName:
m_MethodName:
- m_Target: {fileID: 84920916}
m_TargetAssemblyTypeName: SemanticModelController, Assembly-CSharp
m_MethodName: SetServerIPAdress
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
Expand Down Expand Up @@ -3047,6 +3047,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
debugMessage: {fileID: 1944241604}
mixedRealityKeyboardPreview: {fileID: 260466193056062083}
disableUIInteractionWhenTyping: 0
--- !u!1 &2067261402
GameObject:
m_ObjectHideFlags: 0
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioWidget : ItemWidget
{

public AudioSource _audioSource;

public override void Start()
{
base.Start();
InitWidget();
}

private void InitWidget()
{
if (_audioSource == null) _audioSource = GetComponent<AudioSource>();
itemController.updateItem?.Invoke();
}

public void PauseAudioSource()
{
if (IsAudioSourcePlaying()) _audioSource.Pause();
}

public void PlayAudioSource()
{
if (!IsAudioSourcePlaying()) _audioSource.Play();
}

public bool IsAudioSourcePlaying()
{
return _audioSource.isPlaying;
}

/// <summary>
/// Play/Pause Audio
/// </summary>
public void ToggleAudioSource()
{
if (IsAudioSourcePlaying()) PauseAudioSource();
else PlayAudioSource();
}

public void MuteAudioSource()
{
_audioSource.mute = true;
}

public void UnMuteAudioSource()
{
_audioSource.mute = false;
}

public void DecreaseVolumeAudioSource(float value = 0.1f)
{
_audioSource.volume -= value;
}

public void IncreaseVolumeAudioSource(float value = 0.1f)
{
_audioSource.volume += value;
}

/// <summary>
/// Change the clip to a new one
/// </summary>
/// <param name="newAudioClip"></param>
public void ChangeAudioSource(AudioClip newAudioClip)
{
_audioSource.clip = newAudioClip;
}

public override void OnUpdate()
{
//throw new System.NotImplementedException();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Microsoft.MixedReality.Toolkit.Input;
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;
/// <summary>
/// Unique Gesture item of Thumbs up. Its value - the angle between the thumb and Y-axis.
/// </summary>
public class GestureThumbsUpRotatedForDimmerWidget : GestureWidget
{
public override void Start()
{
base.Start();
}

void Update()
{
OnSetItem();
}

public override bool GestureCondition()
{
return !HandPoseUtils.IsThumbGrabbing(_handedness) && HandPoseUtils.IsMiddleGrabbing(_handedness) && HandPoseUtils.IsIndexGrabbing(_handedness);
}

public override void GestureEventTrigger()
{
if (TryGetGestureValue(out float value))
{
if (value > 40.0f)
{
_trigger.SensorTrigger();
}
else
{
_trigger.SensorUntrigger();
}
}
else
{
_trigger.SensorUntrigger();
}
}

public bool TryGetNormalizedValue(out uint normalizedValue)
{
if (TryGetGestureValue(out float value))
{
normalizedValue = (uint)value * 10 / 9;
return ((value > 2f) && (value < 100f)) ? true : false;
}
normalizedValue = 0;
return false;
}

public override bool TryGetGestureValue(out float value)
{
value = 0f;
if (!GestureCondition()) return false;

MixedRealityPose palmPose = MixedRealityPose.ZeroIdentity;
if (HandJointUtils.TryGetJointPose(TrackedHandJoint.Palm, _handedness, out MixedRealityPose palmpose))
{
palmPose = palmpose;
}
else
{
return false;
}
value = Vector3.Angle(palmPose.Up, this.transform.up);
if (_handedness == Handedness.Left) value = value * -1f;
return true;
}

public override void OnUpdate()
{
//throw new System.NotImplementedException();
}

public void OnSetItem()
{
if (TryGetNormalizedValue(out uint value))
{
itemController.SetItemStateAsDimmer((int)value);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.MixedReality.Toolkit.Utilities;
using UnityEngine;

#if OCULUSINTEGRATION_PRESENT
#endif
/// <summary>
/// One hand gesture basic class
/// </summary>
public abstract class GestureWidget : ItemWidget
{
public Handedness _handedness;

[SerializeField] public bool isTrigger;
[SerializeField] public SensorWidget _trigger;

public GestureWidget(Handedness handedness = Handedness.Right)
{
_handedness = handedness;
}

public abstract bool GestureCondition();

public abstract bool TryGetGestureValue(out float value);

public abstract void GestureEventTrigger();

public override void Start()
{
base.Start();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using Microsoft.MixedReality.Toolkit.UI;
using UnityEngine;

public abstract class ItemWidget : MonoBehaviour
{
Expand All @@ -13,13 +14,16 @@ public abstract class ItemWidget : MonoBehaviour

public virtual void Start()
{
// If there is bo itemController attached, it means that this widget was created outside the SemanticModelController
// In this case synchronizing the data requires ItemDTo (including item.state), which need to be created additionaly
if (itemController == null)
{
itemController = new ItemController(item, EvtType.None);
}
}

public void SetItemController(ItemController setItemComtroller)
{
//itemController = SemanticModel.getInstance().items[item].itemController;
//itemController.ItemId = item;

itemController = setItemComtroller;
itemController.updateItem += OnUpdate;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading