Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit b3ac5ee

Browse files
authored
Merge pull request #342 from caseyyee/view-vector-zero
Updates for next release
2 parents fe01f89 + 24d676b commit b3ac5ee

12 files changed

+110
-156
lines changed

Assets/WebVR/Prefabs/WebVRCameraSet.prefab

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,10 +1510,10 @@ MonoBehaviour:
15101510
m_Name:
15111511
m_EditorClassIdentifier:
15121512
toggleVRKeyName: v
1513-
vrState: 1
15141513
dontDestroyOnLoad: 1
15151514
DefaultHeight: 1.2
15161515
TrackingSpace: 1
1516+
vrState: 1
15171517
--- !u!114 &114104781069495054
15181518
MonoBehaviour:
15191519
m_ObjectHideFlags: 1
@@ -1543,28 +1543,8 @@ MonoBehaviour:
15431543
hand: 1
15441544
inputMap: {fileID: 11400000, guid: b249a0801fba0f74198588a3ecb37bbe, type: 2}
15451545
simulate3dof: 0
1546-
controllerOffset: {x: -0.15, y: -0.3, z: 0.4}
1547-
isActive: 0
1548-
index: 0
1549-
position: {x: 0, y: 0, z: 0}
1550-
rotation: {x: 0, y: 0, z: 0, w: 0}
1551-
sitStand:
1552-
e00: 0
1553-
e01: 0
1554-
e02: 0
1555-
e03: 0
1556-
e10: 0
1557-
e11: 0
1558-
e12: 0
1559-
e13: 0
1560-
e20: 0
1561-
e21: 0
1562-
e22: 0
1563-
e23: 0
1564-
e30: 0
1565-
e31: 0
1566-
e32: 0
1567-
e33: 0
1546+
eyesToElbow: {x: 0.1, y: -0.4, z: 0.15}
1547+
elbowHand: {x: 0, y: 0, z: 0.25}
15681548
--- !u!114 &114243127810226890
15691549
MonoBehaviour:
15701550
m_ObjectHideFlags: 1
@@ -1601,28 +1581,8 @@ MonoBehaviour:
16011581
hand: 2
16021582
inputMap: {fileID: 11400000, guid: a760722b59f73e94287ddd9ffc44440f, type: 2}
16031583
simulate3dof: 0
1604-
controllerOffset: {x: 0.15, y: -0.3, z: 0.4}
1605-
isActive: 0
1606-
index: 0
1607-
position: {x: 0, y: 0, z: 0}
1608-
rotation: {x: 0, y: 0, z: 0, w: 0}
1609-
sitStand:
1610-
e00: 0
1611-
e01: 0
1612-
e02: 0
1613-
e03: 0
1614-
e10: 0
1615-
e11: 0
1616-
e12: 0
1617-
e13: 0
1618-
e20: 0
1619-
e21: 0
1620-
e22: 0
1621-
e23: 0
1622-
e30: 0
1623-
e31: 0
1624-
e32: 0
1625-
e33: 0
1584+
eyesToElbow: {x: 0.1, y: -0.4, z: 0.15}
1585+
elbowHand: {x: 0, y: 0, z: 0.25}
16261586
--- !u!114 &114589835210473740
16271587
MonoBehaviour:
16281588
m_ObjectHideFlags: 1

Assets/WebVR/Scripts/WebVRCamera.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
using UnityEngine;
2+
using UnityEngine.XR;
23
using System.Linq;
34
using System.Collections;
45
using System.Runtime.InteropServices;
56

67
public class WebVRCamera : MonoBehaviour
78
{
8-
private Matrix4x4 sitStand;
9-
109
private Camera cameraMain, cameraL, cameraR;
1110
private bool vrActive = false;
1211

Assets/WebVR/Scripts/WebVRController.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,7 @@ public class WebVRController : MonoBehaviour
3535
public Vector3 eyesToElbow = new Vector3(0.1f, -0.4f, 0.15f);
3636
[Tooltip("Vector from elbow to hand")]
3737
public Vector3 elbowHand = new Vector3(0, 0, 0.25f);
38-
[HideInInspector]
39-
public bool isActive = false;
40-
[HideInInspector]
41-
public int index;
42-
[HideInInspector]
43-
public Vector3 position;
44-
[HideInInspector]
45-
public Quaternion rotation;
46-
[HideInInspector]
47-
public Matrix4x4 sitStand;
38+
private Matrix4x4 sitStand;
4839
private float[] axes;
4940

5041
private XRNode handNode;
@@ -183,6 +174,7 @@ private void onHeadsetUpdate(Matrix4x4 leftProjectionMatrix,
183174
Matrix4x4 trs = WebVRMatrixUtil.TransformViewMatrixToTRS(leftViewMatrix);
184175
this.headRotation = WebVRMatrixUtil.GetRotationFromMatrix(trs);
185176
this.headPosition = WebVRMatrixUtil.GetTranslationFromMatrix(trs);
177+
this.sitStand = sitStandMatrix;
186178
}
187179

188180
private void onControllerUpdate(string id,
@@ -194,26 +186,25 @@ private void onControllerUpdate(string id,
194186
Vector3 position,
195187
Vector3 linearAcceleration,
196188
Vector3 linearVelocity,
197-
Matrix4x4 sitStand,
198189
WebVRControllerButton[] buttonValues,
199190
float[] axesValues)
200191
{
201192
if (handFromString(handValue) == hand)
202193
{
203194
SetVisible(true);
204195

205-
Quaternion sitStandRotation = WebVRMatrixUtil.GetRotationFromMatrix(sitStand);
196+
Quaternion sitStandRotation = WebVRMatrixUtil.GetRotationFromMatrix(this.sitStand);
206197
Quaternion rotation = sitStandRotation * orientation;
207198

208199
if (!hasPosition || this.simulate3dof) {
209200
position = applyArmModel(
210-
sitStand.MultiplyPoint(this.headPosition),
201+
this.sitStand.MultiplyPoint(this.headPosition),
211202
rotation,
212203
this.headRotation);
213204
}
214205
else
215206
{
216-
position = sitStand.MultiplyPoint(position);
207+
position = this.sitStand.MultiplyPoint(position);
217208
}
218209

219210
transform.rotation = rotation;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using UnityEngine;
2+
3+
[System.Serializable]
4+
class WebVRControllerData
5+
{
6+
public string id = null;
7+
public int index = 0;
8+
public string hand = null;
9+
public bool hasOrientation = false;
10+
public bool hasPosition = false;
11+
public float[] orientation = null;
12+
public float[] position = null;
13+
public float[] linearAcceleration = null;
14+
public float[] linearVelocity = null;
15+
public float[] axes = null;
16+
public WebVRControllerButton[] buttons = new WebVRControllerButton[0];
17+
}

Assets/WebVR/Scripts/WebVRControllerData.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/WebVR/Scripts/WebVRData.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using UnityEngine;
2+
3+
// WebVR data class
4+
[System.Serializable]
5+
class WebVRData
6+
{
7+
public WebVRControllerData[] controllers = new WebVRControllerData[0];
8+
public static WebVRData CreateFromJSON(string jsonString)
9+
{
10+
return JsonUtility.FromJson<WebVRData> (jsonString);
11+
}
12+
}

Assets/WebVR/Scripts/WebVRData.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)