2020
2121using UnityEngine ;
2222using System . Collections ;
23+ using System . Text ;
2324
2425//a class for storing information about a device based on it's json descriptor file
2526public class DeviceDescriptor {
2627
28+ //filename
29+ private string _fileName = "" ;
30+ public string FileName
31+ {
32+ get { return _fileName ; }
33+ set { _fileName = value ; }
34+ }
2735 //hmd
2836 private string _vendor = "" ;
2937 public string Vendor
@@ -153,10 +161,11 @@ public int Rotate180
153161
154162 //constructors
155163 public DeviceDescriptor ( ) { }
156- public DeviceDescriptor ( float monocularHorizontal , float monocularVertical , float overlapPercent , float pitchTilt ,
164+ public DeviceDescriptor ( string fileName , float monocularHorizontal , float monocularVertical , float overlapPercent , float pitchTilt ,
157165 int width , int height , int videoInputs , string displayMode , float k1Red , float k1Green , float k1Blue , float leftRoll ,
158166 float rightRoll , float centerProjX , float centerProjY , int rotate180 )
159167 {
168+ this . _fileName = fileName ;
160169 this . _monocularHorizontal = monocularHorizontal ;
161170 this . _monocularVertical = monocularVertical ;
162171 this . _overlapPercent = overlapPercent ;
@@ -177,32 +186,41 @@ public DeviceDescriptor(float monocularHorizontal, float monocularVertical, floa
177186
178187 public override string ToString ( )
179188 {
180- string deviceDescription = "Device Description:\n " + "HMD:\n " ;
181- deviceDescription += "Vendor = " + Vendor + "\n " ;
182- deviceDescription += "Model = " + Model + "\n " ;
183- deviceDescription += "Version = " + Version + "\n " ;
184- deviceDescription += "Note = " + Note + "\n " ;
185- deviceDescription += "\n FIELD OF VIEW:\n " ;
186- deviceDescription += "monocular_horizontal = " + MonocularHorizontal + "\n " ;
187- deviceDescription += "monocular_vertical = " + MonocularVertical + "\n " ;
188- deviceDescription += "overlap_percent = " + OverlapPercent + "\n " ;
189- deviceDescription += "pitch_tilt = " + PitchTilt + "\n " ;
190- deviceDescription += "\n RESOLUTION\n " ;
191- deviceDescription += "width = " + Width + "\n " ;
192- deviceDescription += "height = " + Height + "\n " ;
193- deviceDescription += "video_inputs = " + VideoInputs + "\n " ;
194- deviceDescription += "display_mode = " + DisplayMode + "\n " ;
195- deviceDescription += "\n DISTORTION\n " ;
196- deviceDescription += "k1_red = " + K1Red + "\n " ;
197- deviceDescription += "k1_green = " + K1Green + "\n " ;
198- deviceDescription += "k1_blue = " + K1Blue + "\n " ;
199- deviceDescription += "\n RENDERING\n " ;
200- deviceDescription += "left_roll = " + LeftRoll + "\n " ;
201- deviceDescription += "right_roll = " + RightRoll + "\n " ;
202- deviceDescription += "\n EYES\n " ;
203- deviceDescription += "center_proj_x = " + CenterProjX + "\n " ;
204- deviceDescription += "center_proj_y = " + CenterProjY + "\n " ;
205- deviceDescription += "rotate_180 = " + Rotate180 + "\n " ;
206- return deviceDescription ;
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 ( "\n FIELD 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 ( "\n RESOLUTION\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 ( "\n DISTORTION\n " )
214+ . Append ( "k1_red = " ) . AppendLine ( K1Red . ToString ( ) )
215+ . Append ( "k1_green = " ) . AppendLine ( K1Green . ToString ( ) )
216+ . Append ( "k1_blue = " ) . AppendLine ( K1Blue . ToString ( ) )
217+ . Append ( "\n RENDERING\n " )
218+ . Append ( "left_roll = " ) . AppendLine ( LeftRoll . ToString ( ) )
219+ . Append ( "right_roll = " ) . AppendLine ( RightRoll . ToString ( ) )
220+ . Append ( "\n EYES\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 ( ) ;
207225 }
208226}
0 commit comments