Initialer Upload neues Unity-Projekt

This commit is contained in:
Daniel Ocks
2025-07-21 09:11:14 +02:00
commit eeca72985b
14558 changed files with 1508140 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f2a5702f81abeab4d8948f0f06424efc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus 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 Oculus.Interaction.Input;
namespace Oculus.Interaction.Body.Input
{
using IOVRSkeletonDataProvider = OVRSkeleton.IOVRSkeletonDataProvider;
public class FromOVRBodyDataSource : DataSource<BodyDataAsset>
{
[Header("OVR Data Source")]
[SerializeField, Interface(typeof(IOVRSkeletonDataProvider))]
private UnityEngine.Object _dataProvider;
private IOVRSkeletonDataProvider DataProvider;
[SerializeField, Interface(typeof(IOVRCameraRigRef))]
private UnityEngine.Object _cameraRigRef;
private IOVRCameraRigRef CameraRigRef;
[SerializeField]
private bool _processLateUpdates = false;
protected override BodyDataAsset DataAsset => _bodyDataAsset;
private readonly BodyDataAsset _bodyDataAsset = new BodyDataAsset();
private readonly OVRSkeletonMapping _mapping = new OVRSkeletonMapping();
protected void Awake()
{
CameraRigRef = _cameraRigRef as IOVRCameraRigRef;
DataProvider = _dataProvider as IOVRSkeletonDataProvider;
}
protected override void Start()
{
base.Start();
this.AssertField(DataProvider, nameof(DataProvider));
this.AssertField(CameraRigRef, nameof(CameraRigRef));
_bodyDataAsset.SkeletonMapping = _mapping;
}
protected override void OnEnable()
{
base.OnEnable();
if (_started)
{
CameraRigRef.WhenInputDataDirtied += HandleInputDataDirtied;
}
}
protected override void OnDisable()
{
if (_started)
{
CameraRigRef.WhenInputDataDirtied -= HandleInputDataDirtied;
}
base.OnDisable();
}
private void HandleInputDataDirtied(bool isLateUpdate)
{
if (isLateUpdate && !_processLateUpdates)
{
return;
}
MarkInputDataRequiresUpdate();
}
protected override void UpdateData()
{
var data = DataProvider.GetSkeletonPoseData();
if (!data.IsDataValid)
{
return;
}
_bodyDataAsset.SkeletonMapping = _mapping;
_bodyDataAsset.IsDataHighConfidence = data.IsDataHighConfidence;
_bodyDataAsset.IsDataValid = data.IsDataValid;
_bodyDataAsset.SkeletonChangedCount = data.SkeletonChangedCount;
_bodyDataAsset.RootScale = data.RootScale;
_bodyDataAsset.Root = new Pose()
{
position = data.RootPose.Position.FromFlippedZVector3f(),
rotation = data.RootPose.Orientation.FromFlippedZQuatf()
};
foreach (var jointId in _mapping.Joints)
{
Pose pose = default(Pose);
if (_mapping.TryGetSourceJointId(jointId, out OVRPlugin.BoneId boneId))
{
int index = (int)boneId;
pose = new Pose()
{
rotation = float.IsNaN(data.BoneRotations[index].w)
? default(Quaternion)
: data.BoneRotations[index].FromFlippedZQuatf(),
position = data.BoneTranslations[index].FromFlippedZVector3f()
};
}
_bodyDataAsset.JointPoses[(int)jointId] = pose;
}
}
}
}

