clean project

This commit is contained in:
Helar Jaadla
2022-03-07 17:52:41 +02:00
parent a174b45bd2
commit cbeb10ec35
5100 changed files with 837159 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class ActiveStateDebugVisual : MonoBehaviour
{
[SerializeField, Interface(typeof(IActiveState))]
private MonoBehaviour _activeState;
private IActiveState ActiveState { get; set; }
[SerializeField]
private Renderer _target;
[SerializeField]
private Color _normalColor = Color.red;
[SerializeField]
private Color _activeColor = Color.green;
private Material _material;
private bool _lastActiveValue = false;
protected virtual void Awake()
{
ActiveState = _activeState as IActiveState;
Assert.IsNotNull(ActiveState);
Assert.IsNotNull(_target);
_material = _target.material;
SetMaterialColor(_lastActiveValue ? _activeColor : _normalColor);
}
private void OnDestroy()
{
Destroy(_material);
}
protected virtual void Update()
{
bool isActive = ActiveState.Active;
if (_lastActiveValue != isActive)
{
SetMaterialColor(isActive ? _activeColor : _normalColor);
_lastActiveValue = isActive;
}
}
private void SetMaterialColor(Color activeColor)
{
_material.color = activeColor;
_target.enabled = _material.color.a > 0.0f;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38d73b2d0c0ee504587e0237ec474ca4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,137 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class FingerFeatureSkeletalDebugVisual : MonoBehaviour
{
[SerializeField]
private LineRenderer _lineRenderer;
[SerializeField]
private Color _normalColor = Color.red;
[SerializeField]
private Color _activeColor = Color.green;
[SerializeField]
private float _lineWidth = 0.005f;
private IHand _hand;
private FingerFeatureStateProvider _featureState;
private bool _lastFeatureActiveValue = false;
private IReadOnlyList<HandJointId> _jointsCovered = null;
private HandFinger _finger;
private ShapeRecognizer.FingerFeatureConfig _fingerFeatureConfig;
private bool _initializedPositions;
private bool _initialized;
protected virtual void Awake()
{
Assert.IsNotNull(_lineRenderer);
UpdateFeatureActiveValueAndVisual(false);
}
private void UpdateFeatureActiveValueAndVisual(bool newValue)
{
var colorToUse = newValue ? _activeColor : _normalColor;
_lineRenderer.startColor = colorToUse;
_lineRenderer.endColor = colorToUse;
_lastFeatureActiveValue = newValue;
}
public void Initialize(
IHand hand,
HandFinger finger,
ShapeRecognizer.FingerFeatureConfig fingerFeatureConfig)
{
_hand = hand;
_initialized = true;
bool foundAspect = hand.GetHandAspect(out _featureState);
Assert.IsTrue(foundAspect);
var featureValueProvider = _featureState.GetValueProvider(finger);
_jointsCovered = featureValueProvider.GetJointsAffected(
finger,
fingerFeatureConfig.Feature);
_finger = finger;
_fingerFeatureConfig = fingerFeatureConfig;
_initializedPositions = false;
}
protected virtual void Update()
{
if (!_initialized || !_hand.IsTrackedDataValid)
{
ToggleLineRendererEnableState(false);
return;
}
ToggleLineRendererEnableState(true);
UpdateDebugSkeletonLineRendererJoints();
UpdateFeatureActiveValue();
}
private void ToggleLineRendererEnableState(bool enableState)
{
if (_lineRenderer.enabled == enableState)
{
return;
}
_lineRenderer.enabled = enableState;
}
private void UpdateDebugSkeletonLineRendererJoints()
{
if (!_initializedPositions)
{
_lineRenderer.positionCount = _jointsCovered.Count;
_initializedPositions = true;
}
if (Mathf.Abs(_lineRenderer.startWidth - _lineWidth) > Mathf.Epsilon)
{
_lineRenderer.startWidth = _lineWidth;
_lineRenderer.endWidth = _lineWidth;
}
int numJoints = _jointsCovered.Count;
for (int i = 0; i < numJoints; i++)
{
if (_hand.GetJointPose(_jointsCovered[i], out Pose jointPose))
{
_lineRenderer.SetPosition(i, jointPose.position);
}
}
}
private void UpdateFeatureActiveValue()
{
bool isActive = _featureState.IsStateActive(_finger, _fingerFeatureConfig.Feature,
_fingerFeatureConfig.Mode, _fingerFeatureConfig.State);
if (isActive != _lastFeatureActiveValue)
{
UpdateFeatureActiveValueAndVisual(isActive);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df12566059c64f34a8985d7383779198
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class HandShapeSkeletalDebugVisual : MonoBehaviour
{
[SerializeField]
private ShapeRecognizerActiveState _shapeRecognizerActiveState;
[SerializeField]
private GameObject _fingerFeatureDebugVisualPrefab;
protected virtual void Awake()
{
Assert.IsNotNull(_shapeRecognizerActiveState);
Assert.IsNotNull(_fingerFeatureDebugVisualPrefab);
}
protected virtual void Start()
{
var statesByFinger = AllFeatureStates()
.GroupBy(s => s.Item1)
.Select(group => new
{
HandFinger = group.Key,
FingerFeatures = group.SelectMany(item => item.Item2)
});
foreach (var g in statesByFinger)
{
foreach (var feature in g.FingerFeatures)
{
var boneDebugObject = Instantiate(_fingerFeatureDebugVisualPrefab);
var skeletalComp = boneDebugObject.GetComponent<FingerFeatureSkeletalDebugVisual>();
skeletalComp.Initialize(_shapeRecognizerActiveState.Hand, g.HandFinger, feature);
var debugVisTransform = boneDebugObject.transform;
debugVisTransform.parent = this.transform;
debugVisTransform.localScale = Vector3.one;
debugVisTransform.localRotation = Quaternion.identity;
debugVisTransform.localPosition = Vector3.zero;
}
}
}
private IEnumerable<ValueTuple<HandFinger, IReadOnlyList<ShapeRecognizer.FingerFeatureConfig>>> AllFeatureStates()
{
foreach (ShapeRecognizer shapeRecognizer in _shapeRecognizerActiveState.Shapes)
{
foreach (var handFingerConfigs in shapeRecognizer.GetFingerFeatureConfigs())
{
yield return handFingerConfigs;
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86fda5ce347f35d44a5c6faee65c6679
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,110 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using TMPro;
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class TransformFeatureDebugVisual : MonoBehaviour
{
[SerializeField]
private Renderer _target;
[SerializeField]
private Color _normalColor = Color.red;
[SerializeField]
private Color _activeColor = Color.green;
[SerializeField]
private TextMeshPro _targetText;
private TransformFeatureStateProvider _transformFeatureStateProvider;
private TransformRecognizerActiveState _transformRecognizerActiveState;
private Material _material;
private bool _lastActiveValue;
private TransformFeatureConfig _targetConfig;
private bool _initialized;
private Handedness _handedness;
protected virtual void Awake()
{
_material = _target.material;
Assert.IsNotNull(_material);
Assert.IsNotNull(_targetText);
_material.color = _lastActiveValue ? _activeColor : _normalColor;
}
private void OnDestroy()
{
Destroy(_material);
}
public void Initialize(
Handedness handedness,
TransformFeatureConfig targetConfig,
TransformFeatureStateProvider transformFeatureStateProvider,
TransformRecognizerActiveState transformActiveState)
{
_handedness = handedness;
_initialized = true;
_transformFeatureStateProvider = transformFeatureStateProvider;
_transformRecognizerActiveState = transformActiveState;
_targetConfig = targetConfig;
}
protected virtual void Update()
{
if (!_initialized)
{
return;
}
bool isActive = false;
TransformFeature feature = _targetConfig.Feature;
if (_transformFeatureStateProvider.GetCurrentState(
_transformRecognizerActiveState.TransformConfig,
feature,
out string currentState))
{
float? featureVal = _transformFeatureStateProvider.GetFeatureValue(
_transformRecognizerActiveState.TransformConfig, feature);
isActive = _transformFeatureStateProvider.IsStateActive(
_transformRecognizerActiveState.TransformConfig,
feature,
_targetConfig.Mode,
_targetConfig.State);
string featureValStr = featureVal.HasValue ? featureVal.Value.ToString("F2") : "--";
_targetText.text = $"{feature}\n" +
$"{currentState} ({featureValStr})";
}
else
{
_targetText.text = $"{feature}\n";
}
if (isActive != _lastActiveValue)
{
_material.color = isActive ? _activeColor : _normalColor;
_lastActiveValue = isActive;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9390f6f5772c6d942a736437d338b667
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class TransformFeatureVectorDebugParentVisual : MonoBehaviour
{
[SerializeField]
private TransformRecognizerActiveState _transformRecognizerActiveState;
[SerializeField]
private GameObject _vectorVisualPrefab;
public void GetTransformFeatureVectorAndWristPos(TransformFeature feature,
bool isHandVector, ref Vector3? featureVec, ref Vector3? wristPos)
{
_transformRecognizerActiveState.GetFeatureVectorAndWristPos(feature, isHandVector,
ref featureVec, ref wristPos);
}
protected virtual void Awake()
{
Assert.IsNotNull(_transformRecognizerActiveState);
Assert.IsNotNull(_vectorVisualPrefab);
}
protected virtual void Start()
{
var featureConfigs = _transformRecognizerActiveState.FeatureConfigs;
foreach (var featureConfig in featureConfigs)
{
var feature = featureConfig.Feature;
CreateVectorDebugView(feature, false);
CreateVectorDebugView(feature, true);
}
}
private void CreateVectorDebugView(TransformFeature feature, bool trackingHandVector)
{
var featureDebugVis = Instantiate(_vectorVisualPrefab, this.transform);
var debugVisComp = featureDebugVis.GetComponent<TransformFeatureVectorDebugVisual>();
debugVisComp.Initialize(feature, trackingHandVector, this, trackingHandVector ?
Color.blue : Color.black);
var debugVisTransform = debugVisComp.transform;
debugVisTransform.localRotation = Quaternion.identity;
debugVisTransform.localPosition = Vector3.zero;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8cd27ccbb9a942e47a1b2bfd53f957e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class TransformFeatureVectorDebugVisual : MonoBehaviour
{
public IHand Hand { get; private set; }
[SerializeField]
private LineRenderer _lineRenderer;
[SerializeField]
private float _lineWidth = 0.005f;
[SerializeField]
private float _lineScale = 0.1f;
private bool _isInitialized = false;
private TransformFeature _feature;
private TransformFeatureVectorDebugParentVisual _parent;
private bool _trackingHandVector = false;
protected virtual void Awake()
{
Assert.IsNotNull(_lineRenderer);
_lineRenderer.enabled = false;
}
public void Initialize(TransformFeature feature,
bool trackingHandVector,
TransformFeatureVectorDebugParentVisual parent,
Color lineColor)
{
_isInitialized = true;
_lineRenderer.enabled = true;
_lineRenderer.positionCount = 2;
_lineRenderer.startColor = lineColor;
_lineRenderer.endColor = lineColor;
_feature = feature;
_trackingHandVector = trackingHandVector;
_parent = parent;
}
protected virtual void Update()
{
if (!_isInitialized)
{
return;
}
Vector3? featureVec = null;
Vector3? wristPos = null;
_parent.GetTransformFeatureVectorAndWristPos(_feature,
_trackingHandVector, ref featureVec, ref wristPos);
if (featureVec == null || wristPos == null)
{
if (_lineRenderer.enabled)
{
_lineRenderer.enabled = false;
}
return;
}
if (!_lineRenderer.enabled)
{
_lineRenderer.enabled = true;
}
if (Mathf.Abs(_lineRenderer.startWidth - _lineWidth) > Mathf.Epsilon)
{
_lineRenderer.startWidth = _lineWidth;
_lineRenderer.endWidth = _lineWidth;
}
_lineRenderer.SetPosition(0, wristPos.Value);
_lineRenderer.SetPosition(1, wristPos.Value + _lineScale*featureVec.Value);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5b3b9e0179019c46a27bcc4ed7916ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
/************************************************************************************
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
https://developer.oculus.com/licenses/oculussdk/
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY KIND, either express or implied. See the License for the specific language governing
permissions and limitations under the License.
************************************************************************************/
using Oculus.Interaction.Input;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.Assertions;
namespace Oculus.Interaction.PoseDetection.Debug
{
public class TransformRecognizerDebugVisual : MonoBehaviour
{
[SerializeField]
private Hand _hand;
[SerializeField]
private TransformRecognizerActiveState[] _transformRecognizerActiveStates;
[SerializeField]
private Renderer _target;
[SerializeField]
private Color _normalColor = Color.red;
[SerializeField]
private Color _activeColor = Color.green;
[SerializeField]
private GameObject _transformFeatureDebugVisualPrefab;
[SerializeField]
private Transform _debugVisualParent;
[SerializeField]
private Vector3 _featureSpacingVec = new Vector3(1.0f, 0.0f, 0.0f);
[SerializeField]
private Vector3 _featureDebugLocalScale = new Vector3(0.3f, 0.3f, 0.3f);
[SerializeField]
private TextMeshPro _targetText;
private Material _material;
private bool _lastActiveValue = false;
protected virtual void Awake()
{
Assert.IsNotNull(_hand);
Assert.IsTrue(_transformRecognizerActiveStates != null &&
_transformRecognizerActiveStates.Length > 0);
Assert.IsNotNull(_target);
Assert.IsNotNull(_transformFeatureDebugVisualPrefab);
Assert.IsNotNull(_targetText);
_material = _target.material;
_material.color = _lastActiveValue ? _activeColor : _normalColor;
if (_debugVisualParent == null)
{
_debugVisualParent = transform;
}
}
protected virtual void Start()
{
Vector3 totalDisp = Vector3.zero;
string shapeNames = "";
foreach (var activeState in _transformRecognizerActiveStates)
{
bool foundAspect = activeState.Hand.GetHandAspect(out TransformFeatureStateProvider stateProvider);
Assert.IsTrue(foundAspect);
var featureConfigs = activeState.FeatureConfigs;
foreach (var featureConfig in featureConfigs)
{
var featureDebugVis = Instantiate(_transformFeatureDebugVisualPrefab, _debugVisualParent);
var debugVisComp = featureDebugVis.GetComponent<TransformFeatureDebugVisual>();
debugVisComp.Initialize(activeState.Hand.Handedness, featureConfig, stateProvider,
activeState);
var debugVisTransform = debugVisComp.transform;
debugVisTransform.localScale = _featureDebugLocalScale;
debugVisTransform.localRotation = Quaternion.identity;
debugVisTransform.localPosition = totalDisp;
totalDisp += _featureSpacingVec;
if (!String.IsNullOrEmpty(shapeNames)) { shapeNames += "\n "; }
shapeNames += $"{featureConfig.Mode} {featureConfig.State} ({activeState.Hand.Handedness})";
}
}
_targetText.text = $"{shapeNames}";
}
private void OnDestroy()
{
Destroy(_material);
}
private bool AllActive()
{
foreach (var activeState in _transformRecognizerActiveStates)
{
if (!activeState.Active)
{
return false;
}
}
return true;
}
protected virtual void Update()
{
bool isActive = AllActive();
if (_lastActiveValue != isActive)
{
_material.color = isActive ? _activeColor : _normalColor;
_lastActiveValue = isActive;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aca13d9f89c0c904a8d62bde280f5b52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: