Initialer Upload neues Unity-Projekt
This commit is contained in:
63
Assets/Oculus/Interaction/Runtime/Scripts/Input/HMD/Hmd.cs
Normal file
63
Assets/Oculus/Interaction/Runtime/Scripts/Input/HMD/Hmd.cs
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
public class Hmd : DataModifier<HmdDataAsset>, IHmd
|
||||
{
|
||||
public event Action WhenUpdated = delegate { };
|
||||
|
||||
protected override void Apply(HmdDataAsset data)
|
||||
{
|
||||
// Default implementation does nothing, to allow instantiation of this modifier directly
|
||||
}
|
||||
|
||||
public override void MarkInputDataRequiresUpdate()
|
||||
{
|
||||
base.MarkInputDataRequiresUpdate();
|
||||
|
||||
if (Started)
|
||||
{
|
||||
WhenUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetRootPose(out Pose pose)
|
||||
{
|
||||
var currentData = GetData();
|
||||
|
||||
if (!currentData.IsTracked)
|
||||
{
|
||||
pose = Pose.identity;
|
||||
return false;
|
||||
}
|
||||
ITrackingToWorldTransformer transformer = GetData().Config.TrackingToWorldTransformer;
|
||||
pose = transformer.ToWorldPose(currentData.Root);
|
||||
return true;
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2606bf2f0c914a7aba4390f29ba2eb6e
|
||||
timeCreated: 1629334585
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
[Serializable]
|
||||
public class HmdDataAsset : ICopyFrom<HmdDataAsset>
|
||||
{
|
||||
public Pose Root;
|
||||
public bool IsTracked;
|
||||
public int FrameId;
|
||||
public HmdDataSourceConfig Config;
|
||||
|
||||
public void CopyFrom(HmdDataAsset source)
|
||||
{
|
||||
Root = source.Root;
|
||||
IsTracked = source.IsTracked;
|
||||
FrameId = source.FrameId;
|
||||
Config = source.Config;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 332eb9fb3feb493aa2632f2739bf3d41
|
||||
timeCreated: 1629321466
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of constants that are passed to each child of a Hand modifier tree from the root DataSource.
|
||||
/// </summary>
|
||||
public class HmdDataSourceConfig
|
||||
{
|
||||
public ITrackingToWorldTransformer TrackingToWorldTransformer { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e6945eb8bd2e9941a48a55b14cda4d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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 UnityEngine.Assertions;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of constants that are passed to each child of a Hand modifier tree from the root DataSource.
|
||||
/// </summary>
|
||||
public class HmdRef : MonoBehaviour, IHmd
|
||||
{
|
||||
[SerializeField, Interface(typeof(IHmd))]
|
||||
private UnityEngine.Object _hmd;
|
||||
private IHmd Hmd;
|
||||
|
||||
public event Action WhenUpdated
|
||||
{
|
||||
add => Hmd.WhenUpdated += value;
|
||||
remove => Hmd.WhenUpdated -= value;
|
||||
}
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Hmd = _hmd as IHmd;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.AssertField(Hmd, nameof(Hmd));
|
||||
}
|
||||
|
||||
public bool TryGetRootPose(out Pose pose)
|
||||
{
|
||||
return Hmd.TryGetRootPose(out pose);
|
||||
}
|
||||
|
||||
#region Inject
|
||||
public void InjectAllHmdRef(IHmd hmd)
|
||||
{
|
||||
InjectHmd(hmd);
|
||||
}
|
||||
|
||||
public void InjectHmd(IHmd hmd)
|
||||
{
|
||||
_hmd = hmd as UnityEngine.Object;
|
||||
Hmd = hmd;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 484167e684014224c9a8bff92b293c6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Oculus/Interaction/Runtime/Scripts/Input/HMD/IHmd.cs
Normal file
31
Assets/Oculus/Interaction/Runtime/Scripts/Input/HMD/IHmd.cs
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
public interface IHmd
|
||||
{
|
||||
bool TryGetRootPose(out Pose pose);
|
||||
event Action WhenUpdated;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d92925b93eb01cf4ba528518efe2705a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user