Skip to content

Commit 2e332d1

Browse files
authored
Asymmetrical Sample Apartment (#25)
* Fix Browser to send and recieve Mouse and Keyboard data * Add Camera Controls for Better Asym Control * Add Null Check * Update Tracked Alias in Bow Sample * Shrink Display Res and Make Input Non Static * Shirk Default Stream Size * Add Apartment Sample and Update Change and Project files * Adding Unity Versions to README & Cloud Docs * Add Apartment Sample to README
1 parent 2b24c98 commit 2e332d1

File tree

184 files changed

+16553
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+16553
-23
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@ All notable changes to com.unity.renderstreaming package will be documented in t
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.5.1] - 2021-09-20
8+
9+
### Added
10+
11+
- Added a **NEW** Sample : Asymmetrical Apartment for testing asymmetrical multiplayer
12+
- Add CameraControls.cs to allow for the Camera to be controlled in 2D experiences
13+
- Added Supported Versions to README : https://github.com/FusedVR/VRStreaming/issues/24
14+
- Added enableKeyboardTouchControls to VRInputManager to control whether to use Camera Controls
15+
16+
### Changed
17+
18+
- Fixed HDRPVR Sample to reference correct Render Streaming Prefab
19+
- Fixed Mouse & Camera Input from the Web Client to be correctly sent to Unity SDK using RemoteInput class
20+
- Removed WebXR controls from client and instead send input to be handled by server
21+
- Fixed Overriding Prefab Positional & Rotational Data : https://github.com/FusedVR/VRStreaming/issues/19
22+
- Rotation from headset is applied in local rotation instead of global rotation
23+
24+
725
## [0.5.0] - 2021-09-13
826

927
### Added

Images~/apartment.png

3.54 MB
Loading

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ For an overview of this package, please refer to this video tutorial on the Fuse
2020
5. On the Browser, click "**Connect to Cloud VR Streaming Server**"
2121
6. Once you see the video feed, click "**Enter Virtual Reality**"
2222

