/*! This methode starts the loading of a .blend file * \param pathToMeshJson path to a .blend file */ public void LoadFile(string pathToMeshJson) { //Check if mesh.json exists if (!File.Exists(pathToMeshJson)) { Debug.LogWarning("Could not load mesh from: " + pathToMeshJson + ", file not found."); return; } // Read mesh.json string fileContent = ""; string line; System.IO.StreamReader file = new System.IO.StreamReader(pathToMeshJson); while ((line = file.ReadLine()) != null) { fileContent += line; } file.Close(); meshJson = JsonMapper.ToObject <MeshJson>(fileContent); if (meshJson == null) { Debug.LogWarning("Error while parsing mesh.json"); return; } Patient currentPatient = Patient.getLoadedPatient(); string path = currentPatient.path + "/" + meshJson.pathToBlendFile; //Loading blend file if (File.Exists(path)) { // Let loading screen know what we're currently doing: PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_AddLoadingJob, "Mesh"); this.RemoveMesh(); this.Path = path; MeshGameObjectContainers = new List <GameObject>(); // Reset scale, rotation, position: meshNode.transform.localScale = new Vector3(0.007f, 0.007f, 0.007f); meshNode.transform.parent.localScale = new Vector3(1.0f, 1.0f, 1.0f); meshNode.transform.parent.localRotation = Quaternion.identity; //meshNode.transform.parent.Rotate (90, 0, 0); meshNode.transform.parent.GetComponent <ModelRotator>().setTargetOrientation(Quaternion.Euler(90, 0, 0)); ThreadUtil t = new ThreadUtil(this.LoadFileWorker, this.LoadFileCallback); t.Run(); } else { Debug.LogWarning("Could not load mesh from: '" + path + "', file not found."); } }
// Update is called once per frame void Update() { if (loaded) { StartCoroutine("LoadFileExecute"); unityMeshes = new List <List <UnityMesh> >(); loaded = false; Path = ""; } if (triggerEvent) { blenderObjects = new List <BlenderObjectBlock>(); meshJson = null; triggerEvent = false; // Let loading screen know what we're currently doing: PatientEventSystem.triggerEvent(PatientEventSystem.Event.LOADING_RemoveLoadingJob, "Mesh"); PatientEventSystem.triggerEvent(PatientEventSystem.Event.MESH_LoadedAll); } }