View File

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

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus 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 Oculus.Interaction.Body.Input;
using IOVRSkeletonDataProvider = OVRSkeleton.IOVRSkeletonDataProvider;
using OVRBoneId = OVRPlugin.BoneId;
namespace Oculus.Interaction.Body.PoseDetection
{
public class OVRBodyPoseSkeletonProvider : MonoBehaviour, IOVRSkeletonDataProvider
{
private const int OVR_NUM_JOINTS =
OVRBoneId.Body_End - OVRBoneId.Body_Start;
[SerializeField, Interface(typeof(IBodyPose))]
private UnityEngine.Object _bodyPose;
private IBodyPose BodyPose;
private OVRPlugin.Quatf[] _boneRotations = new OVRPlugin.Quatf[OVR_NUM_JOINTS];
private OVRPlugin.Vector3f[] _boneTranslations = new OVRPlugin.Vector3f[OVR_NUM_JOINTS];
private readonly OVRSkeletonMapping _mapping = new OVRSkeletonMapping();
protected virtual void Awake()
{
BodyPose = _bodyPose as IBodyPose;
}
protected virtual void Start()
{
this.AssertField(BodyPose, nameof(BodyPose));
}
OVRSkeleton.SkeletonPoseData OVRSkeleton.IOVRSkeletonDataProvider.GetSkeletonPoseData()
{
T[] EnsureLength<T>(T[] array, int length) => array?.Length == length ? array : new T[length];
// Make sure arrays have been allocated
_boneRotations = EnsureLength(_boneRotations, OVR_NUM_JOINTS);
_boneTranslations = EnsureLength(_boneTranslations, OVR_NUM_JOINTS);
// Copy joint poses into bone arrays
for (int i = 0; i < OVR_NUM_JOINTS; ++i)
{
OVRBoneId boneId = (OVRBoneId)i;
if (_mapping.TryGetBodyJointId(boneId, out BodyJointId jointId) &&
BodyPose.GetJointPoseFromRoot(jointId, out Pose pose))
{
_boneRotations[i] = pose.rotation.ToFlippedZQuatf();
_boneTranslations[i] = pose.position.ToFlippedZVector3f();
}
}
OVRPlugin.Posef rootPose;
if (BodyPose.GetJointPoseFromRoot(BodyJointId.Body_Root, out Pose root))
{
rootPose = new OVRPlugin.Posef()
{
Orientation = root.rotation.ToFlippedXQuatf(),
Position = root.position.ToFlippedZVector3f()
};
}
else
{
rootPose = default;
}
return new OVRSkeleton.SkeletonPoseData
{
IsDataValid = true,
IsDataHighConfidence = true,
RootPose = rootPose,
RootScale = 1.0f,
BoneRotations = _boneRotations,
BoneTranslations = _boneTranslations,
};
}
public OVRSkeleton.SkeletonType GetSkeletonType()
{
return OVRSkeleton.SkeletonType.Body;
}
}
}

View File

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

View File

