//inherit old events then send out new ones for
        //the cat and any other objects assigned to the event.
		protected override void HandleStructureEvent(object sender, StructureARPluginEventArgs structureArgs)
        {
			base.HandleStructureEvent(sender, structureArgs);

            if(HoverCatGameEvent == null)
            {
                return;
            }

            switch(structureArgs.eventType)
            {
                case StructureARPluginEvent.TrackingLost:
					if(this.trackingIsGood != isCatTracking)
                    {
                        if(this.gameState == SensorState.Playing)
                        {
                            HoverCatEventArgs catArgs = new HoverCatEventArgs(
                                this.gameState, this.trackingIsGood, HoverCatEvent.StateChange);
                            catArgs.catEvent = HoverCatEvent.Hide;
                            HoverCatGameEvent(this, catArgs);
                        }
                        isCatTracking = trackingIsGood;
                    }
                    break;
                
                case StructureARPluginEvent.TrackingFound:
					if(this.trackingIsGood != isCatTracking)
                    {
                        if(this.gameState == SensorState.Playing)
                        {
                            HoverCatEventArgs catArgs = new HoverCatEventArgs(
								this.gameState, this.trackingIsGood,  HoverCatEvent.StateChange);
                            catArgs.catEvent = HoverCatEvent.Show;
                            HoverCatGameEvent(this, catArgs);
                        }
						isCatTracking = trackingIsGood;
                    }
                    break;

                case StructureARPluginEvent.ScannedMeshReady:
					if(this.gameState == SensorState.Playing)
                    {
                        HoverCatEventArgs catArgs = new HoverCatEventArgs(
							this.gameState, this.trackingIsGood, HoverCatEvent.StateChange);
                        catArgs.catEvent = HoverCatEvent.Reset;
                        HoverCatGameEvent(this, catArgs);
                    }
                    break;

				case StructureARPluginEvent.CameraAccessRequired:
                case StructureARPluginEvent.SensorDisconnected:
				case StructureARPluginEvent.SensorNeedsCharging:
					if(this.gameState == SensorState.Playing)
                    {
                        HoverCatEventArgs catArgs = new HoverCatEventArgs(
							this.gameState, this.trackingIsGood, HoverCatEvent.StateChange);
                        catArgs.catEvent = HoverCatEvent.Hide;
                        HoverCatGameEvent(this, catArgs);
                    }
                    break;

                case StructureARPluginEvent.SensorConnected:
					if(this.gameState == SensorState.Playing)
                    {
                        HoverCatEventArgs catArgs = new HoverCatEventArgs(
							this.gameState, this.trackingIsGood, HoverCatEvent.StateChange);
                        catArgs.catEvent = HoverCatEvent.Show;
                        HoverCatGameEvent(this, catArgs);
                    }
                    break;

                case StructureARPluginEvent.UpdateProjectionMatrix:
                default:
                    break;
            }
        }
Beispiel #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;
            }
        }
Beispiel #3
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;
            }
        }