Skip to content

Commit 0b9af8b

Browse files
authored
VRTK Sample (#3)
* VRTK Archery Bow & Arrow * Updated Quaternion Data from Client * Add Images and Update ReadME
1 parent 6097f04 commit 0b9af8b

Some content is hidden

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

53 files changed

+18702
-7
lines changed

Images~/archery-sample.png

158 KB
Loading

Images~/first-look.jpg

1000 KB
Loading

Images~/hdrpvr.png

6.25 MB
Loading

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
This SDK package is built based on [Unity Render Streaming](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) and [Unity WebRTC](https://docs.unity3d.com/Packages/[email protected]/manual/index.html). By using this package, you can stream any Unity scene from the the Unity Editor or a Standalone build to a WebXR client on the FusedVR Website : [https://fusedvr.com/rendering](https://fusedvr.com/rendering). To try this this package, it is as simple as dragging the included **Render Streaming Services** prefab into your Unity scene that you would like to stream and setting up the connect to the WebRTC server.
66

7+
For an overview of this package, please refer to this video tutorial on the FusedVR Youtube Channel: [A First Look At CloudXR WebXR](https://youtu.be/cTd8VDqep1c)
8+
9+
[![CloudXR WebXR](https://github.com/FusedVR/VRStreaming/blob/VRTKSample/Images~/first-look.jpg)](https://youtu.be/cTd8VDqep1c)
10+
711
# Setup
812

913
1. Import this Github Repo as a Unity Package via the Unity Package Manager **Add from Git URL** : https://github.com/FusedVR/VRStreaming.git
@@ -47,3 +51,19 @@ ID 6 is what is used for all WebXR Input specific to VR. Within VR Input, we spe
4751
- ID 2 = Controller Axis Data (Joystick & Trackpad)
4852

4953
The Raw Data from the Client is passed to VRInputManager, who is responsible for transmitting events based on the data mode recieved. Controller Input is then parsed by the ControllerInputManager, which has events that can be subscribed to for VR Input.
54+
55+
# Samples
56+
57+
Provided with the package are two samples to help with quick testing the SDK : **HDRP & VRTK**. Both these samples can be imported via the Package Manager once you have imported the SDK into your Unity project.
58+
59+
The first one uses the Unity HDRP Built In Template to show case streaming a scene with the [High Definition Render Pipeline](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) into WebXR. This one of the very few ways to play a HDRP game / app within Oculus Quest / WebXR. Provided within the sample is an Editor script to automatically import the High Definition Render Pipeline package. However, if this auto-import fails for some reason, please import the package yourself.
60+
61+
![High Definition Render Pipeline](https://github.com/FusedVR/VRStreaming/blob/VRTKSample/Images~/hdrpvr.png)
62+
63+
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):
64+
65+
- **io.extendreality.tilia.camerarigs.trackedalias.unity**
66+
- **io.extendreality.tilia.interactions.interactables.unity**
67+
- **io.extendreality.tilia.interactions.snapzone.unity**
68+
69+
![VRTK Archery](https://github.com/FusedVR/VRStreaming/blob/VRTKSample/Images~/archery-sample.png)

Runtime/Scripts/ApplyVRData.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public class ApplyVRData : MonoBehaviour
2323
/// <summary>
2424
/// Apply the VR Positional and Rotational Data from the Client onto the Server.
2525
/// </summary>
26-
public void ApplyData(VRInputManager.Source id, Vector3 position, Vector3 rotation)
26+
public void ApplyData(VRInputManager.Source id, Vector3 position, Quaternion rotation)
2727
{
2828
if (index == id) //check if the data is from the correct source
2929
{
30-
transform.localPosition = new Vector3(position.x, position.y, -position.z); //apply position
31-
transform.rotation = Quaternion.Euler(-rotation.x, -rotation.y, rotation.z); //apply rotation - not coordinate system change
30+
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
3232
}
3333
}
3434
}

Runtime/Scripts/VRInputManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public enum Source {
5252
/// Wrapper class for the Unity Event to pass custom data.
5353
/// </summary>
5454
[System.Serializable]
55-
public class VRPoseData : UnityEvent<Source, Vector3, Vector3> {
55+
public class VRPoseData : UnityEvent<Source, Vector3, Quaternion> {
5656

5757
}
5858

@@ -100,8 +100,8 @@ protected override void OnMessage(byte[] bytes)
100100
Vector3 pos = new Vector3(BitConverter.ToSingle(bytes, 3),
101101
BitConverter.ToSingle(bytes, 11), BitConverter.ToSingle(bytes, 19));
102102

103-
Vector3 rot = new Vector3(Mathf.Rad2Deg * BitConverter.ToSingle(bytes, 27),
104-
Mathf.Rad2Deg * BitConverter.ToSingle(bytes, 35), Mathf.Rad2Deg * BitConverter.ToSingle(bytes, 43));
103+
Quaternion rot = new Quaternion(BitConverter.ToSingle(bytes, 27) , BitConverter.ToSingle(bytes, 35),
104+
-BitConverter.ToSingle(bytes, 43), -BitConverter.ToSingle(bytes, 51)); //flip z and w due to different coordinated system
105105
VRPoseEvent.Invoke(device_type, pos, rot);
106106
break;
107107
case VRDataType.Button:

Samples~/VRTK-Sample/Materials.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: Cube
11+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12+
m_ShaderKeywords:
13+
m_LightmapFlags: 4
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: -1
17+
stringTagMap: {}
18+
disabledShaderPasses: []
19+
m_SavedProperties:
20+
serializedVersion: 3
21+
m_TexEnvs:
22+
- _BumpMap:
23+
m_Texture: {fileID: 0}
24+
m_Scale: {x: 1, y: 1}
25+
m_Offset: {x: 0, y: 0}
26+
- _DetailAlbedoMap:
27+
m_Texture: {fileID: 0}
28+
m_Scale: {x: 1, y: 1}
29+
m_Offset: {x: 0, y: 0}
30+
- _DetailMask:
31+
m_Texture: {fileID: 0}
32+
m_Scale: {x: 1, y: 1}
33+
m_Offset: {x: 0, y: 0}
34+
- _DetailNormalMap:
35+
m_Texture: {fileID: 0}
36+
m_Scale: {x: 1, y: 1}
37+
m_Offset: {x: 0, y: 0}
38+
- _EmissionMap:
39+
m_Texture: {fileID: 0}
40+
m_Scale: {x: 1, y: 1}
41+
m_Offset: {x: 0, y: 0}
42+
- _MainTex:
43+
m_Texture: {fileID: 0}
44+
m_Scale: {x: 1, y: 1}
45+
m_Offset: {x: 0, y: 0}
46+
- _MetallicGlossMap:
47+
m_Texture: {fileID: 0}
48+
m_Scale: {x: 1, y: 1}
49+
m_Offset: {x: 0, y: 0}
50+
- _OcclusionMap:
51+
m_Texture: {fileID: 0}
52+
m_Scale: {x: 1, y: 1}
53+
m_Offset: {x: 0, y: 0}
54+
- _ParallaxMap:
55+
m_Texture: {fileID: 0}
56+
m_Scale: {x: 1, y: 1}
57+
m_Offset: {x: 0, y: 0}
58+
m_Floats:
59+
- _BumpScale: 1
60+
- _Cutoff: 0.5
61+
- _DetailNormalMapScale: 1
62+
- _DstBlend: 0
63+
- _GlossMapScale: 1
64+
- _Glossiness: 0.5
65+
- _GlossyReflections: 1
66+
- _Metallic: 0
67+
- _Mode: 0
68+
- _OcclusionStrength: 1
69+
- _Parallax: 0.02
70+
- _SmoothnessTextureChannel: 0
71+
- _SpecularHighlights: 1
72+
- _SrcBlend: 1
73+
- _UVSec: 0
74+
- _ZWrite: 1
75+
m_Colors:
76+
- _Color: {r: 1, g: 0, b: 0.06209469, a: 1}
77+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

Samples~/VRTK-Sample/Materials/Cube.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 6
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: Shootable
11+
m_Shader: {fileID: 210, guid: 0000000000000000f000000000000000, type: 0}
12+
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _FADING_ON
13+
m_LightmapFlags: 0
14+
m_EnableInstancingVariants: 0
15+
m_DoubleSidedGI: 0
16+
m_CustomRenderQueue: 3000
17+
stringTagMap:
18+
RenderType: Transparent
19+
disabledShaderPasses:
20+
- ALWAYS
21+
m_SavedProperties:
22+
serializedVersion: 3
23+
m_TexEnvs:
24+
- _BumpMap:
25+
m_Texture: {fileID: 0}
26+
m_Scale: {x: 1, y: 1}
27+
m_Offset: {x: 0, y: 0}
28+
- _DetailAlbedoMap:
29+
m_Texture: {fileID: 0}
30+
m_Scale: {x: 1, y: 1}
31+
m_Offset: {x: 0, y: 0}
32+
- _DetailMask:
33+
m_Texture: {fileID: 0}
34+
m_Scale: {x: 1, y: 1}
35+
m_Offset: {x: 0, y: 0}
36+
- _DetailNormalMap:
37+
m_Texture: {fileID: 0}
38+
m_Scale: {x: 1, y: 1}
39+
m_Offset: {x: 0, y: 0}
40+
- _EmissionMap:
41+
m_Texture: {fileID: 0}
42+
m_Scale: {x: 1, y: 1}
43+
m_Offset: {x: 0, y: 0}
44+
- _MainTex:
45+
m_Texture: {fileID: 0}
46+
m_Scale: {x: 1, y: 1}
47+
m_Offset: {x: 0, y: 0}
48+
- _MetallicGlossMap:
49+
m_Texture: {fileID: 0}
50+
m_Scale: {x: 1, y: 1}
51+
m_Offset: {x: 0, y: 0}
52+
- _OcclusionMap:
53+
m_Texture: {fileID: 0}
54+
m_Scale: {x: 1, y: 1}
55+
m_Offset: {x: 0, y: 0}
56+
- _ParallaxMap:
57+
m_Texture: {fileID: 0}
58+
m_Scale: {x: 1, y: 1}
59+
m_Offset: {x: 0, y: 0}
60+
m_Floats:
61+
- _BlendOp: 0
62+
- _BumpScale: 1
63+
- _CameraFadingEnabled: 0
64+
- _CameraFarFadeDistance: 2
65+
- _CameraNearFadeDistance: 1
66+
- _ColorMode: 0
67+
- _Cull: 2
68+
- _Cutoff: 0.5
69+
- _DetailNormalMapScale: 1
70+
- _DistortionBlend: 0.5
71+
- _DistortionEnabled: 0
72+
- _DistortionStrength: 1
73+
- _DistortionStrengthScaled: 0
74+
- _DstBlend: 10
75+
- _EmissionEnabled: 0
76+
- _FlipbookMode: 0
77+
- _GlossMapScale: 1
78+
- _Glossiness: 0.7
79+
- _GlossyReflections: 1
80+
- _LightingEnabled: 1
81+
- _Metallic: 0
82+
- _Mode: 3
83+
- _OcclusionStrength: 1
84+
- _Parallax: 0.02
85+
- _SmoothnessTextureChannel: 0
86+
- _SoftParticlesEnabled: 1
87+
- _SoftParticlesFarFadeDistance: 1
88+
- _SoftParticlesNearFadeDistance: 0
89+
- _SpecularHighlights: 1
90+
- _SrcBlend: 1
91+
- _UVSec: 0
92+
- _ZWrite: 0
93+
m_Colors:
94+
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
95+
- _Color: {r: 1, g: 1, b: 1, a: 1}
96+
- _ColorAddSubDiff: {r: 0, g: 0, b: 0, a: 0}
97+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
98+
- _SoftParticleFadeParams: {r: 0, g: 1, b: 0, a: 0}

0 commit comments

Comments
 (0)