Skip to content

Commit 9db262b

Browse files
committed
Merge pull request #28 from DuFF14/Unity5Refactor
Unity5 compatibility refactor, update to JSON display parsing (using Newtonsoft.JSON)
2 parents a8bf8c4 + ef0f6e8 commit 9db262b

12 files changed

Lines changed: 402 additions & 1268 deletions

File tree

OSVR-Unity/Assets/OSVRUnity/Prefabs/VRDisplayTracked.prefab

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ MonoBehaviour:
140140
m_Script: {fileID: 11500000, guid: a288e4aec9950634b83d232abc73d1bb, type: 3}
141141
m_Name:
142142
m_EditorClassIdentifier:
143-
path: /display
144-
jsonDescriptorFile: {fileID: 4900000, guid: 6c4ce626027a5de4692d184d6a1b6db3, type: 3}
143+
JsonDescriptorFile: {fileID: 4900000, guid: 903a53a7997a82c42b329c472b623a4e, type: 3}
145144
--- !u!114 &11431730
146145
MonoBehaviour:
147146
m_ObjectHideFlags: 1

OSVR-Unity/Assets/OSVRUnity/Sample/Demo/Scenes/OSVRDemo.unity

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,8 +2562,7 @@ MonoBehaviour:
25622562
m_Script: {fileID: 11500000, guid: a288e4aec9950634b83d232abc73d1bb, type: 3}
25632563
m_Name:
25642564
m_EditorClassIdentifier:
2565-
path: /display
2566-
jsonDescriptorFile: {fileID: 4900000, guid: 6c4ce626027a5de4692d184d6a1b6db3, type: 3}
2565+
JsonDescriptorFile: {fileID: 4900000, guid: 903a53a7997a82c42b329c472b623a4e, type: 3}
25672566
--- !u!1 &1850521407
25682567
GameObject:
25692568
m_ObjectHideFlags: 0

OSVR-Unity/Assets/OSVRUnity/Sample/VRDisplayDemo.unity

