Esempio n. 1
0
 /// <summary>
 /// Called when the Hololens webcam is created and primed. Triggers
 /// the enabling of voice commands for taking photos or ending
 /// camera mode. Removes ability to erroneously start up texturing
 /// process while the texturing process is underway. Sets the displayed
 /// text.
 /// </summary>
 /// <param name="result">
 /// The information/image saved from the PhotoCapture's photo capture.
 /// </param>
 static void OnStartPhotoMode(PhotoCapture.PhotoCaptureResult result)
 {
     VoiceManager.EnableVoiceCommand(VoiceCommands.Photo);
     VoiceManager.EnableVoiceCommand(VoiceCommands.End);
     VoiceManager.DisableVoiceCommand(VoiceCommands.Start);
     TextManager.SetText(Messages.PhotoPrompt + Messages.AppendNumPhotosTaken());
 }
Esempio n. 2
0
        /// <summary>
        /// Initialization method. Must be called manually since this class
        /// isn't attachable to a Unity object to make it auto-initiate.
        /// Initializes variables, arrays, the camera, and enables the voice
        /// command that triggers letting the camera take pictures for
        /// texturing. Sets display text.
        /// </summary>
        public static void Start()
        {
            // Initialize variables
            WorldToCameraMatrixArray = new Matrix4x4[MaxPhotoNum];
            ProjectionMatrixArray    = new Matrix4x4[MaxPhotoNum];
            // Avoid potential null exceptions w/ future code changes
            // by using temporary new matrix arrays
            LocalToWorldMatrixArray = new Matrix4x4[1];
            PositionArray           = new Vector3[1];
            RotationArray           = new Quaternion[1];
            MeshArray = new Mesh[1];

            // Failsafe for Hololens camera and texture initialization
            // Default assumed of 1280 pixels x 720 pixels
            m_downgradedCameraResolution = new Resolution();
            m_CameraParameters           = new CameraParameters();
            m_CameraResolution           = new Resolution();
            m_CameraResolution.width     = 1280;
            m_CameraResolution.height    = 720;
            m_Texture = new Texture2D(1280, 720);

            // Run accurate Hololens camera and texture initialization
            InitCamera();
            m_Texture = new Texture2D(CameraResolution.width, CameraResolution.height);

            // Enable voice command that triggers texturing process
            VoiceManager.EnableVoiceCommand(VoiceCommands.Start);
            TextManager.SetText(Messages.StartPrompt);
        }
Esempio n. 3
0
        /// <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);
            }
        }