23+
# Unity Versions
24+
25+
Tested & Verfied with Unity 2019.4 LTS. Limited testing has been done with Unity 2020.3 LTS and seems to be working as intended there as well.
26+
27+
Please also refer to [Unity Render Streaming](https://github.com/Unity-Technologies/UnityRenderStreaming) for their list of supported Unity versions.
28+
2329
# Configurations
2430

2531
On the **Render Streaming Service** Game Object, there are a few configuration options to make it easier to customize your Render Streaming Game.
@@ -40,7 +46,10 @@ At this time, the WebXR Client sends the resolution required to render per eye b
4046

4147
# Cloud Support
4248

43-
Limited testing and Proof of Concepts have been done with deploying a standalone version of the Unity Render Streaming app onto a Cloud or Edge Service provider via either a Windows or Ubuntu Virtual Machine. More testing is required to be done to enable this support.
49+
This project has been tested to work on AWS EC2 leveraging Nvidia's Gaming AMIs. See the following videos for documentation on how to setup your Unity VR Streaming project and get it deployed on the Cloud.
50+
51+
- Windows Server with Tesla T4 GPU Accelerated Graphics : https://youtu.be/UFsbQ8YlboU
52+
- Ubuntu 18.04 with Tesla T4 GPU Accelerated Graphics : https://youtu.be/3p0tzqD-s-c
4453

4554
# GPU Recommendations
4655

@@ -50,14 +59,14 @@ It is strongly recommended to utlize a NVIDIA GPU as these GPUs support Hardware
5059

5160
Controller Input is captured via the [A-Frame Tracked-Controls component](https://aframe.io/docs/1.2.0/components/tracked-controls.html) and then sent over the data channel to the Unity SDK. This data protocol is adapted from the Unity Broadcast system, which was also capable of sending Keyboard, Mouse, Touch, and Gamepad data back to Unity via the RemoteInput.cs script in Unity. As such, VR data is sent from the client to Unity as Data Array buffers, defined in bytes.
5261

53-
The first byte of the data Array Byffer refers to the input mode to determine how to parse the data as an id. The following IDs were reservered for Web Input by the Unity Render Streaming system.
62+
The first byte of the data Array Byffer refers to the input mode to determine how to parse the data as an id. The following IDs were reservered for Web Input by the Unity Render Streaming system and integrated with their Remote Input class.
5463

5564
- ID 0 = Keyboard
5665
- ID 1 = Mouse
5766
- ID 2 = MouseWheel
5867
- ID 3 = Touch
5968
- ID 4 = UI (legacy)
60-
- ID 5 = Gamepad
69+
- ID 5 = Gamepad (currently not implemented)
6170

6271
ID 6 is used for all WebXR Input specific to VR. Within VR Input, we specify 3 different modes for sending data, which are:
6372
- ID 0 = Positional and Rotational Data of the Headset and Hands
@@ -99,10 +108,17 @@ The first one uses the Unity HDRP Built In Template to show case streaming a sce
99108

100109
![High Definition Render Pipeline](https://raw.githubusercontent.com/FusedVR/VRStreaming/master/Images~/hdrpvr.png)
101110

102-
The second provided sample shows integration with [VRTK](https://www.vrtk.io/) to showcase how to utilize the input that is streamed from the WebXR client into Unity. Using this input, we can build an Archery Sandbox. Simmply pick up the bow and then grab arrows from behind your back to begin shooting. Please note that to you use this sample you will need to manually also import the following [VRTK Tilia Packages](https://www.vrtk.io/tilia.html):
111+
The second provided sample shows integration with [VRTK](https://www.vrtk.io/) to showcase how to utilize the input that is streamed from the WebXR client into Unity. Using this input, we can build an Archery Sandbox. Simply pick up the bow and then grab arrows from behind your back to begin shooting. Please note that to you use this sample you will need to manually also import the following [VRTK Tilia Packages](https://www.vrtk.io/tilia.html):
103112

104113
- **io.extendreality.tilia.camerarigs.trackedalias.unity**
105114
- **io.extendreality.tilia.interactions.interactables.unity**
106115
- **io.extendreality.tilia.interactions.snapzone.unity**
107116

108117
![VRTK Archery](https://raw.githubusercontent.com/FusedVR/VRStreaming/master/Images~/archery-sample.png)
118+
119+
The third provided sample shows an example of creating a asymmetrical multiplayer experience, where up to 4 users can enter the application either in VR or in 2D as a laptop or mobile user to view an apartment. VR users will be able to teleport around using the enabled [VRTK](https://www.vrtk.io/) integration. Please note that to you use this sample you will need to manually also import the following [VRTK Tilia Packages](https://www.vrtk.io/tilia.html):
120+
121+
- **io.extendreality.tilia.locomotors.teleporter.unity**
122+
- **io.extendreality.tilia.indicators.objectpointers.unity**
123+
124+
![Apartment](https://raw.githubusercontent.com/FusedVR/VRStreaming/master/Images~/apartment.png)

Runtime/FusedVR.Streaming.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "FusedVR.Streaming",
33
"references": [
44
"GUID:40a5acf76f04c4c8ebb69605e4b0d5c7",
5-
"GUID:f12aafacab75a87499e7e45c873ffab8"
5+
"GUID:f12aafacab75a87499e7e45c873ffab8",
6+
"GUID:75469ad4d38634e559750d17036d5f7c"
67
],
78
"includePlatforms": [],
89
"excludePlatforms": [],

Runtime/Prefabs/Render Streaming Service.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ MonoBehaviour:
7272
gameID:
7373
maxConnections: 1
7474
playerPrefabs:
75-
- {fileID: 3432969078835647384, guid: 234ee74f5f05b9541850ec55278bb3f5, type: 3}
75+
- {fileID: 1305806924054047947, guid: 234ee74f5f05b9541850ec55278bb3f5, type: 3}

Runtime/Prefabs/WebXR Streamer.prefab

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ MonoBehaviour:
8787
m_Script: {fileID: 11500000, guid: 88dc1ef0a0e7d1b4a897f095b852ab38, type: 3}
8888
m_Name:
8989
m_EditorClassIdentifier:
90-
streamingSize: {x: 1350, y: 1500}
90+
streamingSize: {x: 972, y: 1080}
9191
cameras:
9292
- {fileID: 7977754495293142443}
9393
depth: 0
@@ -154,7 +154,7 @@ GameObject:
154154
serializedVersion: 6
155155
m_Component:
156156
- component: {fileID: 7977754496362167397}
157-
- component: {fileID: 3432969078835647384}
157+
- component: {fileID: 1305806924054047947}
158158
- component: {fileID: 7977754496362167396}
159159
- component: {fileID: 8526365356649225057}
160160
m_Layer: 0
@@ -171,7 +171,7 @@ Transform:
171171
m_PrefabInstance: {fileID: 0}
172172
m_PrefabAsset: {fileID: 0}
173173
m_GameObject: {fileID: 7977754496362167402}
174-
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
174+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
175175
m_LocalPosition: {x: 0, y: 0, z: 0}
176176
m_LocalScale: {x: 1, y: 1, z: 1}
177177
m_Children:
@@ -181,7 +181,7 @@ Transform:
181181
m_Father: {fileID: 0}
182182
m_RootOrder: 0
183183
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
184-
--- !u!114 &3432969078835647384
184+
--- !u!114 &1305806924054047947
185185
MonoBehaviour:
186186
m_ObjectHideFlags: 0
187187
m_CorrespondingSourceObject: {fileID: 0}
@@ -212,6 +212,7 @@ MonoBehaviour:
212212
m_EditorClassIdentifier:
213213
local: 0
214214
label:
215+
enableKeyboardTouchControls: 1
215216
VRCameras: {fileID: 0}
216217
VRPoseEvent:
217218
m_PersistentCalls:
@@ -401,7 +402,7 @@ MonoBehaviour:
401402
m_Script: {fileID: 11500000, guid: 88dc1ef0a0e7d1b4a897f095b852ab38, type: 3}
402403
m_Name:
403404
m_EditorClassIdentifier:
404-
streamingSize: {x: 1350, y: 1500}
405+
streamingSize: {x: 972, y: 1080}
405406
cameras:
406407
- {fileID: 7977754496754579055}
407408
depth: 0

Runtime/Scripts/ApplyVRData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void ApplyData(VRInputManager.Source id, Vector3 position, Quaternion rot
2828
if (index == id) //check if the data is from the correct source
2929
{
3030
transform.localPosition = new Vector3(position.x, position.y, -position.z); //note that z data is reversed on WebXR
31-
transform.rotation = rotation; //apply rotation - note coordinate system change was already applied
31+
transform.localRotation = rotation; //apply rotation - note coordinate system change was already applied
3232
}
3333
}
3434
}

Runtime/Scripts/CameraControls.cs

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
using UnityEngine;
2+
using UnityEngine.InputSystem;
3+
4+
namespace FusedVR.VRStreaming {
5+
6+
/// <summary>
7+
/// Fly Camera Writen by Windexglow 11-13-10. And Modified for usage with VR Render Streaming
8+
/// Original Source : https://gist.github.com/gunderson/d7f096bd07874f31671306318019d996
9+
/// </summary>
10+
public class CameraControls : MonoBehaviour {
11+
12+
#region Public Properties
13+
public float mainSpeed = 10.0f; // Regular speed
14+
public float shiftAdd = 25.0f; // Amount to accelerate when shift is pressed
15+
public float maxShift = 100.0f; // Maximum speed when holding shift
16+
public float camSens = 0.15f; // Mouse sensitivity
17+
#endregion
18+
19+
#region Private Properties
20+
private Mouse myMouse; // This Controllers Mouse Input
21+
private Touchscreen myTouch; // This Controllers Touch Input
22+
private Keyboard myKeyboard; // This Controllers Keyboard Input
23+
24+
private Pointer lastPointer; // For Mouse / Touch Input, what pointer was used last
25+
private Vector2 lastPointerPosition = Vector2.zero; // The last position of the pointer
26+
private bool isFirstPress = true; // whether the pointer has been previously pressed in the prior frame
27+
private float totalRun = 1.0f; // speed control for the camera
28+
#endregion
29+
30+
#region Public Methods
31+
/// <summary>
32+
/// Add a Unity Input Device (Mouse, Touch, Keyboard) to this controller to be used for Camera Controls
33+
/// Used in the VR Input Manager to assign devices
34+
/// </summary>
35+
public void AddDevice(InputDevice device) {
36+
switch (device) {
37+
case Mouse mouse:
38+
myMouse = mouse;
39+
lastPointer = myMouse;
40+
break;
41+
case Keyboard keyboard:
42+
myKeyboard = keyboard;
43+
break;
44+
case Touchscreen touch:
45+
myTouch = touch;
46+
lastPointer = myTouch;
47+
break;
48+
}
49+
}
50+
51+
/// <summary>
52+
/// Reset and Remove all Devices that have prior assigned
53+
/// Used in the VR Input Manager to remove devices for the camera control on disconnect
54+
/// </summary>
55+
public void RemoveDevices() {
56+
myMouse = null;
57+
myKeyboard = null;
58+
myTouch = null;
59+
lastPointer = null;
60+
}
61+
#endregion
62+
63+
#region Camera Controls
64+
void Update() {
65+
// Mouse camera angle
66+
if (myMouse != null && myMouse.leftButton.isPressed) {
67+
if (isFirstPress) {
68+
lastPointerPosition = myMouse.position.ReadValue();
69+
isFirstPress = false;
70+
}
71+
72+
UpdateMouseTouch(myMouse.position.ReadValue());
73+
} else if (myTouch != null && myTouch.primaryTouch.press.isPressed ) {
74+
if (isFirstPress) {
75+
lastPointerPosition = myTouch.primaryTouch.position.ReadValue();
76+
isFirstPress = false;
77+
}
78+
79+
UpdateMouseTouch(myTouch.primaryTouch.position.ReadValue());
80+
} else {
81+
isFirstPress = true;
82+
}
83+
84+
// Keyboard commands
85+
Vector3 p = GetBaseInput();
86+
87+
if ( myKeyboard != null && myKeyboard.leftShiftKey.isPressed ) {
88+
totalRun += Time.deltaTime;
89+
p *= totalRun * shiftAdd;
90+
p.x = Mathf.Clamp(p.x, -maxShift, maxShift);
91+
p.y = Mathf.Clamp(p.y, -maxShift, maxShift);
92+
p.z = Mathf.Clamp(p.z, -maxShift, maxShift);
93+
} else {
94+
totalRun = Mathf.Clamp(totalRun * 0.5f, 1f, 1000f);
95+
p *= mainSpeed;
96+
}
97+
98+
p *= Time.deltaTime;
99+
transform.Translate(p);
100+
}
101+
102+
// Updates the Rotation based on the Mouse 2D Position
103+
void UpdateMouseTouch(Vector2 position) {
104+
Vector3 delta = position - lastPointerPosition;
105+
delta = new Vector3(-delta.y * camSens, delta.x * camSens, 0);
106+
delta = new Vector3(transform.eulerAngles.x + delta.x, transform.eulerAngles.y + delta.y, 0);
107+
transform.eulerAngles = delta;
108+
109+
lastPointerPosition = position;
110+
}
111+
112+
// Returns the basic values, if it's 0 than it's not active.
113+
private Vector3 GetBaseInput() {
114+
if (myKeyboard == null) {
115+
return Vector3.zero;
116+
}
117+
118+
Vector3 p_Velocity = new Vector3();
119+
120+
// Forwards
121+
if (myKeyboard.wKey.isPressed)
122+
p_Velocity += new Vector3(0, 0, 1);
123+
124+
// Backwards
125+
if (myKeyboard.sKey.isPressed)
126+
p_Velocity += new Vector3(0, 0, -1);
127+
128+
// Left
129+
if (myKeyboard.aKey.isPressed)
130+
p_Velocity += new Vector3(-1, 0, 0);
131+
132+
// Right
133+
if (myKeyboard.dKey.isPressed)
134+
p_Velocity += new Vector3(1, 0, 0);
135+
136+
// Up
137+
if (myKeyboard.spaceKey.isPressed)
138+
p_Velocity += new Vector3(0, 1, 0);
139+
140+
// Down
141+
if (myKeyboard.leftCtrlKey.isPressed)
142+
p_Velocity += new Vector3(0, -1, 0);
143+
144+
return p_Velocity;
145+
}
146+
#endregion
147+
148+
}
149+
}

Runtime/Scripts/CameraControls.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.

Runtime/Scripts/ControllerInputManager.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace FusedVR.VRStreaming
1717
/// The manager class for Controller Input Data i.e. Trigger, Grips Pressed, etc.
1818
/// This class provides an abstraction over the raw data ControllerDataEvent from VRInputManager
1919
/// </summary>
20+
[RequireComponent(typeof(VRInputManager))]
2021
public class ControllerInputManager : MonoBehaviour
2122
{
2223
#region Enums
@@ -71,18 +72,21 @@ public class VRAxisData : UnityEvent<Hand, Button, float, float> {
7172
public VRAxisData VRAxisEvent;
7273
#endregion
7374

75+
private VRInputManager input; // handles recieving the data
76+
7477
#region Methods
7578
// Start is called before the first frame update
7679
void Start()
7780
{
78-
VRInputManager.ButtonDataEvent += ButtonEvents; //start listening
79-
VRInputManager.AxisDataEvent += AxisEvents; //start listening
81+
input = GetComponent<VRInputManager>();
82+
input.ButtonDataEvent += ButtonEvents; //start listening
83+
input.AxisDataEvent += AxisEvents; //start listening
8084
}
8185

8286
// OnDestroy is called when the game object is about to be destroyed in the scene
8387
private void OnDestroy() {
84-
VRInputManager.ButtonDataEvent -= ButtonEvents; //end listening
85-
VRInputManager.AxisDataEvent -= AxisEvents; //end listening
88+
input.ButtonDataEvent -= ButtonEvents; //end listening
89+
input.AxisDataEvent -= AxisEvents; //end listening
8690
}
8791

8892
/// <summary>

0 commit comments

Comments
 (0)