/// <summary> /// Raises the button click event. /// </summary> ///*********************** IMPORTANT *********************** /// this is the method that sends the start, done and reset /// commands to the plug-in! public virtual void HandleButtonClickedEvent(object sender, ButtonEventArgs buttonArgs) { //we already know what state we're in, and what state we //need to go to. The local property will update the button's //when it's changed. GameLog.Log(this.trackingIsGood+" --this.gameState--------------------------------------" + this.gameState); switch (this.gameState) { case SensorState.DeviceReady: // DeviceReady -> Scanning if (this.MainCamera.GetComponent<PinchToScale>() != null) { this.MainCamera.GetComponent<PinchToScale>().enablePinchToScale = false; } //tell StructurePlugin to start scanning StructureARPlugin.startScanning(); this.gameState = SensorState.Scanning; break; case SensorState.Scanning: // Scanning -> WaitingForMesh if (this.trackingIsGood) { //tell StructurePlugin to finish scanning. //this finishes up the scanning session, when the //mesh is finished, it's sent to the wireframe //object where it's copied over. //the HandleStructureEvent gets ScannedMeshReady where //the construction of the mesh is completed. StructureARPlugin.doneScanning(); this.BuildScannedMesh(); this.gameState = SensorState.WaitingForMesh; } else { if (this.MainCamera.GetComponent<PinchToScale>() != null) { this.MainCamera.GetComponent<PinchToScale>().enablePinchToScale = true; } //clear scanned mesh this.ClearScannedMesh(); StructureARPlugin.resetScanning();//tell StructurePlugin to reset the scanned data. this.gameState = SensorState.DeviceReady; } break; case SensorState.WaitingForMesh: // WaitingForMesh -> Playing break; case SensorState.Playing: // Playing -> DeviceReady if (this.MainCamera.GetComponent<PinchToScale>() != null) { this.MainCamera.GetComponent<PinchToScale>().enablePinchToScale = true; } //clear scanned mesh this.ClearScannedMesh(); StructureARPlugin.resetScanning();//tell StructurePlugin to reset the scanned data. this.gameState = SensorState.DeviceReady; break; default: GameLog.Log(this.ToString() + " -- unhandled game state for button" + buttonArgs.toState); break; } }
/// <summary> /// Raises the button click event. /// </summary> ///*********************** IMPORTANT *********************** /// this is the method that sends the start, done and reset /// commands to the plug-in! public virtual void HandleButtonClickedEvent(object sender, ButtonEventArgs buttonArgs) { //we already know what state we're in, and what state we //need to go to. The local property will update the button's //when it's changed. switch (this.gameState) { case SensorState.DeviceReady: // DeviceReady -> Scanning if (this.MainCamera.GetComponent <PinchToScale>() != null) { this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = false; } //tell StructurePlugin to start scanning StructureARPlugin.startScanning(); this.gameState = SensorState.Scanning; break; case SensorState.Scanning: // Scanning -> WaitingForMesh if (this.trackingIsGood) { //tell StructurePlugin to finish scanning. //this finishes up the scanning session, when the //mesh is finished, it's sent to the wireframe //object where it's copied over. //the HandleStructureEvent gets ScannedMeshReady where //the construction of the mesh is completed. StructureARPlugin.doneScanning(); this.gameState = SensorState.WaitingForMesh; } else { if (this.MainCamera.GetComponent <PinchToScale>() != null) { this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = true; } //clear scanned mesh this.ClearScannedMesh(); StructureARPlugin.resetScanning(); //tell StructurePlugin to reset the scanned data. this.gameState = SensorState.DeviceReady; } break; case SensorState.WaitingForMesh: // WaitingForMesh -> Playing UploadScannedMesh(); break; case SensorState.Playing: // Playing -> DeviceReady if (this.MainCamera.GetComponent <PinchToScale>() != null) { this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = true; } //clear scanned mesh this.ClearScannedMesh(); StructureARPlugin.resetScanning(); //tell StructurePlugin to reset the scanned data. this.gameState = SensorState.DeviceReady; break; default: GameLog.Log(this.ToString() + " -- unhandled game state for button" + buttonArgs.toState); break; } }