@ -0,0 +1,128 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus 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 System.Collections.Generic;
/// <summary>
/// Primitive type serialization
/// </summary>
namespace Oculus.Interaction.Body.Input
{
using OVRBoneId = OVRPlugin.BoneId;
public class OVRSkeletonMapping : BodySkeletonMapping<OVRBoneId>, ISkeletonMapping
{
protected override IReadOnlyDictionary<BodyJointId, JointInfo> GetJointMapping()
{
return _jointMapping;
}
protected override OVRBoneId GetRoot()
{
return OVRBoneId.Body_Root;
}
/// <summary>
/// Mapping of <see cref="BodyJointId"/> to <see cref="OVRBoneId"/> and parent joint
/// </summary>
private readonly Dictionary<BodyJointId, JointInfo> _jointMapping =
new Dictionary<BodyJointId, JointInfo>
{
[BodyJointId.Body_Root] = new JointInfo(OVRBoneId.Body_Root, OVRBoneId.Body_Root),
[BodyJointId.Body_Hips] = new JointInfo(OVRBoneId.Body_Hips, OVRBoneId.Body_Root),
[BodyJointId.Body_SpineLower] = new JointInfo(OVRBoneId.Body_SpineLower, OVRBoneId.Body_Hips),
[BodyJointId.Body_SpineMiddle] = new JointInfo(OVRBoneId.Body_SpineMiddle, OVRBoneId.Body_SpineLower),
[BodyJointId.Body_SpineUpper] = new JointInfo(OVRBoneId.Body_SpineUpper, OVRBoneId.Body_SpineMiddle),
[BodyJointId.Body_Chest] = new JointInfo(OVRBoneId.Body_Chest, OVRBoneId.Body_SpineUpper),
[BodyJointId.Body_Neck] = new JointInfo(OVRBoneId.Body_Neck, OVRBoneId.Body_Chest),
[BodyJointId.Body_Head] = new JointInfo(OVRBoneId.Body_Head, OVRBoneId.Body_Neck),
// Left Arm
[BodyJointId.Body_LeftShoulder] = new JointInfo(OVRBoneId.Body_LeftShoulder, OVRBoneId.Body_Chest),
[BodyJointId.Body_LeftScapula] = new JointInfo(OVRBoneId.Body_LeftScapula, OVRBoneId.Body_LeftShoulder),
[BodyJointId.Body_LeftArmUpper] = new JointInfo(OVRBoneId.Body_LeftArmUpper, OVRBoneId.Body_LeftScapula),
[BodyJointId.Body_LeftArmLower] = new JointInfo(OVRBoneId.Body_LeftArmLower, OVRBoneId.Body_LeftArmUpper),
[BodyJointId.Body_LeftHandWristTwist] = new JointInfo(OVRBoneId.Body_LeftHandWristTwist, OVRBoneId.Body_LeftArmLower),
// Right Arm
[BodyJointId.Body_RightShoulder] = new JointInfo(OVRBoneId.Body_RightShoulder, OVRBoneId.Body_Chest),
[BodyJointId.Body_RightScapula] = new JointInfo(OVRBoneId.Body_RightScapula, OVRBoneId.Body_RightShoulder),
[BodyJointId.Body_RightArmUpper] = new JointInfo(OVRBoneId.Body_RightArmUpper, OVRBoneId.Body_RightScapula),
[BodyJointId.Body_RightArmLower] = new JointInfo(OVRBoneId.Body_RightArmLower, OVRBoneId.Body_RightArmUpper),
[BodyJointId.Body_RightHandWristTwist] = new JointInfo(OVRBoneId.Body_RightHandWristTwist, OVRBoneId.Body_RightArmLower),
// Left Hand
[BodyJointId.Body_LeftHandWrist] = new JointInfo(OVRBoneId.Body_LeftHandWrist, OVRBoneId.Body_LeftArmLower),
[BodyJointId.Body_LeftHandPalm] = new JointInfo(OVRBoneId.Body_LeftHandPalm, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandThumbMetacarpal] = new JointInfo(OVRBoneId.Body_LeftHandThumbMetacarpal, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandThumbProximal] = new JointInfo(OVRBoneId.Body_LeftHandThumbProximal, OVRBoneId.Body_LeftHandThumbMetacarpal),
[BodyJointId.Body_LeftHandThumbDistal] = new JointInfo(OVRBoneId.Body_LeftHandThumbDistal, OVRBoneId.Body_LeftHandThumbProximal),
[BodyJointId.Body_LeftHandThumbTip] = new JointInfo(OVRBoneId.Body_LeftHandThumbTip, OVRBoneId.Body_LeftHandThumbDistal),
[BodyJointId.Body_LeftHandIndexMetacarpal] = new JointInfo(OVRBoneId.Body_LeftHandIndexMetacarpal, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandIndexProximal] = new JointInfo(OVRBoneId.Body_LeftHandIndexProximal, OVRBoneId.Body_LeftHandIndexMetacarpal),
[BodyJointId.Body_LeftHandIndexIntermediate] = new JointInfo(OVRBoneId.Body_LeftHandIndexIntermediate, OVRBoneId.Body_LeftHandIndexProximal),
[BodyJointId.Body_LeftHandIndexDistal] = new JointInfo(OVRBoneId.Body_LeftHandIndexDistal, OVRBoneId.Body_LeftHandIndexIntermediate),
[BodyJointId.Body_LeftHandIndexTip] = new JointInfo(OVRBoneId.Body_LeftHandIndexTip, OVRBoneId.Body_LeftHandIndexDistal),
[BodyJointId.Body_LeftHandMiddleMetacarpal] = new JointInfo(OVRBoneId.Body_LeftHandMiddleMetacarpal, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandMiddleProximal] = new JointInfo(OVRBoneId.Body_LeftHandMiddleProximal, OVRBoneId.Body_LeftHandMiddleMetacarpal),
[BodyJointId.Body_LeftHandMiddleIntermediate] = new JointInfo(OVRBoneId.Body_LeftHandMiddleIntermediate, OVRBoneId.Body_LeftHandMiddleProximal),
[BodyJointId.Body_LeftHandMiddleDistal] = new JointInfo(OVRBoneId.Body_LeftHandMiddleDistal, OVRBoneId.Body_LeftHandMiddleIntermediate),
[BodyJointId.Body_LeftHandMiddleTip] = new JointInfo(OVRBoneId.Body_LeftHandMiddleTip, OVRBoneId.Body_LeftHandMiddleDistal),
[BodyJointId.Body_LeftHandRingMetacarpal] = new JointInfo(OVRBoneId.Body_LeftHandRingMetacarpal, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandRingProximal] = new JointInfo(OVRBoneId.Body_LeftHandRingProximal, OVRBoneId.Body_LeftHandRingMetacarpal),
[BodyJointId.Body_LeftHandRingIntermediate] = new JointInfo(OVRBoneId.Body_LeftHandRingIntermediate, OVRBoneId.Body_LeftHandRingProximal),
[BodyJointId.Body_LeftHandRingDistal] = new JointInfo(OVRBoneId.Body_LeftHandRingDistal, OVRBoneId.Body_LeftHandRingIntermediate),
[BodyJointId.Body_LeftHandRingTip] = new JointInfo(OVRBoneId.Body_LeftHandRingTip, OVRBoneId.Body_LeftHandRingDistal),
[BodyJointId.Body_LeftHandLittleMetacarpal] = new JointInfo(OVRBoneId.Body_LeftHandLittleMetacarpal, OVRBoneId.Body_LeftHandWrist),
[BodyJointId.Body_LeftHandLittleProximal] = new JointInfo(OVRBoneId.Body_LeftHandLittleProximal, OVRBoneId.Body_LeftHandLittleMetacarpal),
[BodyJointId.Body_LeftHandLittleIntermediate] = new JointInfo(OVRBoneId.Body_LeftHandLittleIntermediate, OVRBoneId.Body_LeftHandLittleProximal),
[BodyJointId.Body_LeftHandLittleDistal] = new JointInfo(OVRBoneId.Body_LeftHandLittleDistal, OVRBoneId.Body_LeftHandLittleIntermediate),
[BodyJointId.Body_LeftHandLittleTip] = new JointInfo(OVRBoneId.Body_LeftHandLittleTip, OVRBoneId.Body_LeftHandLittleDistal),
// Right Hand
[BodyJointId.Body_RightHandWrist] = new JointInfo(OVRBoneId.Body_RightHandWrist, OVRBoneId.Body_RightArmLower),
[BodyJointId.Body_RightHandPalm] = new JointInfo(OVRBoneId.Body_RightHandPalm, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandThumbMetacarpal] = new JointInfo(OVRBoneId.Body_RightHandThumbMetacarpal, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandThumbProximal] = new JointInfo(OVRBoneId.Body_RightHandThumbProximal, OVRBoneId.Body_RightHandThumbMetacarpal),
[BodyJointId.Body_RightHandThumbDistal] = new JointInfo(OVRBoneId.Body_RightHandThumbDistal, OVRBoneId.Body_RightHandThumbProximal),
[BodyJointId.Body_RightHandThumbTip] = new JointInfo(OVRBoneId.Body_RightHandThumbTip, OVRBoneId.Body_RightHandThumbDistal),
[BodyJointId.Body_RightHandIndexMetacarpal] = new JointInfo(OVRBoneId.Body_RightHandIndexMetacarpal, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandIndexProximal] = new JointInfo(OVRBoneId.Body_RightHandIndexProximal, OVRBoneId.Body_RightHandIndexMetacarpal),
[BodyJointId.Body_RightHandIndexIntermediate] = new JointInfo(OVRBoneId.Body_RightHandIndexIntermediate, OVRBoneId.Body_RightHandIndexProximal),
[BodyJointId.Body_RightHandIndexDistal] = new JointInfo(OVRBoneId.Body_RightHandIndexDistal, OVRBoneId.Body_RightHandIndexIntermediate),
[BodyJointId.Body_RightHandIndexTip] = new JointInfo(OVRBoneId.Body_RightHandIndexTip, OVRBoneId.Body_RightHandIndexDistal),
[BodyJointId.Body_RightHandMiddleMetacarpal] = new JointInfo(OVRBoneId.Body_RightHandMiddleMetacarpal, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandMiddleProximal] = new JointInfo(OVRBoneId.Body_RightHandMiddleProximal, OVRBoneId.Body_RightHandMiddleMetacarpal),
[BodyJointId.Body_RightHandMiddleIntermediate] = new JointInfo(OVRBoneId.Body_RightHandMiddleIntermediate, OVRBoneId.Body_RightHandMiddleProximal),
[BodyJointId.Body_RightHandMiddleDistal] = new JointInfo(OVRBoneId.Body_RightHandMiddleDistal, OVRBoneId.Body_RightHandMiddleIntermediate),
[BodyJointId.Body_RightHandMiddleTip] = new JointInfo(OVRBoneId.Body_RightHandMiddleTip, OVRBoneId.Body_RightHandMiddleDistal),
[BodyJointId.Body_RightHandRingMetacarpal] = new JointInfo(OVRBoneId.Body_RightHandRingMetacarpal, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandRingProximal] = new JointInfo(OVRBoneId.Body_RightHandRingProximal, OVRBoneId.Body_RightHandRingMetacarpal),
[BodyJointId.Body_RightHandRingIntermediate] = new JointInfo(OVRBoneId.Body_RightHandRingIntermediate, OVRBoneId.Body_RightHandRingProximal),
[BodyJointId.Body_RightHandRingDistal] = new JointInfo(OVRBoneId.Body_RightHandRingDistal, OVRBoneId.Body_RightHandRingIntermediate),
[BodyJointId.Body_RightHandRingTip] = new JointInfo(OVRBoneId.Body_RightHandRingTip, OVRBoneId.Body_RightHandRingDistal),
[BodyJointId.Body_RightHandLittleMetacarpal] = new JointInfo(OVRBoneId.Body_RightHandLittleMetacarpal, OVRBoneId.Body_RightHandWrist),
[BodyJointId.Body_RightHandLittleProximal] = new JointInfo(OVRBoneId.Body_RightHandLittleProximal, OVRBoneId.Body_RightHandLittleMetacarpal),
[BodyJointId.Body_RightHandLittleIntermediate] = new JointInfo(OVRBoneId.Body_RightHandLittleIntermediate, OVRBoneId.Body_RightHandLittleProximal),
[BodyJointId.Body_RightHandLittleDistal] = new JointInfo(OVRBoneId.Body_RightHandLittleDistal, OVRBoneId.Body_RightHandLittleIntermediate),
[BodyJointId.Body_RightHandLittleTip] = new JointInfo(OVRBoneId.Body_RightHandLittleTip, OVRBoneId.Body_RightHandLittleDistal),
};
}
}

View File

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