Inheritance: IAccelerometerReading
示例#1
0
        private void calcDirection(AccelerometerReading reading)
        {
            //Debug.WriteLine("{0}", reading.AccelerationX);
            // Standing still by default
            Direction = Directions.ON_PAUSE;

            // Only move whilst in the right Y-position
            if (reading.AccelerationY > -0.75)
                if (reading.AccelerationX < -0.15)
                    Direction = Directions.NORTH_WEST;
                else if (reading.AccelerationX > 0.15)
                    Direction = Directions.NORTH_EAST;
                else
                    Direction = Directions.NORTH;

            else if (reading.AccelerationY < -0.85)
                if (reading.AccelerationX < -0.15)
                    Direction = Directions.SOUTH_WEST;
                else if (reading.AccelerationX > 0.15)
                    Direction = Directions.SOUTH_EAST;
                else
                    Direction = Directions.SOUTH;

            else if (reading.AccelerationX < -0.15)
                Direction = Directions.WEST;
            else if (reading.AccelerationX > 0.15)
                Direction = Directions.EAST;
            
        }
 public AccelerometerSample(AccelerometerReading accelerometerReading, DateTimeOffset _startDateTime)
 {
     this.MeasurementTime = accelerometerReading.Timestamp.Subtract(_startDateTime);
     this.CoordinateX = Convert.ToSingle(accelerometerReading.AccelerationX);
     this.CoordinateY = Convert.ToSingle(accelerometerReading.AccelerationY);
     this.CoordinateZ = Convert.ToSingle(accelerometerReading.AccelerationZ);
 }
示例#3
0
 void accelerometer_ReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
 {
     Deployment.Current.Dispatcher.BeginInvoke(() =>
     {
         accelerometerReading = args.Reading;
         ShowData();
     });
 }
示例#4
0
 static Vector ConvertToVector(AccelerometerReading reading)
 {
     return new Vector
     {
         X = reading.AccelerationX,
         Y = reading.AccelerationY,
         Z = reading.AccelerationZ
     };
 }
 private static MvxAccelerometerReading ToReading(AccelerometerReading sensorReading)
 {
     var reading = new MvxAccelerometerReading
         {
             X = sensorReading.AccelerationX,
             Y = sensorReading.AccelerationY,
             Z = sensorReading.AccelerationZ,
         };
     return reading;
 }
示例#6
0
        private void ReadingChanged(object sender, Sensors.AccelerometerReadingChangedEventArgs e)
        {
            Sensors.AccelerometerReading reading = e.Reading;

            this.SendEvent("Accelerometer", new RNSensorsJsonObject
            {
                X         = reading.AccelerationX,
                Y         = reading.AccelerationY,
                Z         = reading.AccelerationZ,
                Timestamp = reading.Timestamp
            }.ToJObject());
        }
示例#7
0
        //Событие изменения показаний акселерометра
        async private void ReadingChanged(object sender, AccelerometerReadingChangedEventArgs e)
        {
            if (!m_isStarted)
            {
                return;
            }

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Windows.Devices.Sensors.AccelerometerReading reading = e.Reading;
                SendRollCommand(reading.AccelerationX, reading.AccelerationY, reading.AccelerationZ);
            });
        }
示例#8
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     accelerometer = Accelerometer.GetDefault();
     if (accelerometer == null)
     {
         MessageBox.Show("不支持加速度计传感器");
         return;
     }
     Debug.WriteLine(accelerometer.MinimumReportInterval);
     accelerometer.ReportInterval = accelerometer.MinimumReportInterval * 2;
     accelerometer.ReadingChanged += accelerometer_ReadingChanged;
     accelerometer.Shaken += accelerometer_Shaken;
     accelerometerReading = accelerometer.GetCurrentReading();
     ShowData();
 }
        public void AddAcceleration(AccelerometerReading acceleration)
        {
            if (AbsoluteValue(acceleration) < MaxAcceleration)
            {
                DecreaseAgresivityIfDrivingGoodForRequiredAmountOfTime();
                return;
            }

            _accelerations.Add(acceleration);
            if (IsEraticAccelerationPeriodExceeded())
            {
                Agresivity += GetEraticAccelerationPenalty();
                _accelerations.Clear();
                _lastIncidentDate = DateTime.Now;
                PersistData();
            }
        }
