Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,004 changes: 1,228 additions & 776 deletions Assets/Gothic-VR/Resources/VR/Prefabs/VR - Player XRI.prefab

Large diffs are not rendered by default.

145 changes: 145 additions & 0 deletions Assets/Gothic-VR/Resources/VR/Prefabs/Vobs/oCItem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ GameObject:
- component: {fileID: 2018021949967966991}
- component: {fileID: 5746501746354695612}
- component: {fileID: 6145980801324581266}
- component: {fileID: 5604778400711577802}
- component: {fileID: 1949468816389965935}
m_Layer: 6
m_Name: oCItem
m_TagString: GothicVob
Expand Down Expand Up @@ -287,6 +289,149 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 594f5e7857d0629419c1bef807639a86, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Backends.Hvr.HvrInteractableBridge
--- !u!114 &5604778400711577802
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503575194566409312}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6087a45bbe7ac8f469bf5110b3d64b49, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Backends.Xri.GothicGrabInteractable
m_InteractionManager: {fileID: 0}
m_Colliders: []
m_InteractionLayers:
m_Bits: 1
m_DistanceCalculationMode: 1
m_SelectMode: 1
m_FocusMode: 1
m_CustomReticle: {fileID: 0}
m_AllowGazeInteraction: 0
m_AllowGazeSelect: 0
m_OverrideGazeTimeToSelect: 0
m_GazeTimeToSelect: 0.5
m_OverrideTimeToAutoDeselectGaze: 0
m_TimeToAutoDeselectGaze: 3
m_AllowGazeAssistance: 0
m_FirstHoverEntered:
m_PersistentCalls:
m_Calls: []
m_LastHoverExited:
m_PersistentCalls:
m_Calls: []
m_HoverEntered:
m_PersistentCalls:
m_Calls: []
m_HoverExited:
m_PersistentCalls:
m_Calls: []
m_FirstSelectEntered:
m_PersistentCalls:
m_Calls: []
m_LastSelectExited:
m_PersistentCalls:
m_Calls: []
m_SelectEntered:
m_PersistentCalls:
m_Calls: []
m_SelectExited:
m_PersistentCalls:
m_Calls: []
m_FirstFocusEntered:
m_PersistentCalls:
m_Calls: []
m_LastFocusExited:
m_PersistentCalls:
m_Calls: []
m_FocusEntered:
m_PersistentCalls:
m_Calls: []
m_FocusExited:
m_PersistentCalls:
m_Calls: []
m_Activated:
m_PersistentCalls:
m_Calls: []
m_Deactivated:
m_PersistentCalls:
m_Calls: []
m_StartingHoverFilters: []
m_StartingSelectFilters: []
m_StartingInteractionStrengthFilters: []
m_AutoFindParentInteractableInHierarchy: 0
m_ParentInteractableObject: {fileID: 0}
m_AttachTransform: {fileID: 0}
m_SecondaryAttachTransform: {fileID: 0}
m_UseDynamicAttach: 1
m_MatchAttachPosition: 1
m_MatchAttachRotation: 1
m_SnapToColliderVolume: 1
m_ReinitializeDynamicAttachEverySingleGrab: 1
m_AttachEaseInTime: 0.15
m_MovementType: 0
m_PredictedVisualsTransform: {fileID: 0}
m_VelocityDamping: 1
m_VelocityScale: 1
m_AngularVelocityDamping: 1
m_AngularVelocityScale: 1
m_TrackPosition: 1
m_SmoothPosition: 0
m_SmoothPositionAmount: 8
m_TightenPosition: 0.1
m_TrackRotation: 1
m_SmoothRotation: 0
m_SmoothRotationAmount: 8
m_TightenRotation: 0.1
m_TrackScale: 1
m_SmoothScale: 0
m_SmoothScaleAmount: 8
m_TightenScale: 0.1
m_ThrowOnDetach: 1
m_ThrowSmoothingDuration: 0.25
m_ThrowSmoothingCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_ThrowVelocityScale: 1.5
m_ThrowAngularVelocityScale: 1
m_ForceGravityOnDetach: 0
m_UnparentTransformOnGrab: 0
m_RetainTransformParent: 1
m_StartingSingleGrabTransformers: []
m_StartingMultipleGrabTransformers: []
m_AddDefaultGrabTransformers: 1
m_FarAttachMode: 0
m_LimitLinearVelocity: 0
m_LimitAngularVelocity: 0
m_MaxLinearVelocityDelta: 10
m_MaxAngularVelocityDelta: 20
_heldInterpolation: 1
--- !u!114 &1949468816389965935
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503575194566409312}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d53defac19fbb474d81910e60e275fd7, type: 3}
m_Name:
m_EditorClassIdentifier: Gothic.VR::Gothic.VR.Interaction.Backends.Xri.XriInteractableBridge
--- !u!1001 &2283517946604736509
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
using HurricaneVR.Framework.Core;
using HurricaneVR.Framework.Core.Grabbers;
using HurricaneVR.Framework.Core.Sockets;
using Reflex.Attributes;
using UnityEngine;

