示例#1
0
        public void HandleHoverCatButtonClickedEvent(object sender, HoverCatButtonEventArgs buttonArgs)
        {
            switch (this.gameState)
            {
            case SensorState.DeviceReady:
                this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = false;
                StructureARPlugin.startScanning();    //tell StructurePlugin to start scanning
                this.gameState = SensorState.Scanning;
                break;

            case SensorState.Scanning:
                StructureARPlugin.doneScanning();    //tell StructurePlugin to finish scanning.
                this.gameState = SensorState.WaitingForMesh;
                break;

            case SensorState.WaitingForMesh:    //ignore buttons.
                break;

            case SensorState.Playing:

                if (buttonArgs.catButtonEvent == HoverCatButtonEvent.ResetGame)
                {
                    this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = true;
                    structureObjectLoader.ClearMesh(this.scanObject);
                    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.catButtonEvent);
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Raises the structure AR event event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="structureArgs">Structure arguments.</param>
        protected virtual void HandleStructureEvent(object sender, StructureARPluginEventArgs structureArgs)
        {
            switch (structureArgs.eventType)
            {
            case StructureARPluginEvent.SensorConnected:
                if (this.gameState == SensorState.DeviceNotReady)
                {
                    if (this.MainCamera.GetComponent <PinchToScale>() != null)
                    {
                        this.MainCamera.GetComponent <PinchToScale>().enablePinchToScale = true;
                    }

                    //clear the scanned mesh
                    this.ClearScannedMesh();

                    StructureARPlugin.resetScanning();    //tell StructurePlugin to reset the scanned data.
                }
                this.gameState = SensorState.DeviceReady;
                break;

            case StructureARPluginEvent.CameraAccessRequired:
                this.gameState = SensorState.CameraAccessRequired;
                if (StructureARGameEvent != null)
                {
                    StructureARGameEvent(this, new GameEventArgs(this.gameState, true));
                }
                break;

            case StructureARPluginEvent.SensorNeedsCharging:
                this.gameState = SensorState.DeviceNeedsCharging;
                break;

            case StructureARPluginEvent.SensorDisconnected:
                this.gameState = SensorState.DeviceNotReady;
                break;

            case StructureARPluginEvent.UpdateProjectionMatrix:
                if (this.MainCamera != null)
                {
                    this.MainCamera.projectionMatrix = StructureARPlugin.projectionMatrix;
                }
                break;

            case StructureARPluginEvent.ScannedMeshReady:
                // this constructs the mesh from the scanned data
                // and will be called once we have a mesh ready to build
                this.BuildScannedMesh();
                this.gameState = SensorState.Playing;
                break;

            case StructureARPluginEvent.TrackingLost:
                if (this.trackingIsGood == true)
                {
                    if (StructureARGameEvent != null)
                    {
                        StructureARGameEvent(this, new GameEventArgs(this.gameState, false));
                    }
                    this.trackingIsGood = false;
                }
                break;

            case StructureARPluginEvent.TrackingFound:
                if (this.trackingIsGood == false)
                {
                    if (StructureARGameEvent != null)
                    {
                        StructureARGameEvent(this, new GameEventArgs(this.gameState, true));
                    }
                    this.trackingIsGood = true;
                }
                break;

            default:
                break;
            }
        }
示例#3
0
        /// <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;
            }
        }