示例#10
0
        private void ReadingChanged(object sender, Sensors.AccelerometerReadingChangedEventArgs e)
        {
            Sensors.AccelerometerReading reading = e.Reading;

            if (_lastReading.AddMilliseconds(interval) <= reading.Timestamp)
            {
                _lastReading = reading.Timestamp;

                this.SendEvent("Accelerometer", new RNSensorsJsonObject
                {
                    X         = reading.AccelerationX,
                    Y         = reading.AccelerationY,
                    Z         = reading.AccelerationZ,
                    Timestamp = reading.Timestamp
                }.ToJObject());
            }
        }
示例#11
0
        private void updateMyScreen(AccelerometerReadingChangedEventArgs e)
        {
            // updates the textblocks

            previousReading = currentReading;
            currentReading = e.Reading;

            if (previousReading != null)
            {

                double xValue = currentReading.AccelerationX - previousReading.AccelerationX;
                double yValue = currentReading.AccelerationY - previousReading.AccelerationY;
                double zValue = currentReading.AccelerationZ - previousReading.AccelerationZ;

                if (xValue < 0) xValue -= 2 * xValue;
                if (yValue < 0) yValue -= 2 * yValue;
                if (zValue < 0) zValue -= 2 * zValue;

                data_width.Text = String.Format("{0,5:0.00}", xValue);
                data_length.Text = String.Format("{0,5:0.00}", yValue);
                data_depth.Text = String.Format("{0,5:0.00}", zValue);

                // draws on the canvas

                double currentXOnGraph = Math.Abs((xValue * 200) - 200);
                double currentYOnGraph = Math.Abs((yValue * 200) - 200);
                double currentZOnGraph = Math.Abs((zValue * 200) - 200);

                Rectangle xPoint = new Rectangle();
                Rectangle yPoint = new Rectangle();
                Rectangle zPoint = new Rectangle();

                xPoint.Fill = new SolidColorBrush(Colors.Red);
                yPoint.Fill = new SolidColorBrush(Colors.Blue);
                zPoint.Fill = new SolidColorBrush(Colors.Green);

                // set the pixel size 

                xPoint.Width = 1;
                xPoint.Height = 2;
                yPoint.Width = 1;
                yPoint.Height = 2;
                zPoint.Width = 1;
                zPoint.Height = 2;

                // These pixels will be "pasted into" the canvas by setting their position 
                // according to the currentX/Y/Z-on-graph values. To set their position 
                // relative to the canvas, pass the canvas properties on to the pixels via 
                // the SetValue method. Use a generic iterator to determine the distance 
                // the pixel should be from the left side of the canvas.

                xPoint.SetValue(Canvas.LeftProperty, iterateur);
                xPoint.SetValue(Canvas.TopProperty, currentXOnGraph);
                yPoint.SetValue(Canvas.LeftProperty, iterateur);
                yPoint.SetValue(Canvas.TopProperty, currentYOnGraph);
                zPoint.SetValue(Canvas.LeftProperty, iterateur);
                zPoint.SetValue(Canvas.TopProperty, currentZOnGraph);

                // finally, associate pixels with the canvas

                my_canvas.Children.Add(xPoint);
                my_canvas.Children.Add(yPoint);
                my_canvas.Children.Add(zPoint);

                if (iterateur == 399)
                {
                    my_canvas.Children.Clear();
                    iterateur = 0;
                }
                else
                {
                    iterateur++;
                }
            }

        }
