flip polish (pre refactor)

This commit is contained in:
spatialfree 2020-12-04 18:55:00 -08:00
parent 29ef0e1214
commit 96ab7cd8d7
2 changed files with 226 additions and 56 deletions

View file

@ -551,7 +551,7 @@ Transform:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 45752346} m_GameObject: {fileID: 45752346}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.133, z: -0.217} m_LocalPosition: {x: 0.12, y: -0.25, z: -0.217}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 1318561811} - {fileID: 1318561811}
@ -875,7 +875,7 @@ LineRenderer:
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
- {fileID: 10306, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 2100000, guid: d584c93390323c84cbdb0665a4a3721a, type: 2}
m_StaticBatchInfo: m_StaticBatchInfo:
firstSubMesh: 0 firstSubMesh: 0
subMeshCount: 0 subMeshCount: 0
@ -900,7 +900,7 @@ LineRenderer:
- {x: 0, y: 0, z: 1} - {x: 0, y: 0, z: 1}
m_Parameters: m_Parameters:
serializedVersion: 3 serializedVersion: 3
widthMultiplier: 0.1 widthMultiplier: 0.333
widthCurve: widthCurve:
serializedVersion: 2 serializedVersion: 2
m_Curve: m_Curve:
@ -913,13 +913,22 @@ LineRenderer:
weightedMode: 0 weightedMode: 0
inWeight: 0.33333334 inWeight: 0.33333334
outWeight: 0.33333334 outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0.333
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
colorGradient: colorGradient:
serializedVersion: 2 serializedVersion: 2
key0: {r: 1, g: 0.627451, b: 1, a: 1} key0: {r: 1, g: 1, b: 1, a: 1}
key1: {r: 0.9811321, g: 0.5322179, b: 0.64302593, a: 1} key1: {r: 1, g: 1, b: 1, a: 1}
key2: {r: 0, g: 0, b: 0, a: 0} key2: {r: 0, g: 0, b: 0, a: 0}
key3: {r: 0, g: 0, b: 0, a: 0} key3: {r: 0, g: 0, b: 0, a: 0}
key4: {r: 0, g: 0, b: 0, a: 0} key4: {r: 0, g: 0, b: 0, a: 0}
@ -946,7 +955,7 @@ LineRenderer:
m_NumColorKeys: 2 m_NumColorKeys: 2
m_NumAlphaKeys: 2 m_NumAlphaKeys: 2
numCornerVertices: 0 numCornerVertices: 0
numCapVertices: 0 numCapVertices: 5
alignment: 0 alignment: 0
textureMode: 0 textureMode: 0
shadowBias: 0.5 shadowBias: 0.5
@ -964,8 +973,8 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 1796811813}
m_RootOrder: 3 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &202625280 --- !u!1 &202625280
GameObject: GameObject:
@ -1487,7 +1496,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &343354975 --- !u!82 &343354975
AudioSource: AudioSource:
@ -1828,7 +1837,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 8 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &408032442 --- !u!114 &408032442
MonoBehaviour: MonoBehaviour:
@ -1876,6 +1885,7 @@ Transform:
m_Children: m_Children:
- {fileID: 963194228} - {fileID: 963194228}
- {fileID: 45752347} - {fileID: 45752347}
- {fileID: 588278528}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1896,9 +1906,10 @@ MonoBehaviour:
disconnected: {fileID: 1638248270} disconnected: {fileID: 1638248270}
head: {fileID: 963194228} head: {fileID: 963194228}
con: {fileID: 45752347} con: {fileID: 45752347}
lCon: {fileID: 588278528}
hangingRod: {fileID: 1554483892} hangingRod: {fileID: 1554483892}
recordCam: {fileID: 850212509} recordCam: {fileID: 850212509}
remote: 0 ovrCon: 0
controllerRot: {x: 0, y: 0, z: 0, w: 1} controllerRot: {x: 0, y: 0, z: 0, w: 1}
inputRot: {x: 0, y: 0, z: 0, w: 1} inputRot: {x: 0, y: 0, z: 0, w: 1}
controllerPos: {x: 0, y: 0, z: 0} controllerPos: {x: 0, y: 0, z: 0}
@ -1906,7 +1917,10 @@ MonoBehaviour:
boxShake: {x: 0, y: 0, z: 0} boxShake: {x: 0, y: 0, z: 0}
boxOffset: {x: 0, y: 0, z: 0} boxOffset: {x: 0, y: 0, z: 0}
alignRecordCam: 1 alignRecordCam: 1
pullLine: {fileID: 114864358} lerper:
t: 0
spring: 60
dampen: 30
--- !u!1 &434999704 --- !u!1 &434999704
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2416,6 +2430,37 @@ Transform:
m_Father: {fileID: 1510915030} m_Father: {fileID: 1510915030}
m_RootOrder: 6 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &588278527
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 588278528}
m_Layer: 9
m_Name: L Con
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &588278528
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 588278527}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.12, y: -0.25, z: -0.217}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1542691186}
m_Father: {fileID: 416451006}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &611823981 --- !u!1 &611823981
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3982,7 +4027,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 9 m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &950738597 --- !u!1 &950738597
GameObject: GameObject:
@ -5920,7 +5965,7 @@ MeshRenderer:
m_RenderingLayerMask: 1 m_RenderingLayerMask: 1
m_RendererPriority: 0 m_RendererPriority: 0
m_Materials: m_Materials:
- {fileID: 2100000, guid: bb5f41eecb5ccc546814746a66914984, type: 2} - {fileID: 2100000, guid: d584c93390323c84cbdb0665a4a3721a, type: 2}
m_StaticBatchInfo: m_StaticBatchInfo:
firstSubMesh: 0 firstSubMesh: 0
subMeshCount: 0 subMeshCount: 0
@ -6827,7 +6872,7 @@ Transform:
- {fileID: 580349063} - {fileID: 580349063}
- {fileID: 2101684220} - {fileID: 2101684220}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &1510915031 --- !u!82 &1510915031
AudioSource: AudioSource:
@ -7002,6 +7047,83 @@ MeshFilter:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1518462474} m_GameObject: {fileID: 1518462474}
m_Mesh: {fileID: 4300022, guid: 1cc1b125262248c4ba967763bf40c861, type: 3} m_Mesh: {fileID: 4300022, guid: 1cc1b125262248c4ba967763bf40c861, type: 3}
--- !u!1 &1542691185
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1542691186}
- component: {fileID: 1542691188}
- component: {fileID: 1542691187}
m_Layer: 9
m_Name: Mesh
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1542691186
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542691185}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.016666668, y: 0.016666668, z: 0.016666668}
m_Children: []
m_Father: {fileID: 588278528}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1542691187
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542691185}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: d584c93390323c84cbdb0665a4a3721a, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1542691188
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1542691185}
m_Mesh: {fileID: 4300096, guid: 1cc1b125262248c4ba967763bf40c861, type: 3}
--- !u!1 &1554483891 --- !u!1 &1554483891
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -7310,7 +7432,7 @@ Transform:
- {fileID: 950738598} - {fileID: 950738598}
- {fileID: 662602231} - {fileID: 662602231}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 11 m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1643476466 --- !u!1 &1643476466
GameObject: GameObject:
@ -7696,8 +7818,9 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 351576464} - {fileID: 351576464}
- {fileID: 114864359}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1821719418 --- !u!1 &1821719418
GameObject: GameObject:
@ -7823,7 +7946,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1825209466 --- !u!1 &1825209466
GameObject: GameObject:
@ -8546,7 +8669,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 10 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &2081994160 --- !u!82 &2081994160
AudioSource: AudioSource:

