mid Control implementation and... a Unity Update (backup)
This commit is contained in:
parent
0a7f98b4d2
commit
213d7ec0e9
7 changed files with 101 additions and 67 deletions
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
[Serializable]
|
||||
public class Control
|
||||
|
@ -7,23 +8,55 @@ public class Control
|
|||
[HideInInspector]
|
||||
public Logic logic;
|
||||
|
||||
public OculusFilter oculusFilter;
|
||||
public ValveFilter valveFilter;
|
||||
|
||||
public bool connected;
|
||||
public InputDevice headDevice, lHandDevice, rHandDevice;
|
||||
public Vector3 headTrackedPos, lHandTrackedPos, rHandTrackedPos;
|
||||
public Quaternion headTrackedRot, lHandTrackedRot, rHandTrackedRot;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
|
||||
oculusFilter.Set(setter);
|
||||
valveFilter.Set(setter);
|
||||
}
|
||||
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
|
||||
oculusFilter.Fetch(setter);
|
||||
valveFilter.Fetch(setter);
|
||||
}
|
||||
|
||||
public void Start(Logic logic)
|
||||
{
|
||||
this.logic = logic;
|
||||
|
||||
headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
|
||||
lHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
|
||||
rHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
|
||||
|
||||
oculusFilter.Start(this);
|
||||
valveFilter.Start(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// General
|
||||
connected = headDevice.IsValid && (lHandDevice.IsValid || rHandDevice.IsValid);
|
||||
if (!connected)
|
||||
return;
|
||||
|
||||
|
||||
XRDevice.DisableAutoXRCameraTracking(Camera.main, true);
|
||||
|
||||
// headDevice.TryGetFeatureValue();
|
||||
// need to update...
|
||||
|
||||
// you can play with your left controller or your right (and?) RIG CLASS?
|
||||
|
||||
// Swappable Proprietary Overrides
|
||||
oculusFilter.Update();
|
||||
valveFilter.Update();
|
||||
}
|
||||
}
|
|
@ -1,17 +1,28 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class OculusBS : MonoBehaviour
|
||||
[Serializable]
|
||||
public class OculusFilter
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
[HideInInspector]
|
||||
public Control control;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Start(Control control)
|
||||
{
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ValveFilter : MonoBehaviour
|
||||
[Serializable]
|
||||
public class ValveFilter
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
[HideInInspector]
|
||||
public Control control;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Start(Control control)
|
||||
{
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -9,17 +9,16 @@ public class Logic
|
|||
|
||||
public Control control;
|
||||
public World world;
|
||||
public Rig rig;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
rig.Set(setter);
|
||||
control.Set(setter);
|
||||
world.Set(setter);
|
||||
}
|
||||
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
rig.Fetch(setter);
|
||||
control.Fetch(setter);
|
||||
world.Fetch(setter);
|
||||
}
|
||||
|
||||
|
@ -27,12 +26,14 @@ public class Logic
|
|||
{
|
||||
this.mono = mono;
|
||||
|
||||
rig.Start(this);
|
||||
control.Start(this);
|
||||
world.Start(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
control.Update();
|
||||
if (control.connected)
|
||||
world.Update();
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ using UnityEngine.XR;
|
|||
public class Rig
|
||||
{
|
||||
[HideInInspector]
|
||||
public Logic logic;
|
||||
public World world;
|
||||
|
||||
[Header("Design")]
|
||||
public float scale;
|
||||
|
@ -41,14 +41,15 @@ public class Rig
|
|||
[HideInInspector]
|
||||
public Vector3 controllerPos;
|
||||
|
||||
bool leftOn, rightOn, touchOn;
|
||||
public Vector3 boxShake, boxOffset;
|
||||
|
||||
public bool alignRecordCam;
|
||||
|
||||
public void Start(Logic logic)
|
||||
public void Start(World world)
|
||||
{
|
||||
this.logic = logic;
|
||||
this.world = world;
|
||||
|
||||
|
||||
Game.OnBump += Bump; // replace these systems...
|
||||
Game.OnCrash += Bump;
|
||||
|
||||
|
@ -60,27 +61,6 @@ public class Rig
|
|||
public Lerper lerper;
|
||||
public void Update()
|
||||
{
|
||||
// Input System
|
||||
UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(Camera.main, true);
|
||||
leftOn = OVRInput.IsControllerConnected(OVRInput.Controller.LTrackedRemote);
|
||||
rightOn = OVRInput.IsControllerConnected(OVRInput.Controller.RTrackedRemote);
|
||||
touchOn = OVRInput.IsControllerConnected(OVRInput.Controller.RTouch);
|
||||
|
||||
if (leftOn || rightOn || touchOn)
|
||||
{
|
||||
if (leftOn) { ovrCon = OVRInput.Controller.LTrackedRemote; }
|
||||
else if (rightOn) { ovrCon = OVRInput.Controller.RTrackedRemote; }
|
||||
else if (touchOn) { ovrCon = OVRInput.Controller.RTouch; }
|
||||
|
||||
disconnected.SetActive(false);
|
||||
Time.timeScale = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnected.SetActive(true);
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
|
||||
// Apply to Transforms
|
||||
Quaternion flip = Quaternion.identity;
|
||||
head.localPosition = InputTracking.GetLocalPosition(XRNode.Head);
|
||||
|
|
|
@ -7,23 +7,27 @@ public class World
|
|||
[HideInInspector]
|
||||
public Logic logic;
|
||||
|
||||
public Rig rig;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
|
||||
rig.Set(setter);
|
||||
}
|
||||
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
|
||||
rig.Fetch(setter);
|
||||
}
|
||||
|
||||
public void Start(Logic logic)
|
||||
{
|
||||
this.logic = logic;
|
||||
|
||||
rig.Start(this);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
|
||||
rig.Update();
|
||||
}
|
||||
}
|
|
@ -8,8 +8,6 @@ public class Monolith : MonoBehaviour
|
|||
|
||||
[Header("Design")]
|
||||
public float test;
|
||||
public string words = "";
|
||||
public Vector3 v3;
|
||||
|
||||
[Header("References")]
|
||||
public InspectorSetter setter;
|
||||
|
@ -17,8 +15,6 @@ public class Monolith : MonoBehaviour
|
|||
void OnDisable()
|
||||
{
|
||||
setter.Set("Monolith.test", test);
|
||||
setter.Set("Monolith.words", words);
|
||||
setter.Set("Monolith.v3", v3);
|
||||
|
||||
logic.Set(setter);
|
||||
render.Set(setter);
|
||||
|
@ -29,8 +25,6 @@ public class Monolith : MonoBehaviour
|
|||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
test = setter.Fetch("Monolith.test", test);
|
||||
words = setter.Fetch("Monolith.words", words);
|
||||
v3 = setter.Fetch("Monolith.v3", v3);
|
||||
|
||||
logic.Fetch(setter);
|
||||
render.Fetch(setter);
|
||||
|
|
Reference in a new issue