public bool LoadCalibration(string path) { if (path == null || path.Length == 0) { return(false); } string json = ""; try { string line; StreamReader theReader = new StreamReader(path, Encoding.Default); using (theReader) { do { line = theReader.ReadLine(); if (line != null) { json += line; } }while (line != null); theReader.Close(); } } catch (Exception e) { //Console.WriteLine("{0}\n", e.Message); Debug.Log(e.Message); return(false); } var N = JSON.Parse(json); fieldOfView = N["FieldOfView"].AsFloat; projectorCount = N["Cameras"].Count; renderTextureSize = new Vector2(N["TextureWidth"].AsInt, N["TextureHeight"].AsInt); xDivisions = N["XDivisions"].AsInt; yDivisions = N["YDivisions"].AsInt; arrangement = (CameraArragement)N["Arrangement"].AsInt; overlap = new Vector2(N["OverlapX"].AsFloat, N["OverlapY"].AsFloat); viewportSize = N["ViewportSize"].AsFloat; near = N["Near"].AsFloat; far = N["Far"].AsFloat; projectionCameraSpace = N["Spacing"].AsFloat; DestroyCameras(); InitCameras(); for (int i = 0; i < projectorCount; i++) { ProjectionMesh projectionMesh = projectionCameras[i]; JSONNode cameraNode = N["Cameras"][i]; projectionMesh.leftFadeRange = cameraNode["LeftFadeRange"].AsFloat; projectionMesh.leftFadeChoke = cameraNode["LeftFadeChoke"].AsFloat; projectionMesh.rightFadeRange = cameraNode["RightFadeRange"].AsFloat; projectionMesh.rightFadeChoke = cameraNode["RightFadeChoke"].AsFloat; projectionMesh.topFadeRange = cameraNode["TopFadeRange"].AsFloat; projectionMesh.topFadeChoke = cameraNode["TopFadeChoke"].AsFloat; projectionMesh.bottomFadeRange = cameraNode["BottomFadeRange"].AsFloat; projectionMesh.bottomFadeChoke = cameraNode["BottomFadeChoke"].AsFloat; projectionMesh.tint = new Color(cameraNode["Tint"]["r"].AsFloat, cameraNode["Tint"]["g"].AsFloat, cameraNode["Tint"]["b"].AsFloat); JSONNode cornerNode = cameraNode["Offset"]["Corner"]; for (int j = 0; j < 4; j++) { projectionMesh.cornerOffset[j] = new Vector2(cornerNode[j * 2].AsFloat, cornerNode[(j * 2) + 1].AsFloat); } /* * JSONNode rowNode = cameraNode["Offset"]["Row"]; * * for (int j = 0; j < yDivisions+1; j++) * { * projectionMesh.rowOffset[j] = new Vector2(rowNode[j * 2].AsFloat, rowNode[(j * 2) + 1].AsFloat); * } * * JSONNode columnNode = cameraNode["Offset"]["Column"]; * * for (int j = 0; j < xDivisions+1; j++) * { * projectionMesh.columnOffset[j] = new Vector2(columnNode[j * 2].AsFloat, columnNode[(j * 2) + 1].AsFloat); * } */ JSONNode pointNode = cameraNode["Offset"]["Point"]; for (int j = 0; j < (xDivisions + 1) * (yDivisions + 1); j++) { projectionMesh.pointOffset[j] = new Vector2(pointNode[j * 2].AsFloat, pointNode[(j * 2) + 1].AsFloat); } projectionMesh.CreateMesh(); projectionMesh.BlendRefresh(); //projectionMesh.OffsetRefresh(); projectionMesh.UpdateUI(); } defaultCalibrationFile = path; UpdateSourceCameras(); Debug.Log(path + " has been loaded."); return(true); }