View file

@ -1,3 +1,4 @@
using System;
using UnityEngine; using UnityEngine;
using UnityEngine.XR; using UnityEngine.XR;
@ -7,7 +8,7 @@ public class Rig : MonoBehaviour
public Design design; public Design design;
public Main main; public Main main;
public GameObject disconnected; public GameObject disconnected;
public Transform head, con, hangingRod; public Transform head, con, lCon, hangingRod;
public Camera recordCam; public Camera recordCam;
[Header("Variables")] [Header("Variables")]
@ -34,6 +35,9 @@ public class Rig : MonoBehaviour
recordCam.gameObject.SetActive(Application.isEditor); recordCam.gameObject.SetActive(Application.isEditor);
} }
Quaternion flipRot = Quaternion.identity;
float flipEuler = 180;
public Lerper lerper;
void Update() void Update()
{ {
// Input System // Input System
@ -58,16 +62,33 @@ public class Rig : MonoBehaviour
} }
// Apply to Transforms // Apply to Transforms
Quaternion flip = Quaternion.identity;
head.localPosition = InputTracking.GetLocalPosition(XRNode.Head); head.localPosition = InputTracking.GetLocalPosition(XRNode.Head);
head.localRotation = InputTracking.GetLocalRotation(XRNode.Head); head.localRotation = InputTracking.GetLocalRotation(XRNode.Head);
con.localPosition = InputTracking.GetLocalPosition(XRNode.RightHand); con.localPosition = InputTracking.GetLocalPosition(XRNode.RightHand);
con.localRotation = InputTracking.GetLocalRotation(XRNode.RightHand); con.localRotation = InputTracking.GetLocalRotation(XRNode.RightHand);
lCon.localPosition = InputTracking.GetLocalPosition(XRNode.LeftHand);
lCon.localRotation = InputTracking.GetLocalRotation(XRNode.LeftHand);
// °inview // °inview
if (OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger, ovrCon))
{
flipEuler *= -1;
lerper.t *= -1;
}
transform.localScale = Vector3.one * design.scale; transform.localScale = Vector3.one * design.scale;
transform.position = -head.localPosition * design.scale; Quaternion targetRot = Quaternion.Euler(0, flipEuler, 0);
if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, ovrCon))
{
lerper.Update(1);
}
else
{
lerper.Update(0);
}
flipRot = Quaternion.SlerpUnclamped(Quaternion.identity, targetRot, lerper.t);
transform.rotation = flipRot;
transform.position = flipRot * -head.localPosition * design.scale;
transform.position += design.pivotPos + (head.rotation * headOffset); transform.position += design.pivotPos + (head.rotation * headOffset);
// Shake // Shake
@ -88,51 +109,39 @@ public class Rig : MonoBehaviour
recordCam.transform.rotation = Quaternion.LookRotation(-recPos); recordCam.transform.rotation = Quaternion.LookRotation(-recPos);
} }
// Input Rotation // °fullrot
// Vector3 headsetPos = InputTracking.GetLocalPosition(XRNode.Head);
// controllerPos = OVRInput.GetLocalControllerPosition(remote) * design.scale;
// controllerPos = controllerPos - headsetPos * design.scale;
// controllerPos += head.position;
// inputRot = controllerRot = OVRInput.GetLocalControllerRotation(remote); // inputRot = controllerRot = OVRInput.GetLocalControllerRotation(remote);
// joystick = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, remote);
// joystick = new Vector3(joystick.x, 0, joystick.y);
// if (joystick.sqrMagnitude > 0)
// {
// inputRot *= Quaternion.LookRotation(joystick);
// }
// Ignoring current implementation // point & swipe swap/choose
if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, ovrCon)) // both hands? (nah makes point the odd one out)
{ // HOW TO FILTER OUT THE SPIN CHAIR VEL? (LCON? NAH... BUT MIGHT BE GOOD FOR TESTINGs)
pullFrom = con.localPosition; // flip view? what about 90/45 degree snaps ( or drag view!? )
} // all oculus bs pulled filtered through a single file
// menu system cull
// PRIORITY
// starting scene! the sooner the better ( break things! )
// refactor like vader life alyx!
// °dragdir
Vector3 conVel = flipRot * (con.localPosition - oldConPos) / Time.deltaTime;
OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.RTouch);
if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, ovrCon)) if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, ovrCon))
{ {
pull = con.localPosition - pullFrom; if (conVel.magnitude > 0.05f)
if (pull.magnitude > 0.025f / 3)
{ {
rawDir = pull.normalized; OVRInput.SetControllerVibration(1, 0.1f, OVRInput.Controller.RTouch);
} }
// DRAG PIVOT rawDir = (rawDir + conVel * Time.deltaTime * 30).normalized;
pull = Vector3.ClampMagnitude(pull, 0.025f);
pullFrom = con.localPosition - pull;
} }
inputRot = Quaternion.LookRotation(rawDir); inputRot = Quaternion.LookRotation(rawDir);
oldConPos = con.localPosition;
// visualize
pullLine.SetPosition(0, transform.TransformPoint(pullFrom));
pullLine.SetPosition(1, transform.TransformPoint(pullFrom + pull));
} }
Vector3 oldConPos;
Vector3 rawDir = Vector3.forward; Vector3 rawDir = Vector3.forward;
Vector3 pullFrom, pull;
public LineRenderer pullLine;
public Vector3Int InputDirection(Main main) public Vector3Int InputDirection(Main main)
{ {
@ -151,4 +160,42 @@ public class Rig : MonoBehaviour
{ {
boxShake -= dir; boxShake -= dir;
} }
} }
[Serializable]
public class Lerper
{
public float t = 0;
public float spring = 1;
public float dampen = 1;
float vel;
public void Update(float to = 1, bool bounce = false)
{
float dir = to - t;
vel += dir * spring * Time.deltaTime;
if (Mathf.Sign(vel) != Mathf.Sign(dir))
{
vel *= 1 - (dampen * Time.deltaTime);
}
else
{
vel *= 1 - (dampen * 0.33f * Time.deltaTime);
}
float newt = t + vel * Time.deltaTime;
if (bounce && (newt < 0 || newt > 1))
{
vel *= -0.5f;
newt = Mathf.Clamp01(newt);
}
t = newt;
}
public void Reset()
{
t = vel = 0;
}
}