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,135 @@
/*
* 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;
using UnityEngine;
using Oculus.Interaction.Body.Input;
using Oculus.Interaction.Body.PoseDetection;
namespace Oculus.Interaction.Body.Samples
{
public class BodyPoseSwitcher : MonoBehaviour, IBodyPose
{
public enum PoseSource
{
PoseA,
PoseB,
}
public event Action WhenBodyPoseUpdated = delegate { };
[SerializeField, Interface(typeof(IBodyPose))]
private UnityEngine.Object _poseA;
private IBodyPose PoseA;
[SerializeField, Interface(typeof(IBodyPose))]
private UnityEngine.Object _poseB;
private IBodyPose PoseB;
[SerializeField]
private PoseSource _source = PoseSource.PoseA;
public ISkeletonMapping SkeletonMapping => GetPose().SkeletonMapping;
public bool GetJointPoseFromRoot(BodyJointId bodyJointId, out Pose pose) =>
GetPose().GetJointPoseFromRoot(bodyJointId, out pose);
public bool GetJointPoseLocal(BodyJointId bodyJointId, out Pose pose) =>
GetPose().GetJointPoseLocal(bodyJointId, out pose);
protected bool _started = false;
public PoseSource Source
{
get { return _source; }
set
{
bool changed = value != _source;
_source = value;
if (changed)
{
WhenBodyPoseUpdated.Invoke();
}
}
}
public void UsePoseA()
{
Source = PoseSource.PoseA;
}
public void UsePoseB()
{
Source = PoseSource.PoseB;
}
protected virtual void Awake()
{
PoseA = _poseA as IBodyPose;
PoseB = _poseB as IBodyPose;
}
protected virtual void Start()
{
this.BeginStart(ref _started);
this.AssertField(PoseA, nameof(PoseA));
this.AssertField(PoseB, nameof(PoseB));
this.EndStart(ref _started);
}
protected virtual void OnEnable()
{
if (_started)
{
PoseA.WhenBodyPoseUpdated += () => OnPoseUpdated(PoseSource.PoseA);
PoseB.WhenBodyPoseUpdated += () => OnPoseUpdated(PoseSource.PoseB);
}
}
protected virtual void OnDisable()
{
if (_started)
{
PoseA.WhenBodyPoseUpdated -= () => OnPoseUpdated(PoseSource.PoseA);
PoseB.WhenBodyPoseUpdated -= () => OnPoseUpdated(PoseSource.PoseB);
}
}
private void OnPoseUpdated(PoseSource source)
{
if (source == Source)
{
WhenBodyPoseUpdated.Invoke();
}
}
private IBodyPose GetPose()
{
switch (Source)
{
default:
case PoseSource.PoseA:
return PoseA;
case PoseSource.PoseB:
return PoseB;
}
}
}
}

View File

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

View File

@ -0,0 +1,115 @@
/*
* 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;
using UnityEngine;
using Oculus.Interaction.Body.Input;
using Oculus.Interaction.Body.PoseDetection;
using System.Collections.Generic;
namespace Oculus.Interaction.Body.Samples
{
public class LockedBodyPose : MonoBehaviour, IBodyPose
{
private static readonly Pose HIP_OFFSET = new Pose()
{
position = new Vector3(0f, 0.923987f, 0f),
rotation = Quaternion.Euler(0, 270, 270),
};
public event Action WhenBodyPoseUpdated = delegate { };
[Tooltip("The body pose to be locked")]
[SerializeField, Interface(typeof(IBodyPose))]
private UnityEngine.Object _pose;
private IBodyPose Pose;
[Tooltip("The body pose will be locked relative to this " +
"joint at the specified offset.")]
[SerializeField]
private BodyJointId _referenceJoint = BodyJointId.Body_Hips;
[Tooltip("The reference joint will be placed at " +
"this offset from the root.")]
[SerializeField]
private Pose _referenceOffset = HIP_OFFSET;
protected bool _started = false;
private Dictionary<BodyJointId, Pose> _lockedPoses;
public ISkeletonMapping SkeletonMapping => Pose.SkeletonMapping;
public bool GetJointPoseLocal(BodyJointId bodyJointId, out Pose pose) =>
Pose.GetJointPoseLocal(bodyJointId, out pose);
public bool GetJointPoseFromRoot(BodyJointId bodyJointId, out Pose pose) =>
_lockedPoses.TryGetValue(bodyJointId, out pose);
private void UpdateLockedBodyPose()
{
_lockedPoses.Clear();
for (int i = 0; i < Constants.NUM_BODY_JOINTS; ++i)
{
BodyJointId jointId = (BodyJointId)i;
if (Pose.GetJointPoseFromRoot(_referenceJoint, out Pose referencePose) &&
Pose.GetJointPoseFromRoot(jointId, out Pose jointPose))
{
ref Pose offset = ref referencePose;
PoseUtils.Invert(ref offset);
PoseUtils.Multiply(offset, jointPose, ref jointPose);
PoseUtils.Multiply(_referenceOffset, jointPose, ref jointPose);
_lockedPoses[jointId] = jointPose;
}
}
WhenBodyPoseUpdated.Invoke();
}
protected virtual void Awake()
{
_lockedPoses = new Dictionary<BodyJointId, Pose>();
Pose = _pose as IBodyPose;
}
protected virtual void Start()
{
this.BeginStart(ref _started);
this.AssertField(Pose, nameof(Pose));
UpdateLockedBodyPose();
this.EndStart(ref _started);
}
protected virtual void OnEnable()
{
if (_started)
{
Pose.WhenBodyPoseUpdated += UpdateLockedBodyPose;
}
}
protected virtual void OnDisable()
{
if (_started)
{
Pose.WhenBodyPoseUpdated -= UpdateLockedBodyPose;
}
}
}
}

View File

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

View File

@ -0,0 +1,91 @@
/*
* 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 UnityEngine.Events;
using TMPro;
namespace Oculus.Interaction.Body.Samples
{
public class PoseCaptureCountdown : MonoBehaviour
{
[SerializeField]
private UnityEvent _timerStart = new UnityEvent();
[SerializeField]
private UnityEvent _timerSecondTick = new UnityEvent();
[SerializeField]
private UnityEvent _timeUp = new UnityEvent();
[SerializeField]
private TextMeshProUGUI _countdownText;
[SerializeField]
private string _poseText = "Capture Pose";
[SerializeField]
private float duration = 10f;
[SerializeField, Optional]
private Renderer _renderer;
[SerializeField, Optional]
private Color _resetColor;
private float _timer = 0f;
public void Restart()
{
_timer = duration;
_timerStart.Invoke();
if (_renderer != null)
{
_renderer.material.color = _resetColor;
}
}
private void Update()
{
bool wasCounting = _timer > 0f;
if (wasCounting)
{
int prevSecond = (int)_timer;
_timer -= Time.unscaledDeltaTime;
if ((int)_timer < prevSecond)
{
_timerSecondTick.Invoke();
}
}
bool isCounting = _timer > 0f;
if (wasCounting && !isCounting)
{
_timer = 0f;
_timeUp.Invoke();
_countdownText.text = _poseText;
}
else if (isCounting)
{
_countdownText.text = _timer.ToString("#0.0");
}
}
}
}

View File

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