namespace Gothic.VR.Interaction.Backends.Hvr
{
/// <summary>
/// Sits next to an HVRGrabbable and its VrInteractable. Forwards HVR's grabbable events synchronously to the
/// VrInteractable and executes its commands on the HVRGrabbable.
/// Inactive (no subscriptions) if another backend runs; prefabs carry the bridges of all backends.
/// </summary>
public class HvrInteractableBridge : MonoBehaviour, IVrInteractableBackend
{
[Inject] private readonly IVrBackend _vrBackend;

private HVRGrabbable _grabbable;
private VrInteractable _interactable;
private bool _isSubscribed;
Expand All @@ -29,13 +33,18 @@ private HVRGrabbable Grabbable
}
}

/// <summary>
/// Without injection (e.g. objects outside a scene scope), HVR is assumed as before the XRI backend existed.
/// </summary>
public bool IsActive => _vrBackend == null || _vrBackend is HvrBackend;

public bool IsHeld => Grabbable.IsBeingHeld;
public IReadOnlyList<Collider> Colliders => Grabbable.Colliders;

private void Awake()
{
_interactable = GetComponent<VrInteractable>();
if (Grabbable == null || _interactable == null)
if (!IsActive || Grabbable == null || _interactable == null)
return;

Grabbable.HoverEnter.AddListener(OnHoverEnter);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactables;

namespace Gothic.VR.Interaction.Backends.Xri
{
/// <summary>
/// XRGrabInteractable for Gothic items. Adds what XRI lacks compared to HVR:
/// - BeforeGrabbed: raised (via XriInteractableBridge) before XRI captures the Rigidbody state. Gothic items lie
/// kinematic, the game turns physics on there, so that VelocityTracking moves them and they fall when dropped.
/// - Interpolation while held, against jitter of velocity tracked items while walking.
///
/// Disabled in the prefab. XriInteractableBridge enables it on the XRI backend once the runtime colliders exist.
/// </summary>
public class GothicGrabInteractable : XRGrabInteractable
{
[Tooltip("Rigidbody interpolation while held. Restored on drop.")]
[SerializeField] private RigidbodyInterpolation _heldInterpolation = RigidbodyInterpolation.Interpolate;

private XriInteractableBridge _bridge;
private RigidbodyInterpolation _interpolationBeforeGrab;
private bool _isInterpolationOverridden;

protected override void Awake()
{
base.Awake();
_bridge = GetComponent<XriInteractableBridge>();
}

protected override void OnSelectEntering(SelectEnterEventArgs args)
{
// Before base: XRGrabInteractable.Grab() stores isKinematic, which it restores on drop.
if (_bridge != null)
_bridge.OnSelectEntering(args);

base.OnSelectEntering(args);
}

protected override void SetupRigidbodyGrab(Rigidbody rigidbody)
{
// XRI calls it again when the movement type changes while held.
if (!_isInterpolationOverridden)
{
_interpolationBeforeGrab = rigidbody.interpolation;
_isInterpolationOverridden = true;
}

base.SetupRigidbodyGrab(rigidbody);
rigidbody.interpolation = _heldInterpolation;
}

protected override void SetupRigidbodyDrop(Rigidbody rigidbody)
{
base.SetupRigidbodyDrop(rigidbody);
if (!_isInterpolationOverridden)
return;

rigidbody.interpolation = _interpolationBeforeGrab;
_isInterpolationOverridden = false;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Assets/Gothic-VR/Scripts/Interaction/Backends/Xri/XriBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace Gothic.VR.Interaction.Backends.Xri
{
/// <summary>
/// XR Interaction Toolkit backend. Always compiled, as XRI is a free package.
/// Implemented: input, haptics, SFX, UI laser pointers and the player rig (XriRig on "VR - Player XRI.prefab",
/// with ScreenFade/WallFade on its camera).
/// Missing: the simulator (HVR phase 1d) and grabbing (phase 2).
/// Implemented: input, haptics, SFX, UI laser pointers, the player rig (XriRig on "VR - Player XRI.prefab",
/// with ScreenFade/WallFade on its camera), the XR Interaction Simulator and item grabbing (Near-Far interactor
/// per hand, GothicGrabInteractable + XriInteractableBridge on oCItem).
/// Missing: grabbing mobs/NPCs (phase 2b), sockets (3), doors/chests/ladders (4) and hands (5).
/// </summary>
public class XriBackend : IVrBackend
{
Expand All @@ -18,8 +19,8 @@ public class XriBackend : IVrBackend
public void InstallBindings(ContainerBuilder containerBuilder)
{
Logger.LogWarning("XRI backend is work in progress: rig, locomotion, input, haptics, UI laser pointers, " +
"screen fades and the XR Interaction Simulator work. Grabbing (phase 2), sockets (3), " +
"doors/chests/ladders (4) and hands (5) are missing.", LogCat.VR);
"screen fades, the XR Interaction Simulator and item grabbing work. Mobs/NPCs (phase " +
"2b), sockets (3), doors/chests/ladders (4) and hands (5) are missing.", LogCat.VR);

containerBuilder.AddSingleton(typeof(XriInput), typeof(IVrInput), typeof(XriInput));
containerBuilder.AddSingleton(typeof(XriHaptics), typeof(IVrHaptics));
Expand Down
Loading