private void HandleSensorReadingChanged(object sender, AccelerometerReadingAsyncEventArgs e) { if (this.ReadingChanged != null) { AccelerometerState newState = new AccelerometerState(); newState.X = e.Value.Value.X; newState.Y = e.Value.Value.Y; newState.Z = e.Value.Value.Z; this.ReadingChanged(newState); } }
void _gameCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { _dragging = false; _projection.RotationX = 0; _projection.RotationY = 0; AccelerometerState newState = new AccelerometerState(); newState.X = 0; newState.Y = 0; newState.Z = 0; ReadingChanged(newState); }
void _gameCanvas_MouseMove(object sender, MouseEventArgs e) { if (_dragging) { double percentBuffer = 0.001; double projectionFactor = 100; double governorOnRotation = .3; Point ptCurrent = e.GetPosition(_gameCanvas); double changeX = (_ptStart.X - ptCurrent.X) * percentBuffer; double changeY = -(_ptStart.Y - ptCurrent.Y) * percentBuffer; // *ACK* THIS IS A GOVERNOR ON THE MAX TRANSFORM! if (changeX > governorOnRotation) { changeX = governorOnRotation; } if (changeX < -governorOnRotation) { changeX = -governorOnRotation; } if (changeY > governorOnRotation) { changeY = governorOnRotation; } if (changeY < -governorOnRotation) { changeY = -governorOnRotation; } _projection.RotationY = changeX * projectionFactor; _projection.RotationX = changeY * projectionFactor; AccelerometerState newState = new AccelerometerState(); newState.Y = changeY; newState.X = changeX; ReadingChanged(newState); } }