示例#12
0
        // 通过加速度控制小球的运动
        private void MyReadingChanged(AccelerometerReading e)
        {
#if DEBUG
            XTextBlock.Text = "X:" + e.AccelerationX;
            YTextBlock.Text = "Y:" + e.AccelerationY;
            ZTextBlock.Text = "Z:" + e.AccelerationZ;
#endif

            double accelerationFactor = Math.Abs(e.AccelerationZ) == 0 ? 0.1 : Math.Abs(e.AccelerationZ);

            pcAccX = e.AccelerationX;
            pcAccY = e.AccelerationY;
            pcAccZ = e.AccelerationZ;

            double AccX = e.AccelerationX - double.Parse(appSetting.Values["pcX"].ToString());
            double AccY = e.AccelerationY - double.Parse(appSetting.Values["pcY"].ToString());
            double AccZ = e.AccelerationZ - double.Parse(appSetting.Values["pcZ"].ToString());

            if (Math.Abs(AccX - oldAccX) > 0.02 || Math.Abs(AccY - oldAccY) > 0.02 || Math.Abs(AccZ - oldAccZ) > 0.02)
            {
                double SumWidth = BackGroundCanvas.Width / 2 - BallImage.Width / 2;

                double MarX;
                double MarY;
                double RenX = AccX / 1 * 90; ;
                double RenY = AccY / 1 * 90; ;

                if (AccX < 0)
                {
                    MarX = SumWidth + (-AccX) / 1 * SumWidth;
                }
                else
                {
                    MarX = SumWidth - AccX / 1 * SumWidth;
                }
                if (AccY < 0)
                {
                    MarY = SumWidth + AccY / 1 * SumWidth;
                }
                else
                {
                    MarY = SumWidth + AccY / 1 * SumWidth;
                }

                BallImage.Margin = new Thickness(MarX, MarY, 0, 0);
                phone1Image.RenderTransform.SetValue(RotateTransform.AngleProperty, RenX);
                phone2Image.RenderTransform.SetValue(RotateTransform.AngleProperty, RenY);
                Angle1TextBlock.Text = String.Format("{0:F}", RenX) + "°";
                Angle2TextBlock.Text = String.Format("{0:F}", RenY) + "°";

                oldAccX = AccX;
                oldAccY = AccY;
                oldAccZ = AccZ;

            }

            if (Math.Abs(AccX) > 0.15 || Math.Abs(AccY) > 0.15 || Math.Abs(AccZ) > 0.15)
            {
                Setting.IsEnabled = false;
            }
            else
            {
                Setting.IsEnabled = true;
            }
        }
示例#13
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                // Update the keyboard and mouse state
                keyboardState = keyboardManager.GetState();
                mouseState = mouseManager.GetState();
                mouseManager.SetPosition(mouseCenter);
                accelerometerReading = input.accelerometer.GetCurrentReading();

                // Check collisions
                for (var i = 0; i < allBalls.Count; i++)
                {
                    if (!allBalls[i].Equals(player) && player.CollidedWith(allBalls[i]))
                        {
                            player.Collide(allBalls[i]);
                        }
                }

                // Quit
                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }

                // Update camera based on the above
                camera.Update(gameTime, keyboardState, mouseState);

                // Finally update models
                landscape.Update(gameTime);
                sun.Update(gameTime);

                // Update balls
                for (var i = 0; i < allBalls.Count; i++)
                {
                    allBalls[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                // Handle base.Update
                base.Update(gameTime);
            }
        }
示例#14
0
 public void setAccelerometerReading(AccelerometerReading reading)
 {
     this.acceleration_x = reading.AccelerationX;
     this.acceleration_y = reading.AccelerationY;
     this.acceleration_z = reading.AccelerationZ;
 }
示例#15
0
        /// <summary>
        /// Frame update method.
        /// </summary>
        /// <param name="gameTime">Time since last update.</param>
        protected override void Update(GameTime gameTime)
        {
            if (started) //Do nothing if the game has not started
            {
                if (gameOver == true)   //Exit if you lose. NO SECOND CHANCES
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                    return;
                }

                keyboardState = keyboardManager.GetState(); //Get keyboard state
                flushAddedAndRemovedGameObjects();          //Add and remove waiting objects
                camera.Update();                            //Update the camera first
                accelerometerReading = input.accelerometer.GetCurrentReading(); //Read accelerometers
                for (int i = 0; i < gameObjects.Count; i++) //Update all other game objects and entities
                {
                    gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);    //Increment the player score
                mainPage.UpdateHitpoints(player.hitpoints); //Adjust the hitpoints display

                if (keyboardState.IsKeyDown(Keys.Escape)) //Exit the game when escape is mashed
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }

            }
            else
            {
                windowHeight = Window.ClientBounds.Height;
                windowWidth = Window.ClientBounds.Width;
            }

            // Handle base.Update
            base.Update(gameTime);
        }
示例#16
0
 private void OnReadingChanged(AccelerometerReading reading)
 {
     _readingChanged?.Invoke(this, new AccelerometerReadingChangedEventArgs(reading));
 }
        private void UpdateUI( AccelerometerReading reading )
        {
            statusTextBlock.Text = "getting data";

            // Show the numeric values.
            xTextBlock.Text = "X: " + reading.AccelerationX.ToString( "0.00" );
            yTextBlock.Text = "Y: " + reading.AccelerationY.ToString( "0.00" );
            zTextBlock.Text = "Z: " + reading.AccelerationZ.ToString( "0.00" );

            // Show the values graphically.
            xLine.X2 = xLine.X1 + reading.AccelerationX * 200;
            yLine.Y2 = yLine.Y1 - reading.AccelerationY * 200;
        }