Lines changed: 71 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,18 +1198,63 @@ Transform:
11981198
m_Children: []
11991199
m_Father: {fileID: 0}
12001200
m_RootOrder: 1
1201+
--- !u!1001 &715470731
1202+
Prefab:
1203+
m_ObjectHideFlags: 0
1204+
serializedVersion: 2
1205+
m_Modification:
1206+
m_TransformParent: {fileID: 0}
1207+
m_Modifications:
1208+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1209+
propertyPath: m_LocalPosition.x
1210+
value: 0
1211+
objectReference: {fileID: 0}
1212+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1213+
propertyPath: m_LocalPosition.y
1214+
value: 0
1215+
objectReference: {fileID: 0}
1216+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1217+
propertyPath: m_LocalPosition.z
1218+
value: 0
1219+
objectReference: {fileID: 0}
1220+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1221+
propertyPath: m_LocalRotation.x
1222+
value: 0
1223+
objectReference: {fileID: 0}
1224+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1225+
propertyPath: m_LocalRotation.y
1226+
value: 0
1227+
objectReference: {fileID: 0}
1228+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1229+
propertyPath: m_LocalRotation.z
1230+
value: 0
1231+
objectReference: {fileID: 0}
1232+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1233+
propertyPath: m_LocalRotation.w
1234+
value: 1
1235+
objectReference: {fileID: 0}
1236+
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1237+
propertyPath: m_RootOrder
1238+
value: 0
1239+
objectReference: {fileID: 0}
1240+
m_RemovedComponents: []
1241+
m_ParentPrefab: {fileID: 100100000, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1242+
m_RootGameObject: {fileID: 955452065}
1243+
m_IsPrefabParent: 0
1244+
m_IsExploded: 1
12011245
--- !u!1 &955452065
12021246
GameObject:
12031247
m_ObjectHideFlags: 0
12041248
m_PrefabParentObject: {fileID: 131736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1205-
m_PrefabInternal: {fileID: 1603019521}
1249+
m_PrefabInternal: {fileID: 715470731}
12061250
serializedVersion: 4
12071251
m_Component:
12081252
- 4: {fileID: 955452066}
12091253
- 20: {fileID: 955452068}
12101254
- 81: {fileID: 955452069}
12111255
- 114: {fileID: 955452067}
12121256
- 114: {fileID: 955452070}
1257+
- 114: {fileID: 955452071}
12131258
m_Layer: 0
12141259
m_Name: VRDisplayTracked
12151260
m_TagString: Untagged
@@ -1221,7 +1266,7 @@ GameObject:
12211266
Transform:
12221267
m_ObjectHideFlags: 0
12231268
m_PrefabParentObject: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1224-
m_PrefabInternal: {fileID: 1603019521}
1269+
m_PrefabInternal: {fileID: 715470731}
12251270
m_GameObject: {fileID: 955452065}
12261271
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
12271272
m_LocalPosition: {x: 0, y: 0, z: 0}
@@ -1236,7 +1281,7 @@ MonoBehaviour:
12361281
m_ObjectHideFlags: 0
12371282
m_PrefabParentObject: {fileID: 11431734, guid: bcbb49b5078d05d498ef83a6373ba939,
12381283
type: 2}
1239-
m_PrefabInternal: {fileID: 1603019521}
1284+
m_PrefabInternal: {fileID: 715470731}
12401285
m_GameObject: {fileID: 955452065}
12411286
m_Enabled: 1
12421287
m_EditorHideFlags: 0
@@ -1251,7 +1296,7 @@ Camera:
12511296
m_ObjectHideFlags: 0
12521297
m_PrefabParentObject: {fileID: 2031736, guid: bcbb49b5078d05d498ef83a6373ba939,
12531298
type: 2}
1254-
m_PrefabInternal: {fileID: 1603019521}
1299+
m_PrefabInternal: {fileID: 715470731}
12551300
m_GameObject: {fileID: 955452065}
12561301
m_Enabled: 1
12571302
serializedVersion: 2
@@ -1284,27 +1329,40 @@ AudioListener:
12841329
m_ObjectHideFlags: 0
12851330
m_PrefabParentObject: {fileID: 8131736, guid: bcbb49b5078d05d498ef83a6373ba939,
12861331
type: 2}
1287-
m_PrefabInternal: {fileID: 1603019521}
1332+
m_PrefabInternal: {fileID: 715470731}
12881333
m_GameObject: {fileID: 955452065}
12891334
m_Enabled: 1
12901335
--- !u!114 &955452070
12911336
MonoBehaviour:
12921337
m_ObjectHideFlags: 0
12931338
m_PrefabParentObject: {fileID: 11431736, guid: bcbb49b5078d05d498ef83a6373ba939,
12941339
type: 2}
1295-
m_PrefabInternal: {fileID: 1603019521}
1340+
m_PrefabInternal: {fileID: 715470731}
12961341
m_GameObject: {fileID: 955452065}
12971342
m_Enabled: 1
12981343
m_EditorHideFlags: 0
1299-
m_Script: {fileID: 11500000, guid: ee225769fa78e894c970514b2f2e1f90, type: 3}
1344+
m_Script: {fileID: 11500000, guid: d819a5e6a69cc5c46be733d8a56d387e, type: 3}
13001345
m_Name:
13011346
m_EditorClassIdentifier:
13021347
path: /me/head
1348+
--- !u!114 &955452071
1349+
MonoBehaviour:
1350+
m_ObjectHideFlags: 0
1351+
m_PrefabParentObject: {fileID: 11400556, guid: bcbb49b5078d05d498ef83a6373ba939,
1352+
type: 2}
1353+
m_PrefabInternal: {fileID: 715470731}
1354+
m_GameObject: {fileID: 955452065}
1355+
m_Enabled: 1
1356+
m_EditorHideFlags: 0
1357+
m_Script: {fileID: 11500000, guid: a288e4aec9950634b83d232abc73d1bb, type: 3}
1358+
m_Name:
1359+
m_EditorClassIdentifier:
1360+
JsonDescriptorFile: {fileID: 4900000, guid: 903a53a7997a82c42b329c472b623a4e, type: 3}
13031361
--- !u!1 &1468488789
13041362
GameObject:
13051363
m_ObjectHideFlags: 0
13061364
m_PrefabParentObject: {fileID: 131734, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1307-
m_PrefabInternal: {fileID: 1603019521}
1365+
m_PrefabInternal: {fileID: 715470731}
13081366
serializedVersion: 4
13091367
m_Component:
13101368
- 4: {fileID: 1468488791}
@@ -1321,7 +1379,7 @@ MonoBehaviour:
13211379
m_ObjectHideFlags: 0
13221380
m_PrefabParentObject: {fileID: 11431732, guid: bcbb49b5078d05d498ef83a6373ba939,
13231381
type: 2}
1324-
m_PrefabInternal: {fileID: 1603019521}
1382+
m_PrefabInternal: {fileID: 715470731}
13251383
m_GameObject: {fileID: 1468488789}
13261384
m_Enabled: 1
13271385
m_EditorHideFlags: 0
@@ -1334,62 +1392,14 @@ MonoBehaviour:
13341392
Transform:
13351393
m_ObjectHideFlags: 0
13361394
m_PrefabParentObject: {fileID: 431734, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1337-
m_PrefabInternal: {fileID: 1603019521}
1395+
m_PrefabInternal: {fileID: 715470731}
13381396
m_GameObject: {fileID: 1468488789}
13391397
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
13401398
m_LocalPosition: {x: 0, y: 0, z: 0}
13411399
m_LocalScale: {x: 1, y: 1, z: 1}
13421400
m_Children: []
13431401
m_Father: {fileID: 955452066}
13441402
m_RootOrder: 0
1345-
--- !u!1001 &1603019521
1346-
Prefab:
1347-
m_ObjectHideFlags: 0
1348-
serializedVersion: 2
1349-
m_Modification:
1350-
m_TransformParent: {fileID: 0}
1351-
m_Modifications:
1352-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1353-
propertyPath: m_LocalPosition.x
1354-
value: 0
1355-
objectReference: {fileID: 0}
1356-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1357-
propertyPath: m_LocalPosition.y
1358-
value: 0
1359-
objectReference: {fileID: 0}
1360-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1361-
propertyPath: m_LocalPosition.z
1362-
value: 0
1363-
objectReference: {fileID: 0}
1364-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1365-
propertyPath: m_LocalRotation.x
1366-
value: 0
1367-
objectReference: {fileID: 0}
1368-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1369-
propertyPath: m_LocalRotation.y
1370-
value: 0
1371-
objectReference: {fileID: 0}
1372-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1373-
propertyPath: m_LocalRotation.z
1374-
value: 0
1375-
objectReference: {fileID: 0}
1376-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1377-
propertyPath: m_LocalRotation.w
1378-
value: 1
1379-
objectReference: {fileID: 0}
1380-
- target: {fileID: 431736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1381-
propertyPath: m_RootOrder
1382-
value: 0
1383-
objectReference: {fileID: 0}
1384-
- target: {fileID: 131736, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1385-
propertyPath: m_Name
1386-
value: VRDisplayTracked
1387-
objectReference: {fileID: 0}
1388-
m_RemovedComponents: []
1389-
m_ParentPrefab: {fileID: 100100000, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1390-
m_RootGameObject: {fileID: 955452065}
1391-
m_IsPrefabParent: 0
1392-
m_IsExploded: 1
13931403
--- !u!1001 &1925542040
13941404
Prefab:
13951405
m_ObjectHideFlags: 0
@@ -1442,7 +1452,7 @@ Prefab:
14421452
GameObject:
14431453
m_ObjectHideFlags: 0
14441454
m_PrefabParentObject: {fileID: 131732, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1445-
m_PrefabInternal: {fileID: 1603019521}
1455+
m_PrefabInternal: {fileID: 715470731}
14461456
serializedVersion: 4
14471457
m_Component:
14481458
- 4: {fileID: 2061423056}
@@ -1458,7 +1468,7 @@ GameObject:
14581468
Transform:
14591469
m_ObjectHideFlags: 0
14601470
m_PrefabParentObject: {fileID: 431732, guid: bcbb49b5078d05d498ef83a6373ba939, type: 2}
1461-
m_PrefabInternal: {fileID: 1603019521}
1471+
m_PrefabInternal: {fileID: 715470731}
14621472
m_GameObject: {fileID: 2061423055}
14631473
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
14641474
m_LocalPosition: {x: 0, y: 0, z: 0}
@@ -1471,7 +1481,7 @@ MonoBehaviour:
14711481
m_ObjectHideFlags: 0
14721482
m_PrefabParentObject: {fileID: 11431730, guid: bcbb49b5078d05d498ef83a6373ba939,
14731483
type: 2}
1474-
m_PrefabInternal: {fileID: 1603019521}
1484+
m_PrefabInternal: {fileID: 715470731}
14751485
m_GameObject: {fileID: 2061423055}
14761486
m_Enabled: 1
14771487
m_EditorHideFlags: 0

OSVR-Unity/Assets/OSVRUnity/src/DeviceDescriptor.cs

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,43 @@
2020

2121
using UnityEngine;
2222
using System.Collections;
23+
using System.Text;
2324

2425
//a class for storing information about a device based on it's json descriptor file
2526
public class DeviceDescriptor {
2627

28+
//filename
29+
private string _fileName = "";
30+
public string FileName
31+
{
32+
get { return _fileName; }
33+
set { _fileName = value; }
34+
}
35+
//hmd
36+
private string _vendor = "";
37+
public string Vendor
38+
{
39+
get { return _vendor; }
40+
set { _vendor = value; }
41+
}
42+
private string _model = "";
43+
public string Model
44+
{
45+
get { return _model; }
46+
set { _model = value; }
47+
}
48+
private string _version;
49+
public string Version
50+
{
51+
get { return _version; }
52+
set { _version = value; }
53+
}
54+
private string _note = "";
55+
public string Note
56+
{
57+
get { return _note; }
58+
set { _note = value; }
59+
}
2760
//field of view
2861
private float _monocularHorizontal = 60f;
2962
public float MonocularHorizontal
@@ -128,10 +161,11 @@ public int Rotate180
128161

129162
//constructors
130163
public DeviceDescriptor() { }
131-
public DeviceDescriptor(float monocularHorizontal, float monocularVertical, float overlapPercent, float pitchTilt,
164+
public DeviceDescriptor(string fileName, float monocularHorizontal, float monocularVertical, float overlapPercent, float pitchTilt,
132165
int width, int height, int videoInputs, string displayMode, float k1Red, float k1Green, float k1Blue, float leftRoll,
133166
float rightRoll, float centerProjX, float centerProjY, int rotate180)
134167
{
168+
this._fileName = fileName;
135169
this._monocularHorizontal = monocularHorizontal;
136170
this._monocularVertical = monocularVertical;
137171
this._overlapPercent = overlapPercent;
@@ -149,4 +183,44 @@ public DeviceDescriptor(float monocularHorizontal, float monocularVertical, floa
149183
this._centerProjY = centerProjY;
150184
this._rotate180 = rotate180;
151185
}
186+
187+
public override string ToString()
188+
{
189+
190+
if(FileName.Equals(""))
191+
{
192+
return "No json file has been provided.";
193+
}
194+
//print
195+
StringBuilder jsonPrinter = new StringBuilder(64);
196+
jsonPrinter.AppendLine("Json File Device Description:")
197+
.Append("filename = ").AppendLine(FileName)
198+
.Append("HMD\n")
199+
.Append("vendor = ").AppendLine(Vendor)
200+
.Append("model = ").AppendLine(Model)
201+
.Append("version = ").AppendLine(Version)
202+
.Append("notes = ").AppendLine(Note)
203+
.Append("\nFIELD OF VIEW\n")
204+
.Append("monocular_horizontal = ").AppendLine(MonocularHorizontal.ToString())
205+
.Append("monocular_vertical = ").AppendLine(MonocularVertical.ToString())
206+
.Append("overlap_percent = ").AppendLine(OverlapPercent.ToString())
207+
.Append("pitch_tilt = ").AppendLine(PitchTilt.ToString())
208+
.Append("\nRESOLUTION\n")
209+
.Append("width = ").AppendLine(Width.ToString())
210+
.Append("height = ").AppendLine(Height.ToString())
211+
.Append("video_inputs = ").AppendLine(VideoInputs.ToString())
212+
.Append("display_mode = ").AppendLine(DisplayMode)
213+
.Append("\nDISTORTION\n")
214+
.Append("k1_red = ").AppendLine(K1Red.ToString())
215+
.Append("k1_green = ").AppendLine(K1Green.ToString())
216+
.Append("k1_blue = ").AppendLine(K1Blue.ToString())
217+
.Append("\nRENDERING\n")
218+
.Append("left_roll = ").AppendLine(LeftRoll.ToString())
219+
.Append("right_roll = ").AppendLine(RightRoll.ToString())
220+
.Append("\nEYES\n")
221+
.Append("center_proj_x = ").AppendLine(CenterProjX.ToString())
222+
.Append("center_proj_y = ").AppendLine(CenterProjY.ToString())
223+
.Append("rotate_180 = ").AppendLine(Rotate180.ToString());
224+
return jsonPrinter.ToString();
225+
}
152226
}

0 commit comments

Comments
 (0)