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

Commit

Permalink
Merge pull request #342 from caseyyee/view-vector-zero
Browse files Browse the repository at this point in the history
Updates for next release
  • Loading branch information
caseyyee authored Sep 19, 2018
2 parents fe01f89 + 24d676b commit b3ac5ee
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 156 deletions.
50 changes: 5 additions & 45 deletions Assets/WebVR/Prefabs/WebVRCameraSet.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1510,10 +1510,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
toggleVRKeyName: v
vrState: 1
dontDestroyOnLoad: 1
DefaultHeight: 1.2
TrackingSpace: 1
vrState: 1
--- !u!114 &114104781069495054
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -1543,28 +1543,8 @@ MonoBehaviour:
hand: 1
inputMap: {fileID: 11400000, guid: b249a0801fba0f74198588a3ecb37bbe, type: 2}
simulate3dof: 0
controllerOffset: {x: -0.15, y: -0.3, z: 0.4}
isActive: 0
index: 0
position: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 0, z: 0, w: 0}
sitStand:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
eyesToElbow: {x: 0.1, y: -0.4, z: 0.15}
elbowHand: {x: 0, y: 0, z: 0.25}
--- !u!114 &114243127810226890
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -1601,28 +1581,8 @@ MonoBehaviour:
hand: 2
inputMap: {fileID: 11400000, guid: a760722b59f73e94287ddd9ffc44440f, type: 2}
simulate3dof: 0
controllerOffset: {x: 0.15, y: -0.3, z: 0.4}
isActive: 0
index: 0
position: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 0, z: 0, w: 0}
sitStand:
e00: 0
e01: 0
e02: 0
e03: 0
e10: 0
e11: 0
e12: 0
e13: 0
e20: 0
e21: 0
e22: 0
e23: 0
e30: 0
e31: 0
e32: 0
e33: 0
eyesToElbow: {x: 0.1, y: -0.4, z: 0.15}
elbowHand: {x: 0, y: 0, z: 0.25}
--- !u!114 &114589835210473740
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down
3 changes: 1 addition & 2 deletions Assets/WebVR/Scripts/WebVRCamera.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using UnityEngine;
using UnityEngine.XR;
using System.Linq;
using System.Collections;
using System.Runtime.InteropServices;

public class WebVRCamera : MonoBehaviour
{
private Matrix4x4 sitStand;

private Camera cameraMain, cameraL, cameraR;
private bool vrActive = false;

Expand Down
19 changes: 5 additions & 14 deletions Assets/WebVR/Scripts/WebVRController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ public class WebVRController : MonoBehaviour
public Vector3 eyesToElbow = new Vector3(0.1f, -0.4f, 0.15f);
[Tooltip("Vector from elbow to hand")]
public Vector3 elbowHand = new Vector3(0, 0, 0.25f);
[HideInInspector]
public bool isActive = false;
[HideInInspector]
public int index;
[HideInInspector]
public Vector3 position;
[HideInInspector]
public Quaternion rotation;
[HideInInspector]
public Matrix4x4 sitStand;
private Matrix4x4 sitStand;
private float[] axes;

private XRNode handNode;
Expand Down Expand Up @@ -183,6 +174,7 @@ private void onHeadsetUpdate(Matrix4x4 leftProjectionMatrix,
Matrix4x4 trs = WebVRMatrixUtil.TransformViewMatrixToTRS(leftViewMatrix);
this.headRotation = WebVRMatrixUtil.GetRotationFromMatrix(trs);
this.headPosition = WebVRMatrixUtil.GetTranslationFromMatrix(trs);
this.sitStand = sitStandMatrix;
}

private void onControllerUpdate(string id,
Expand All @@ -194,26 +186,25 @@ private void onControllerUpdate(string id,
Vector3 position,
Vector3 linearAcceleration,
Vector3 linearVelocity,
Matrix4x4 sitStand,
WebVRControllerButton[] buttonValues,
float[] axesValues)
{
if (handFromString(handValue) == hand)
{
SetVisible(true);

Quaternion sitStandRotation = WebVRMatrixUtil.GetRotationFromMatrix(sitStand);
Quaternion sitStandRotation = WebVRMatrixUtil.GetRotationFromMatrix(this.sitStand);
Quaternion rotation = sitStandRotation * orientation;

if (!hasPosition || this.simulate3dof) {
position = applyArmModel(
sitStand.MultiplyPoint(this.headPosition),
this.sitStand.MultiplyPoint(this.headPosition),
rotation,
this.headRotation);
}
else
{
position = sitStand.MultiplyPoint(position);
position = this.sitStand.MultiplyPoint(position);
}

transform.rotation = rotation;
Expand Down
17 changes: 17 additions & 0 deletions Assets/WebVR/Scripts/WebVRControllerData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using UnityEngine;

[System.Serializable]
class WebVRControllerData
{
public string id = null;
public int index = 0;
public string hand = null;
public bool hasOrientation = false;
public bool hasPosition = false;
public float[] orientation = null;
public float[] position = null;
public float[] linearAcceleration = null;
public float[] linearVelocity = null;
public float[] axes = null;
public WebVRControllerButton[] buttons = new WebVRControllerButton[0];
}
11 changes: 11 additions & 0 deletions Assets/WebVR/Scripts/WebVRControllerData.cs.meta

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

12 changes: 12 additions & 0 deletions Assets/WebVR/Scripts/WebVRData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

// WebVR data class
[System.Serializable]
class WebVRData
{
public WebVRControllerData[] controllers = new WebVRControllerData[0];
public static WebVRData CreateFromJSON(string jsonString)
{
return JsonUtility.FromJson<WebVRData> (jsonString);
}
}
11 changes: 11 additions & 0 deletions Assets/WebVR/Scripts/WebVRData.cs.meta

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

Loading

0 comments on commit b3ac5ee

Please sign in to comment.