示例#18
0
 private void AccelerometerOnReadingChanged(Accelerometer sender, AccelerometerReadingChangedEventArgs args)
 {
     _lastAccelerometerReading = args.Reading;
 }
示例#19
0
        protected override void Update(GameTime gameTime)
        {
            currentPositionInMazeArray = sphere.PositionInMaze(sphere.pos);
            if (started&&resumed)
            {
                currentGameTimeSecond += gameTime.ElapsedGameTime.TotalSeconds;
                keyboardState = keyboardManager.GetState();
                flushAddedAndRemovedGameObjects();
                accelerometerReading = input.accelerometer.GetCurrentReading();
                for (int i = 0; i < gameObjects.Count; i++)
                {
                   gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }
                camera.Update();
                // Handle base.Update

            }

            if (currentPositionInMazeArray.X == mazeLandscape.maze.destX &&
                currentPositionInMazeArray.Y == mazeLandscape.maze.destY)
            {
                if (completeScreen == null)
                {
                    completeScreen = new CompleteScreen(mainPage, this, currentGameTimeSecond);
                }
                if( !mainPage.Children.Contains(completeScreen))
                {
                    mainPage.Children.Add(completeScreen);
                }
            }

            base.Update(gameTime);
        }
示例#20
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                keyboardState = keyboardManager.GetState();
                flushAddedAndRemovedGameObjects();

                accelerometerReading = input.accelerometer.GetCurrentReading();
                gyrometerReading = input.gyrometer.GetCurrentReading();

                camera.Update();
                for (int i = 0; i < gameObjects.Count; i++)
                {
                    gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }
                // Handle base.Update
            }
            base.Update(gameTime);
        }
        /// <summary>
        /// Update the state of all desired input devices.
        /// </summary>
        /// <param name="gameTime"></param>
        override public void Update(GameTime gameTime)
        {   
            // update state
            keyboardManager.Update(gameTime);
            keyboardState = keyboardManager.GetState();
            mouseState = mouseManager.GetState();
            pointerState = pointerManager.GetState();

              
            //mouseClick = mouseState.LeftButton.Pressed && !prevMouseState.LeftButton.Pressed;
            //mouseHeld = mouseState.LeftButton.Pressed && prevMouseState.LeftButton.Pressed;

            if (accelerometer != null) {
                accelerometerReading = accelerometer.GetCurrentReading();
                
            }

            // get mouse delta and reset mouse to centre of window
            if (useMouseDelta && mouseManager.Enabled) {
                mouseDelta = new Vector2(0.5f - mouseState.X, 0.5f - mouseState.Y);
                mouseManager.SetPosition(new Vector2(0.5f, 0.5f));
            }

            // record previous mouse state
            prevMouseState = mouseState;

 	        base.Update(gameTime);
        }
 private static double AbsoluteValue(AccelerometerReading acceleration)
 {
     return acceleration.AccelerationX * acceleration.AccelerationX + 
         acceleration.AccelerationY * acceleration.AccelerationY + 
         acceleration.AccelerationZ * acceleration.AccelerationZ;
 }
 public static void SetReadingText(TextBlock textBlock, AccelerometerReading reading)
 {
     textBlock.Text = string.Format("X: {0,5:0.00}, Y: {1,5:0.00}, Z: {2,5:0.00}",
         reading.AccelerationX, reading.AccelerationY, reading.AccelerationZ);
 }
示例#24
0
 protected override void Update(GameTime gameTime)
 {
     keyboardState = keyboardManager.GetState();
     if (started)
     {
         if (player.HasWon())
         {
             GraphicsDevice.Clear(Color.Black);
             mainPage.WinGame();
             return;
         }
         if (keyboardState.IsKeyDown(Keys.Q))
         {
             mainPage.QuitGame();
         }
         DoGhostStuff();
         flushAddedAndRemovedGameObjects();
         accelerometerReading = input.accelerometer.GetCurrentReading();
         player.Update(gameTime);
         for (int i = 0; i < gameObjects.Count; i++)
         {
             gameObjects[i].Update(gameTime);
         }
         mainPage.UpdateLives(player.ghostEncounters);
     }
     if (keyboardState.IsKeyDown(Keys.Escape))
     {
         this.Exit();
         this.Dispose();
         App.Current.Exit();
     }
     base.Update(gameTime);
 }
 private Vector ToVector(AccelerometerReading r)
 {
     return new Vector((float)r.AccelerationX, (float)r.AccelerationY, (float)r.AccelerationZ);
 }
 private void ForceReadingUpdated(AccelerometerReading reading)
 {
    _forceReading = reading;
    if (_state == GenerationState.Gathering)
    {
       ForceX.Value = reading.AccelerationX;
       ForceY.Value = reading.AccelerationY;
       ForceZ.Value = reading.AccelerationZ;
    }
 }
