/// <summary> /// Handles the logic of stopping the active webcam mode for the Hololens. /// Disposes and nulls out the webcam object and disables voice commands. /// Re-enables the start voice command to restart the process of taking /// room textures if the user desires. /// </summary> /// <param name="result"> /// The success of stopping the OnStoppedPhotoMode. /// </param> static void OnStoppedPhotoMode(PhotoCapture.PhotoCaptureResult result) { // Disables the ability to take pictures, and cleans up/disposes of // the photo capture object. VoiceManager.DisableVoiceCommand(VoiceCommands.Photo); photoCaptureObj.Dispose(); photoCaptureObj = null; // Sets locally stored matrices and supplementary info required for // correct texture placement, then saves them along with the mesh SetLocalToWorldMatrices(); // Must be called before SaveMatrixArrays SetMeshSupplementaryInfo(); string roomName = Config.RoomObject.GameObjectName; MatrixArray.SaveMatrixArrays(WorldToCameraMatrixArray, ProjectionMatrixArray, LocalToWorldMatrixArray, currentPhoto); CustomMesh.SaveMesh(MeshArray); CustomOrientation.Save(PositionArray, RotationArray); // ERROR TESTING - REMOVE // CustomMesh.SaveSupplementaryInfo(PositionArray, RotationArray); // Disable the ability to end the photo capture process VoiceManager.DisableVoiceCommand(VoiceCommands.End); VoiceManager.EnableVoiceCommand(VoiceCommands.Start); isEndingPhotoCapture = false; TextManager.SetText("Finished!"); if (currentPhoto < MaxPhotoNum) { TextManager.SetText(Messages.PhotoCaptureEnded); } else { TextManager.SetText(Messages.MaxPhotosTaken); } }
public static GameObject BuildRoomObject(string[] orientationFileLines) { string roomName = Config.RoomObject.GameObjectName; Debug.Log("Building room"); Debug.Log("Room name = " + roomName); //Debug.Log("Unity meshes relative directory = " + unityMeshesRelativeDirectory); //Debug.Log("Materials relative directory = " + materialsRelativeDirectory); Debug.Log("Previous directory = " + Config.UnityMeshes.AssetSubFolder); if (!Directory.Exists(Config.CustomMesh.CompileAbsoluteAssetDirectory(roomName))) { //Directory.CreateDirectory(Config.CustomMesh.CompileAbsoluteAssetDirectory()); AbnormalDirectoryHandler.CreateDirectory(Config.CustomMesh.CompileAbsoluteAssetDirectory(roomName)); } Vector3[] positionArray; Quaternion[] rotationArray; // Load up the information stored from mesh supplementary information // to correct for Hololens mesh translation and orientation. CustomOrientation.Load(orientationFileLines, out positionArray, out rotationArray); GameObject roomObject = new GameObject(); //roomObject.name = Config.RoomObject.GameObjectName; roomObject.name = roomName; for (int i = 0; i < positionArray.Length; i++) { GameObject child = new GameObject(); Debug.Log("Mesh resource load path = " + Config.UnityMeshes.CompileResourcesLoadPath(Config.UnityMeshes.CompileMeshName(i), roomName)); //Debug.Log("mesh resource load path = " + Config.UnityMeshes.CompileResourcesLoadPath(unityMeshesRelativeDirectory, Config.UnityMeshes.CompileMeshName(i))); // Set mesh Mesh childMesh = Resources.Load(Config.UnityMeshes.CompileResourcesLoadPath(Config.UnityMeshes.CompileMeshName(i), roomName)) as Mesh; //Mesh childMesh = Resources.Load(Config.UnityMeshes.CompileResourcesLoadPath(unityMeshesRelativeDirectory, Config.UnityMeshes.CompileMeshName(i))) as Mesh; MeshFilter mf = child.AddComponent <MeshFilter>(); mf.sharedMesh = childMesh; // Set material MeshRenderer mr = child.AddComponent <MeshRenderer>(); mr.sharedMaterial = Resources.Load <Material>(Config.Material.CompileResourcesLoadPath(Config.Material.CompileMaterialName(i), roomName)); //mr.sharedMaterial = Resources.Load<Material>(Config.Material.CompileResourcesLoadPath(materialsRelativeDirectory, Config.Material.CompileMaterialName(i))); //Debug.Log("Meshes relative directory = " + unityMeshesRelativeDirectory); //Debug.Log("Meshes path = " + Config.UnityMeshes.CompileResourcesLoadPath(unityMeshesRelativeDirectory, Config.UnityMeshes.CompileMeshName(i))); //Debug.Log("Materials relative directory = " + materialsRelativeDirectory); //Debug.Log("Materials path = " + Config.Material.CompileResourcesLoadPath(materialsRelativeDirectory, Config.Material.CompileMaterialName(i))); // Set position and rotation child.transform.position = positionArray[i]; child.transform.rotation = rotationArray[i]; // Set name child.name = childMesh.name; child.transform.parent = roomObject.transform; // Add mesh collider MeshCollider mc = child.AddComponent <MeshCollider>(); mc.sharedMesh = childMesh; } roomObject.AddComponent <RoomModel>(); //// Integrate it into the UWB Network //roomObject.AddComponent<UWBPhotonTransformView>(); return(roomObject); }