clean project
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
/************************************************************************************
|
||||
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;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Oculus.Interaction
|
||||
{
|
||||
public class HandJoint : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHand))]
|
||||
private MonoBehaviour _hand;
|
||||
public IHand Hand { get; private set; }
|
||||
|
||||
[FormerlySerializedAs("_jointId")]
|
||||
[SerializeField]
|
||||
private HandJointId _handJointId;
|
||||
|
||||
[FormerlySerializedAs("_offset")]
|
||||
[SerializeField]
|
||||
private Vector3 _localPositionOffset;
|
||||
|
||||
[SerializeField]
|
||||
private Quaternion _rotationOffset = Quaternion.identity;
|
||||
|
||||
#region Properties
|
||||
|
||||
public HandJointId HandJointId
|
||||
{
|
||||
get
|
||||
{
|
||||
return _handJointId;
|
||||
}
|
||||
set
|
||||
{
|
||||
_handJointId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 LocalPositionOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _localPositionOffset;
|
||||
}
|
||||
set
|
||||
{
|
||||
_localPositionOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion RotationOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rotationOffset;
|
||||
}
|
||||
set
|
||||
{
|
||||
_rotationOffset = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected bool _started = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hand = _hand as IHand;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.BeginStart(ref _started);
|
||||
Assert.IsNotNull(Hand);
|
||||
this.EndStart(ref _started);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated += HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated -= HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleHandUpdated()
|
||||
{
|
||||
if (!Hand.GetJointPose(_handJointId, out Pose pose)) return;
|
||||
|
||||
Vector3 positionOffsetWithHandedness =
|
||||
(Hand.Handedness == Handedness.Left ? -1f : 1f) * _localPositionOffset;
|
||||
pose.position += _rotationOffset * pose.rotation *
|
||||
positionOffsetWithHandedness * Hand.Scale;
|
||||
transform.SetPose(pose);
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
public void InjectAllHandJoint(IHand hand)
|
||||
{
|
||||
InjectHand(hand);
|
||||
}
|
||||
|
||||
public void InjectHand(IHand hand)
|
||||
{
|
||||
_hand = hand as MonoBehaviour;
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
#endregion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abee63302fdc2bb4f80efe129df0a723
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,92 @@
|
||||
/************************************************************************************
|
||||
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;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Oculus.Interaction
|
||||
{
|
||||
public class HandPointerPose : MonoBehaviour, IActiveState
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHand))]
|
||||
private MonoBehaviour _hand;
|
||||
public IHand Hand { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 _offset;
|
||||
|
||||
public bool Active => Hand.IsPointerPoseValid;
|
||||
|
||||
protected bool _started = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hand = _hand as IHand;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.BeginStart(ref _started);
|
||||
Assert.IsNotNull(Hand);
|
||||
this.EndStart(ref _started);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated += HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated -= HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleHandUpdated()
|
||||
{
|
||||
if (Hand.GetPointerPose(out Pose pointerPose))
|
||||
{
|
||||
pointerPose.position += pointerPose.rotation * _offset;
|
||||
transform.SetPose(pointerPose);
|
||||
}
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
public void InjectAllHandPointerPose(IHand hand,
|
||||
Vector3 offset)
|
||||
{
|
||||
InjectHand(hand);
|
||||
InjectOffset(offset);
|
||||
}
|
||||
|
||||
public void InjectHand(IHand hand)
|
||||
{
|
||||
_hand = hand as MonoBehaviour;
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
public void InjectOffset(Vector3 offset)
|
||||
{
|
||||
_offset = offset;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 417817ee9b785e341b31ce731f028317
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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 Oculus.Interaction.Input;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Oculus.Interaction
|
||||
{
|
||||
public class HandTransformScaler : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHand))]
|
||||
private MonoBehaviour _hand;
|
||||
public IHand Hand { get; private set; }
|
||||
|
||||
protected bool _started = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hand = _hand as IHand;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.BeginStart(ref _started);
|
||||
Assert.IsNotNull(Hand);
|
||||
this.EndStart(ref _started);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated += HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated -= HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleHandUpdated()
|
||||
{
|
||||
transform.localScale = Vector3.one * Hand.Scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a52cc62b98662b4e9ac356027b2b070
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,128 @@
|
||||
/************************************************************************************
|
||||
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;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Oculus.Interaction
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a position and rotation offset from the wrist of the given hand
|
||||
/// </summary>
|
||||
public class HandWristOffset : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHand))]
|
||||
private MonoBehaviour _hand;
|
||||
public IHand Hand { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 _offset;
|
||||
|
||||
[SerializeField]
|
||||
private Quaternion _rotation = Quaternion.identity;
|
||||
|
||||
private Pose _cachedPose = Pose.identity;
|
||||
|
||||
private static readonly Quaternion LEFT_MIRROR_ROTATION = Quaternion.Euler(180f, 0f, 0f);
|
||||
|
||||
protected bool _started = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hand = _hand as IHand;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.BeginStart(ref _started);
|
||||
Assert.IsNotNull(Hand);
|
||||
this.EndStart(ref _started);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated += HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated -= HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleHandUpdated()
|
||||
{
|
||||
if (Hand.GetRootPose(out Pose rootPose))
|
||||
{
|
||||
GetOffset(ref _cachedPose);
|
||||
_cachedPose.Postmultiply(rootPose);
|
||||
transform.SetPose(_cachedPose);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetOffset(ref Pose pose)
|
||||
{
|
||||
if (!_started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Hand.Handedness == Handedness.Left)
|
||||
{
|
||||
pose.position = -_offset * Hand.Scale;
|
||||
pose.rotation = _rotation * LEFT_MIRROR_ROTATION;
|
||||
}
|
||||
else
|
||||
{
|
||||
pose.position = _offset * Hand.Scale;
|
||||
pose.rotation = _rotation;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetWorldPose(ref Pose pose)
|
||||
{
|
||||
pose.position = this.transform.position;
|
||||
pose.rotation = this.transform.rotation;
|
||||
}
|
||||
|
||||
#region Inject
|
||||
public void InjectHand(IHand hand)
|
||||
{
|
||||
_hand = hand as MonoBehaviour;
|
||||
Hand = hand;
|
||||
}
|
||||
public void InjectOffset(Vector3 offset)
|
||||
{
|
||||
_offset = offset;
|
||||
}
|
||||
public void InjectRotation(Quaternion rotation)
|
||||
{
|
||||
_rotation = rotation;
|
||||
}
|
||||
|
||||
public void InjectAllHandWristOffset(IHand hand,
|
||||
Vector3 offset, Quaternion rotation)
|
||||
{
|
||||
InjectHand(hand);
|
||||
InjectOffset(offset);
|
||||
InjectRotation(rotation);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d61ea23b9fd13af40afe326bb23ac1cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,94 @@
|
||||
/************************************************************************************
|
||||
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 UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Oculus.Interaction
|
||||
{
|
||||
public class IndexPinchSelector : MonoBehaviour, ISelector
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHand))]
|
||||
private MonoBehaviour _hand;
|
||||
public IHand Hand { get; private set; }
|
||||
|
||||
private bool _isIndexFingerPinching;
|
||||
|
||||
public event Action WhenSelected = delegate { };
|
||||
public event Action WhenUnselected = delegate { };
|
||||
|
||||
protected bool _started = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hand = _hand as IHand;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.BeginStart(ref _started);
|
||||
Assert.IsNotNull(Hand);
|
||||
this.EndStart(ref _started);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated += HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
Hand.HandUpdated -= HandleHandUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleHandUpdated()
|
||||
{
|
||||
var prevPinching = _isIndexFingerPinching;
|
||||
_isIndexFingerPinching = Hand.GetIndexFingerIsPinching();
|
||||
if (prevPinching != _isIndexFingerPinching)
|
||||
{
|
||||
if (_isIndexFingerPinching)
|
||||
{
|
||||
WhenSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
WhenUnselected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
public void InjectAllIndexPinchSelector(IHand hand)
|
||||
{
|
||||
InjectHand(hand);
|
||||
}
|
||||
|
||||
public void InjectHand(IHand hand)
|
||||
{
|
||||
_hand = hand as MonoBehaviour;
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b6b944de90aa9047929c54d143ff2da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user