示例#27
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                if (!player.alive)
                {
                    Platform.z_position = 0;
                    Platform.last_platform = new int[,] { { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 } };
                    Platform.next_platform = new int[,] { { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 } };

                    Platform.standing_platform = null;
                    Platform.next_standing_platform = null;
                    SetGameObjects();
                    started = false;
                    mainPage.EndGame(score);
                }
                else
                {
                    lightManager.Update();
                    keyboardState = keyboardManager.GetState();
                    flushAddedAndRemovedGameObjects();

                    // pass gameTime to let camera move along
                    camera.Update(gameTime, player.pos);

                    accelerometerReading = input.accelerometer.GetCurrentReading();

                    for (int i = 0; i < gameObjects.Count; i++)
                    {
                        gameObjects[i].Update(gameTime);
                    }

                    // Update score board on the game page
                    mainPage.UpdateScore(score);

                    // Update camera and player position for testing
                    mainPage.DisplayCameraPlayerPos(camera.Position, camera.cameraPos, player.pos, player.max_speed);
                    mainPage.UpdateShootButton(player.fireOn);

                    if (keyboardState.IsKeyDown(Keys.Escape))
                    {
                        this.Exit();
                        this.Dispose();
                        App.Current.Exit();
                    }
                    // Handle base.Update
                }
            }
            base.Update(gameTime);
        }
示例#28
0
        protected override void Update(GameTime gameTime)
        {
            keyboardState = keyboardManager.GetState();

            if (gameStarted)
            {

                // set the postition of the cannonball base on the landscape
                cannonModel.basicEffect.World = Matrix.RotationY(rotationY) * Matrix.Scaling(0.0003f) * Matrix.Translation(x0, y0 + 0.05f, z0);
                arrow.basicEffect.World = Matrix.Scaling(0.003f) * Matrix.Translation(x1, y1 + 0.3f + (float)arrow.ywave, z1);

                arrow.Update(gameTime);
                Debug.WriteLine(arrow.pos);

                accreading = input.accelerometer.GetCurrentReading();

                xadjust = (float) accreading.AccelerationX;

                if (!LaunchMode)
                {

                    launchViewUpdate();
                    //aim Cannon
                    rotationY = (float)((180 - degree) * Math.PI / 180);
                    if (keyboardState.IsKeyDown(Keys.Left))
                    {
                        rotationY -= speed;
                    }
                    if (keyboardState.IsKeyDown(Keys.Right))
                    {
                        rotationY += speed;
                    }
                    if (xadjust < 0.3 && xadjust > -0.3)
                    {
                        xadjust = 0;
                    }
                    rotationY += xadjust * 0.2f;

                    this.degree = 180 - rotationY / Math.PI * 180;
                    degree = this.mainpage.getDegreeValue();
                    this.mainpage.UpdateDegreeSlider((int)degree);

                }
                else
                {
                    //cannonball in air
                    CameraViewupdate();
                    Vector3 distanceMissed = new Vector3(landscape.getTargetPos().Position.X - ballMovement.pos.X,
                                                             landscape.getTargetPos().Position.Y - ballMovement.pos.Y,
                                                             landscape.getTargetPos().Position.Z - ballMovement.pos.Z);
                    if (justLaunched)
                    {

                //        BallViewUpdate();
                        attemptCount++;
                        mainpage.updateattempt(attemptCount);
                        justLaunched = false;
                    }
                    if (landscape.getHeight(ballMovement.pos.X, ballMovement.pos.Y) < ballMovement.pos.Y + 0.01f && !(distanceMissed.Length() < 0.1))
                    {
                        time += 0.004f;
                      //  this.ballParabolaMovement(time, this.x0, this.y0, this.z0, this.yDegree, this.degree);
                        if (landscape.getHeight(ballMovement.pos.X, ballMovement.pos.Y) < ballMovement.pos.Y)
                            ballMovement.Update(gameTime);
                        //  accelerometerReading = input.accelerometer.GetCurrentReading();
                        // this.degree += (float)accelerometerReading.AccelerationX;
                        //adjust path of ball
                        if (keyboardState.IsKeyDown(Keys.Left))
                        {
                            this.degree += 0.05f;

                        }
                        if (keyboardState.IsKeyDown(Keys.Right))
                        {
                            this.degree -= 0.05f;
                        }

                        this.degree += (float)-xadjust;

                    }
                    else
                    {
                        //next level
                        this.mainpage.viewLaunchControls();
                        LaunchMode = false;
                        time = 0;
                       //if win generate new level and update score
                        if(distanceMissed.Length() <0.1){
                            score +=(int)(10*difficulty);
                            difficulty += 1;
                            mainpage.UpdateScore(score);
                            if (attemptCount < bestAttempt || bestAttempt == 0)
                            {
                                bestAttempt = attemptCount;
                                attemptCount = 0;
                            }
                            mainpage.bestAttempt(bestAttempt);
                            mainpage.returnToMenu();
                            mainpage.hideLaunchControls();
                            this.LoadContent();
                        }

                    }
                }
                //accelerometerReading = input.accelerometer.GetCurrentReading();

                for (int i = 0; i < gameObjects.Count; i++)
                {
                    gameObjects[i].Update(gameTime);
                }

             /*   if (keyboardState.IsKeyDown(Keys.Tab) && isTabDown)
                {
                    isTabDown = false;
                    if (ballview)
                    {
                      /*  ballMovement.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                        landscape.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                        cannonModel.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);
                      arrow.basicEffect.View = Matrix.LookAtLH(initMatrix, emptyMatrix, Vector3.UnitY);*/
            /*                BallViewUpdate();
                        ballview = false;
                    }
                    else
                    {
                        ballview = true;
                    }
                }
                if (keyboardState.IsKeyUp(Keys.Tab))
                {
                    isTabDown = true;
                }

                if (ballview)
                {
                    CameraViewupdate();
                }
                else
                {
                    target1 = new Vector3(4, 0, -4);
                    target2 = landscape.getCannonPos().Position;
                    eye.X = target2.X - 0.1f * (target1.X - target2.X);
                    eye.Y = target2.Y - 0.1f * (target1.Y - target2.Y) + 0.1f;
                    eye.Z = target2.Z - 0.1f * (target1.Z - target2.Z);
                    // eye = new Vector3(target2.X - 1.0f, target2.Y + 0.3f, target2.Z - 1.0f);
                    up = Vector3.UnitY;
                    ballMovement.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    landscape.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    cannonModel.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    arrow.basicEffect.View = Matrix.LookAtLH(eye, target2, up);
                    cannonModel.basicEffect.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)cannonModel.game.GraphicsDevice.BackBuffer.Width / ballMovement.game.GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f);
                }*/
                ballMovement.basicEffect.World = Matrix.Scaling(0.01f) * Matrix.Translation(ballMovement.pos);

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                }
                // Handle base.Update
                //mainpage.UpdateScore(score);
                base.Update(gameTime);
            }
        }
 internal AccelerometerReadingChangedEventArgs(AccelerometerReading reading)
 {
     Reading = reading;
 }
 /// <summary>
 /// Updates the accelerometer's axis.
 /// </summary>
 /// <param name="accelerometerReading">The value of reading on accelerometer.</param>
 private void UpdateAccelerometerAxis(AccelerometerReading accelerometerReading)
 {
     X = accelerometerReading.AccelerationX;
     Y = accelerometerReading.AccelerationY;
     Z = accelerometerReading.AccelerationZ;
 }
 private void UpdateUI( AccelerometerReading reading )
 {
     statusTextBlock.Text = "getting data";
 }
 //################################################## Accelerometer ##################################################
 /// <summary>
 /// Adds a new accelerometer reading into the active accelerometer reading list.
 /// </summary>
 /// <param name="accelerometerReading"></param>
 public void AddAccelerometerReading(AccelerometerReading accelerometerReading)
 {
     if (accelerometerReading != null)
     {
         if (_startDateTime.CompareTo(DateTimeOffset.MinValue) == 0)
         {
             _startDateTime = accelerometerReading.Timestamp;
         }
         this.AddAccelerometerSample(new AccelerometerSample(accelerometerReading, _startDateTime));
     }
 }