public void initGyro() { if(gyroActive) { if(gyroPivot == null) { originalParent = transform.parent; gyroPivot = new GameObject("GyroPivot"); gyroPivot.transform.position = transform.position; transform.parent = gyroPivot.transform; gyroPivot.transform.parent = originalParent; // GetComponent<SceneControl>().gyroPivot = gyroPivot; } gyro = Input.gyro; gyro.enabled = true; #if UNITY_IPHONE InitGyroIPhone(); #elif UNITY_ANDROID InitGyroAndroid(); #endif } }
// Use this for initialization void Start () { Transform originalParent = transform.parent; // check if this transform has a parent GameObject camParent = new GameObject ("camParent"); // make a new parent camParent.transform.position = transform.position; // move the new parent to this transform position transform.parent = camParent.transform; // make this transform a child of the new parent camParent.transform.parent = originalParent; // make the new parent a child of the original parent gyroBool = Input.isGyroAvailable; if (gyroBool) { gyro = Input.gyro; gyro.enabled = true; //Debug.Log("Orientation:"+Screen.orientation); camParent.transform.eulerAngles = new Vector3(90,180,0); rotFix =new Quaternion(0f,0f,1f,0f); //Screen.sleepTimeout = 0; } else { print("NO GYRO"); } }
void Start () { if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyro.enabled = true; } }
// Constructor public MainPage() { InitializeComponent(); // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); timer = new DispatcherTimer(); timer.Tick += timer_Tick; timer.Interval = TimeSpan.FromMilliseconds(66); if (Accelerometer.IsSupported) { accelSensor = new Accelerometer(); accelSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); } if (Compass.IsSupported) { compassSensor = new Compass(); compassSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); compassSensor.Calibrate += compassSensor_Calibrate; } if (Gyroscope.IsSupported) { gyroSensor = new Gyroscope(); gyroSensor.TimeBetweenUpdates = TimeSpan.FromMilliseconds(66); } }
private float mf_snapToPointOffsetRotation = 0f; // mf_snapToPointOffsetRotation: The 'center-to-screen' y-axis offset // Private Functions // Awake(): is called at the start of the program void Awake() { // Gyroscope Initialisation m_Gyroscope = UnityEngine.Input.gyro; m_Gyroscope.enabled = true; // if: There is no rotation pivot assigned, the current gameObject will be assigned instead if (m_RotationPivot == null) m_RotationPivot = this.transform; // Initialisation m_vectorFromPivot = this.transform.position - m_RotationPivot.transform.position; m_initialRotationOnAwake = transform.rotation; m_initialPivotRotationOnAwake = m_RotationPivot.rotation; m_inverseInitialRotationOnAwake = Quaternion.Inverse(m_initialRotationOnAwake); UpdateGyroscopeRotation(); // This line fixed the x-axis problem transform.Rotate(Vector3.right, -m_initialRotationOnAwake.eulerAngles.x * 2f); // Editor cameraRotationX = transform.localEulerAngles.x; cameraRotationY = transform.localEulerAngles.y; if (mbLockNHideCursor) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } }
void Start() { Screen.sleepTimeout = SleepTimeout.NeverSleep; gyro = Input.gyro; gyro.enabled = true; Debug.Log("gyro : " + SystemInfo.supportsGyroscope); m_resetButton.enabled = true; }
// Use this for initialization void Start () { if( SystemInfo.supportsGyroscope ) { _g = Input.gyro ; _g.enabled = true ; } _v1 = _v2 = Vector3.zero ; }
//private float mAxisAttitude; // Use this for initialization void Start () { placeClip = GameObject.Find("AUDIO_SNAP").GetComponent<AudioSource>(); gyro = Input.gyro; if(!gyro.enabled) { gyro.enabled = true; } endRotate = rotateHole.transform.up; }
// Use this for initialization void Start() { rb = GetComponent<Rigidbody>(); gyroSupported = SystemInfo.supportsGyroscope; if (gyroSupported) { gyo1 = Input.gyro; gyo1.enabled = true; Debug.Log ("Gyro is not enabled"); } else { Debug.Log("Gyro is not supported"); } }
public void Start () { Transform currentParent = transform.parent; GameObject camParent = new GameObject ("GyroCamParent"); camParent.transform.position = transform.position; transform.parent = camParent.transform; GameObject camGrandparent = new GameObject ("GyroCamGrandParent"); camGrandparent.transform.position = transform.position; camParent.transform.parent = camGrandparent.transform; camGrandparent.transform.parent = currentParent; #if UNITY_3_4 gyroBool = Input.isGyroAvailable; #else gyroBool = SystemInfo.supportsGyroscope; #endif if (gyroBool) { gyro = Input.gyro; gyro.enabled = true; if (Screen.orientation == ScreenOrientation.LandscapeLeft) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.Portrait) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.LandscapeRight) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } if (Screen.orientation == ScreenOrientation.LandscapeLeft) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.Portrait) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.LandscapeRight) { rotFix = new Quaternion (0, 0, 1, 0); } else { rotFix = new Quaternion (0, 0, 1, 0); } transform.localRotation = getQuatMap() * rotFix; } else { #if UNITY_EDITOR print("NO GYRO"); #endif } }
/// <summary> /// Attaches gyro controller to the transform. /// </summary> private static void AttachGyro () { gyroEnabled = SystemInfo.supportsGyroscope; if( !gyroEnabled ){ Debug.LogError("NO GYRO") ; return ; } gyroRef = Input.gyro ; ResetBaseOrientation (); UpdateCalibration (true); UpdateCameraBaseRotation (true); RecalculateReferenceRotation (); }
public GyroscopeSamplePage() { InitializeComponent(); Loaded += (s, e) => { if (Gyroscope.IsSupported) { _g = new Gyroscope(); _g.CurrentValueChanged += GyroscopeCurrentValueChanged; _g.Start(); } }; }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (!Gyroscope.IsSupported) { MessageBox.Show("Ihr Gerät verfügt über keinem Gyroskope!"); return; } lastTimestamp = DateTimeOffset.MinValue; gyro = new Gyroscope(); gyro.CurrentValueChanged += gyro_CurrentValueChanged; gyro.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100); gyro.Start(); }
public void Init() { Transform camParent = transform.parent; // find the current parent of the camera's transform // instantiate a new transform // match the transform to the camera position //camParent.position = transform.position; // make the new transform the parent of the camera transform //transform.parent = camParent; gyro = Input.gyro; gyro.enabled = true; camParent.eulerAngles = new Vector3(90, 0, 0); quatMult = new Quaternion(0, 0, 1, 0); }
void Start() { gyroSupported = SystemInfo.supportsGyroscope; gyroCamera.parent.transform.rotation = Quaternion.Euler(90f, 180f, 0f); if (gyroSupported) { gyro = Input.gyro; gyro.enabled = true; } else { //Your Logic OnGyroIsNotSupported.Invoke(); } }
public Vibe2020DataService(ILogger <Vibe2020DataService> logger) { _logger = logger; try { var settings = new SpiConnectionSettings(1, 0) { Mode = SpiMode.Mode0, ClockFrequency = 1900000 }; _accelerometerDevice = new Accelerometer(settings); } catch (Exception ex) { _logger.LogError("Error Initializing Accelerometer.", ex.Message, ex.StackTrace); } try { var settings = new SpiConnectionSettings(0, 0) { Mode = SpiMode.Mode3, ClockFrequency = 900000 }; _gyroscopeDevice = new Gyroscope(settings); } catch (Exception ex) { _logger.LogError("Error Initializing Gyroscope.", ex.Message, ex.StackTrace); } try { _rtcDevice = new RTC(); } catch (Exception ex) { _logger.LogError("Error Initializing RTC.", ex.Message, ex.StackTrace); } try { _cpuDevice = new CpuTemperature(); } catch (Exception ex) { _logger.LogError("Error Initializing CPU Temp Device.", ex.Message, ex.StackTrace); } }
protected void RegulateAngle(float target_pitch_angle, float target_roll_angle) { if (Application.isEditor) { for (int i = 0; i < 2; i++) { selfLevelers[i].CopySettings(selfLevelerFactory); } } float pitch_val = Gyroscope.Angle2OneMinusOne(gyroscope.GetRotation().x) * 180f; float slp = selfLevelers[0].Regulate(target_pitch_angle - pitch_val); float roll_val = Gyroscope.Angle2OneMinusOne(gyroscope.GetRotation().z) * 180f; float slr = selfLevelers[1].Regulate(target_roll_angle + roll_val); RotPitch(slp); RotRoll(slr); }
public PureMemoryTest() { using (SpiDevice spi = SpiDevice.Create(new SpiConnectionSettings(0, 0) { Mode = SpiMode.Mode0, ClockFrequency = 2000000 })) { _accelerometerDevice = new Mcp3208Custom(spi, (int)Channel.X, (int)Channel.Y, (int)Channel.Z); } //_accelerometerDevice = new Accelerometer(new SpiConnectionSettings(0, 0) { Mode = SpiMode.Mode0, ClockFrequency = 1900000 }); _gyroscopeDevice = new Gyroscope(new SpiConnectionSettings(1, 0) { Mode = SpiMode.Mode0, ClockFrequency = 1000000 }); _rtcDevice = new RTC(); _cpuDevice = new CpuTemperature(); }
public static int get_attitude(IntPtr l) { int result; try { Gyroscope gyroscope = (Gyroscope)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushValue(l, gyroscope.attitude); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
private bool enableGyro() { if (SystemInfo.supportsGyroscope) { gyroSensor = Input.gyro; gyroSensor.enabled = true; initialRotation = transform.rotation; gyroInitialRotation = Input.gyro.attitude; cameraContrainer.transform.rotation = Quaternion.Euler(90f, -90f, 0f); rot = new Quaternion(0, 0, 1, 0); return(true); } return(false); }
private bool EnableGyro() { if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyro.enabled = true; board.rotation = Quaternion.Euler(90f, 90f, 0f); rott = new Quaternion(0, 0, 1, 0); gyroText.text = " YES "; return(true); } gyroText.text = " NO "; return(false); }
private async Task StopRecordingPerform() { if (!IsRecording) { return; } _skipWriting = true; _timer.Change(Timeout.Infinite, Timeout.Infinite); Accelerometer.ReadingChanged -= Accelerometer_ReadingChanged; Accelerometer.Stop(); if (_gyroscopeIsSensing) { Gyroscope.ReadingChanged -= Gyroscope_ReadingChanged; Gyroscope.Stop(); } if (_locationCancellationSource != null) { _locationCancellationSource.Cancel(); _locationCancellationSource.Dispose(); _locationCancellationSource = null; } // Close up and bundle up the writer await _writer.FlushAsync(); lock (_writerLock) { _writer.Dispose(); _writer = null; } await App.StopAudioRecording(); #if !DEBUG Analytics.TrackEvent("Recording.Stop"); #endif IsRecording = false; _skipWriting = false; }
private void Start() { Input.compass.enabled = true; Input.location.Start(); // Check if Gyro and Cam are supported in target device // Supp Gyro? if (!SystemInfo.supportsGyroscope) { print("Gyroscope is not supported!"); return; } // Supp BackCam? for (int i = 0; i < WebCamTexture.devices.Length; i++) { if (!WebCamTexture.devices[i].isFrontFacing) { cam = new WebCamTexture(WebCamTexture.devices[i].name, Screen.width, Screen.height); } } // If no BackCam detected if (cam == null) { print("Camera is not supported!"); return; } cameraContainer = new GameObject("CameraContainer"); cameraContainer.transform.position = transform.position; transform.SetParent(cameraContainer.transform); // Case: Gyros and BackCam are supported gyro = Input.gyro; gyro.enabled = true; cameraContainer.transform.rotation = Quaternion.Euler(90f, 0, 0); gyroRotation = new Quaternion(0, 0, 1, 0); cam.Play(); background.texture = cam; arReady = true; }
// Use this for initialization void Start() { //Check if we support both services //Gyro if (!SystemInfo.supportsGyroscope) { Debug.Log("The device does not have gyroscope"); return; } //Back camera for (int i = 0; i < WebCamTexture.devices.Length; i++) { if (!WebCamTexture.devices[i].isFrontFacing) { new WebCamTexture(WebCamTexture.devices[i].name, Screen.width, Screen.height); break; } } //if we did not find back camera if (cam == null) { Debug.Log("The device does not have back camera"); return; } //Both services are suppoorted - enable them cameraContainer = new GameObject("Camera Container"); cameraContainer.transform.position = transform.position; transform.SetParent(cameraContainer.transform); gyro = Input.gyro; gyro.enabled = true; cameraContainer.transform.rotation = Quaternion.Euler(90f, 0, 0); rotation = new Quaternion(0, 0, 1, 0); cam.Play(); background.texture = cam; arReady = true; }
public void enableGyro() { if (gyroActive) { return; } if (SystemInfo.supportsGyroscope) { _gyro = Input.gyro; _gyro.enabled = true; gyroActive = _gyro.enabled; } else { Debug.Log("Gyro is not supported on this device"); } }
public void StartSensors() { try { Accelerometer.Start(SensorSpeed.Default); Magnetometer.Start(SensorSpeed.Default); Gyroscope.Start(SensorSpeed.Default); OrientationSensor.Start(SensorSpeed.Default); Accelerometer.ReadingChanged += Accelerometer_ReadingChanged; Magnetometer.ReadingChanged += Magnetometer_ReadingChanged; Gyroscope.ReadingChanged += Gyrotometer_ReadingChanged; OrientationSensor.ReadingChanged += OrientationSensor_ReadingChanged; } catch (Exception EX) { //Log.Error(TAG, EX.GetBaseException().ToString()); } }
// Update is called once per frame private bool EnableGyro() { if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyro.enabled = true; cameraContainer.transform.rotation = Quaternion.Euler(90f, 90f, 0f); rot = new Quaternion(0, 0, 1, 0); return(true); } else { Debug.Log("gyro not supported"); return(false); } }
// Use this for initialization void Start() { gyroSupported = SystemInfo.supportsGyroscope; GameObject camParent = new GameObject("camParent"); camParent.transform.position = transform.position; transform.parent = camParent.transform; if (gyroSupported) { gyro = Input.gyro; gyro.enabled = true; camParent.transform.rotation = Quaternion.Euler(90f, 180f, 0f); rotFix = new Quaternion(0, 0, 1, 0); } }
public void EnableGyro() { if (gyroActive) { return; } if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyroActive = gyro.enabled = true; } if (!gyroActive) { screenLog.text = "Giroscópio não suportado"; } }
// Use this for initialization void Start() { /// Check if we support both services /// Gyroscope if (!SystemInfo.supportsGyroscope) { Debug.Log("Device has no gyroscope."); return; } /// Back Camera Service for (int i = 0; i < WebCamTexture.devices.Length; i++) { if (!WebCamTexture.devices[i].isFrontFacing) { cam = new WebCamTexture(WebCamTexture.devices[i].name, Screen.width, Screen.height); break; } } /// If didn't find a back camera if (cam == null) { Debug.Log("Device has no back camera."); return; } /// Both services are supported, so let's enable them. cameraContainer = new GameObject("Camera Contaner"); cameraContainer.transform.position = transform.position; transform.SetParent(cameraContainer.transform); gyro = Input.gyro; gyro.enabled = true; cameraContainer.transform.rotation = Quaternion.Euler(90.0f, 0.0f, 0.0f); rotation = new Quaternion(0, 0, 1, 0); /// makes sure that it's pointing forward cam.Play(); background.texture = cam; arReady = true; Screen.sleepTimeout = SleepTimeout.NeverSleep; }
public void MergeFrom(MyoEvent other) { if (other == null) { return; } if (other.emg_ != null) { if (emg_ == null) { Emg = new global::Ubii.DataStructure.Vector8(); } Emg.MergeFrom(other.Emg); } if (other.orientation_ != null) { if (orientation_ == null) { Orientation = new global::Ubii.DataStructure.Quaternion(); } Orientation.MergeFrom(other.Orientation); } if (other.gyroscope_ != null) { if (gyroscope_ == null) { Gyroscope = new global::Ubii.DataStructure.Vector3(); } Gyroscope.MergeFrom(other.Gyroscope); } if (other.accelerometer_ != null) { if (accelerometer_ == null) { Accelerometer = new global::Ubii.DataStructure.Vector3(); } Accelerometer.MergeFrom(other.Accelerometer); } if (other.Gesture != global::Ubii.DataStructure.HandGestureType.Rest) { Gesture = other.Gesture; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
void Start() { _t = transform; yO = _t.position.y; HeadTracker = new GameObject("HeadTracker"); HeadTracker.transform.position = transform.position; transform.parent = HeadTracker.transform; _gyroIsAvailable = Input.isGyroAvailable; if (_gyroIsAvailable) { _head = Input.gyro; Input.gyro.enabled = true; Input.gyro.updateInterval = 1f/60f; _head.updateInterval = 1f/60f; } }
public GyroController(Transform trans) { theTransform = trans; quatMap = new Quaternion(); Transform currentParent = theTransform.transform.parent; GameObject camParent = new GameObject ("GyroCamParent"); camParent.transform.position = theTransform.transform.position; theTransform.transform.parent = camParent.transform; GameObject camGrandparent = new GameObject ("GyroCamGrandParent"); camGrandparent.transform.position = theTransform.transform.position; camParent.transform.parent = camGrandparent.transform; camGrandparent.transform.parent = currentParent; gyro = Input.gyro; gyro.enabled = true; camParent.transform.eulerAngles = new Vector3 (90, 180, 0); rotFix = new Quaternion (0, 0, 1, 0); if (Screen.orientation == ScreenOrientation.LandscapeLeft) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.Portrait) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else if (Screen.orientation == ScreenOrientation.LandscapeRight) { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } else { camParent.transform.eulerAngles = new Vector3 (90, 180, 0); } if (Screen.orientation == ScreenOrientation.LandscapeLeft) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.Portrait) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.PortraitUpsideDown) { rotFix = new Quaternion (0, 0, 1, 0); } else if (Screen.orientation == ScreenOrientation.LandscapeRight) { rotFix = new Quaternion (0, 0, 1, 0); } else { rotFix = new Quaternion (0, 0, 1, 0); } // Screen.sleepTimeout = 0; }
void Start() { if (!SystemInfo.supportsGyroscope) { Debug.Log("Gyroscope doesn't supported"); #if !UNITY_EDITOR return; #endif } for (int i = 0; i < WebCamTexture.devices.Length; i++) { if (!WebCamTexture.devices [i].isFrontFacing) { cam = new WebCamTexture(WebCamTexture.devices [i].name, Screen.width, Screen.height); break; } } if (cam == null) { Debug.Log("This device doesn't have back camera"); #if UNITY_EDITOR cam = new WebCamTexture(WebCamTexture.devices [0].name, Screen.width, Screen.height); #else return; #endif } cameraContainer = new GameObject("CameraContainer"); cameraContainer.transform.position = this.transform.position; transform.SetParent(cameraContainer.transform); gyro = Input.gyro; gyro.enabled = true; cameraContainer.transform.rotation = Quaternion.Euler(90f, 0, 0); rotation = new Quaternion(0, 0, 1, 0); cam.Play(); background.texture = cam; arReady = true; }
public static int set_enabled(IntPtr l) { int result; try { Gyroscope gyroscope = (Gyroscope)LuaObject.checkSelf(l); bool enabled; LuaObject.checkType(l, 2, out enabled); gyroscope.enabled = enabled; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
private float limitRot = 0.3f; // 回転の限界値±0.5 public void EnableGyro() { // Already activated if (gyroActive) { return; } if (SystemInfo.supportsGyroscope) { gyro = Input.gyro; gyro.enabled = true; gyroActive = gyro.enabled; } else { Debug.Log("Gyro is not supported on this device"); } }
public static int set_updateInterval(IntPtr l) { int result; try { Gyroscope gyroscope = (Gyroscope)LuaObject.checkSelf(l); float updateInterval; LuaObject.checkType(l, 2, out updateInterval); gyroscope.updateInterval = updateInterval; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public void EnableGyro() { if (gyroInUse) { return; } if (SystemInfo.supportsGyroscope) { Debug.Log("system supports gyro"); gyro = Input.gyro; gyro.enabled = true; gyroInUse = true; } else { Debug.Log("System doesn't support gyro :("); } }
private bool GyroEnabeler() { //Check if the device supports a gyroscope if (SystemInfo.supportsGyroscope) { //Get's the gyro of the device gyro = Input.gyro; gyro.enabled = true; //sets a starting rotation camHolder.transform.rotation = Quaternion.Euler(90f, 90f, 0f); rot = new Quaternion(0, 0, 1, 0); // if it has a gyroscpoe returns true return(true); } //if no gyroscope is found return false return(false); }
// Use this for initialization void Start() { Screen.orientation = ScreenOrientation.LandscapeLeft; Screen.sleepTimeout = SleepTimeout.NeverSleep; gyro = Input.gyro; // Store the reference for Gyroscope sensor gyro.enabled = true; //Enable the Gyroscope sensor gyroInitialRotation = new Quaternion(Input.gyro.attitude.x, Input.gyro.attitude.y, Input.gyro.attitude.z, Input.gyro.attitude.w); Input.location.Start(); Input.compass.enabled = true; usarCompass = true; if (Input.gyro.enabled) { mensajeError.SetActive(false); usarCompass = false; } }
public ApplicationPage() { stopPressed = false; InitializeComponent(); MessagingCenter.Subscribe <SettingsPage, string>(this, "telefon", (sender, arg) => { telephone.Text = arg; }); //MessagingCenter.Subscribe<SettingsPage, string>(this, "lab", (sender, arg) => //{ // LOWER_ACCEL_BOUNDRY = Convert.ToDouble(arg); //}); //MessagingCenter.Subscribe<SettingsPage, string>(this, "uab", (sender, arg) => //{ // UPPER_ACCEL_BOUNDRY = Convert.ToDouble(arg); //}); //MessagingCenter.Subscribe<SettingsPage, string>(this, "mra", (sender, arg) => //{ // MAX_RESTING_AMPLITUDE = Convert.ToDouble(arg); //}); //MessagingCenter.Subscribe<SettingsPage, string>(this, "mav", (sender, arg) => //{ // MAX_ANGULAR_VELOCITY = Convert.ToDouble(arg); //}); if (!Accelerometer.IsMonitoring) { Accelerometer.ReadingChanged += Accelerometer_ReadingChanged; Accelerometer.Start(SensorSpeed.UI); } if (!Gyroscope.IsMonitoring) { Gyroscope.ReadingChanged += Gyroscope_ReadingChanged; Gyroscope.Start(SensorSpeed.UI); } FallTest(); }
void Start() { gyinfo = SystemInfo.supportsGyroscope; go = Input.gyro; //设置设备陀螺仪的开启/关闭状态,使用陀螺仪功能必须设置为 true Input.gyro.enabled = true; //获取设备重力加速度向量 Vector3 deviceGravity = Input.gyro.gravity; //设备的旋转速度,返回结果为x,y,z轴的旋转速度,单位为(弧度/秒) Vector3 rotationVelocity = Input.gyro.rotationRate; //获取更加精确的旋转 Vector3 rotationVelocity2 = Input.gyro.rotationRateUnbiased; //设置陀螺仪的更新检索时间,即隔 0.1秒更新一次 //Input.gyro.updateInterval = 0.03f; //获取移除重力加速度后设备的加速度 Vector3 acceleration = Input.gyro.userAcceleration; lastGy = Input.gyro.gravity; }
void Start() { flightChecker = FlightChecker.Instance; flightChecker.SetTarget(transform); centerOfMass.SetActive(true); rb = GetComponent <Rigidbody>(); foldedWings = new Vector3(0.1f, 0f, 0.7f); deployedWings = new Vector3(0.1f, 1.5f, 0.7f); SetUpWingTrails(); gyro = Input.gyro; if (!gyro.enabled) { gyro.enabled = true; } }
void Start() { gyroSupported = SystemInfo.supportsGyroscope; //Debug.Log("gyroSupported: " + gyroSupported); if (gyroSupported) { gyro = Input.gyro; gyro.enabled = true; transform.parent.transform.rotation = Quaternion.Euler(90f, 180f, 0f); rotFix = new Quaternion(0f, 0f, 1f, 0f); } else { //Your Logic OnGyroIsNotSupported.Invoke(); } }
private bool EnableGyro() { if (SystemInfo.supportsGyroscope) { _gyro = Input.gyro; _gyro.enabled = true; _container.transform.localRotation = Quaternion.Euler(90f, 90f, 0); _rotationBase = new Quaternion(0, 0, 1, 0); return(true); } else { Debug.LogWarning($"<color=yellow><b>[WARNING]</b></color> Gyro is not supported on this device"); return(false); } }
private void ApplicationBarIconButton_Click(object sender, EventArgs e) { if (gyroscope != null && gyroscope.IsDataValid) { // Stop data acquisition from the gyroscope. gyroscope.Stop(); timer.Stop(); statusTextBlock.Text = "gyroscope stopped."; } else { if (gyroscope == null) { // Instantiate the Gyroscope. gyroscope = new Gyroscope(); // Specify the desired time between updates. The sensor accepts // intervals in multiples of 20 ms. gyroscope.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20); // The sensor may not support the requested time between updates. // The TimeBetweenUpdates property reflects the actual rate. timeBetweenUpdatesTextBlock.Text = "time between updates: " + gyroscope.TimeBetweenUpdates.TotalMilliseconds + " ms"; gyroscope.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<GyroscopeReading>>(gyroscope_CurrentValueChanged); } try { statusTextBlock.Text = "starting gyroscope."; gyroscope.Start(); timer.Start(); } catch (InvalidOperationException) { statusTextBlock.Text = "unable to start gyroscope."; } } }
/// <summary> /// Initializes ALPS native plugin. /// </summary> public void Awake() { #if UNITY_ANDROID init(); #endif #if UNITY_WP_8_1 gyroBool = SystemInfo.supportsGyroscope; Debug.Log("gyro bool = " + gyroBool.ToString()); if (gyroBool) { gyro = Input.gyro; gyro.enabled = true; //rotFix = new Quaternion(0, 0, 0.7071f, 0.7071f); } else { Debug.Log("No Gyro Support"); } #endif }
private void Btn_Iniciar_Click(object sender, RoutedEventArgs e) { if(Gyroscope.IsSupported){ if(!vEstado) { giroscopio = new Gyroscope(); giroscopio.TimeBetweenUpdates = TimeSpan.FromMilliseconds(2); giroscopio.CurrentValueChanged += giroscopio_CurrentValueChanged; giroscopio.Start(); Btn_Iniciar.Content = "Apagar Giroscopio"; vEstado = true; } else { Btn_Iniciar.Content = "Iniciar Giroscopio"; vEstado = false; giroscopio.Stop(); } } else { MessageBox.Show("El dispositivo no cuenta con Giroscopio", "Giroscopio", MessageBoxButton.OK); } }
// Use this for initialization void Start() { Debug.Log (" @ VirtualCameraController.Start(): SystemInfo.supportsGyroscope: " + SystemInfo.supportsGyroscope); Debug.Log (" @ VirtualCameraController.Start(): SystemInfo.supportsLocationService: " + SystemInfo.supportsLocationService); if (SystemInfo.supportsGyroscope) { this.gyroscope = Input.gyro; this.gyroscope.enabled = true; } if (SystemInfo.supportsLocationService && Input.location.isEnabledByUser) { this.gps = Input.location; this.gps.Start (); } this.compass = Input.compass; this.compass.enabled = true; this._enableWebCam (); }
/** * Move the camera to its initial position. */ void Start() { #if (UNITY_ANDROID || UNITY_IOS) && (!UNITY_EDITOR) controller = new MobileController(); #else controller = new StandaloneController(); ((StandaloneController)controller).rotateOnFireDown = true; #endif if (_target != null) { Vector2 angles = _target.transform.localEulerAngles; if(!_target.GetComponent<CameraPoint>()) { _x = angles.y; _y = 0f; } else { CameraPoint cp = _target.GetComponent<CameraPoint>(); _x = angles.y; _y = cp.startAngle; _distance = cp.startDistance; _lowAngle = cp.minAngle; _highAngle = cp.maxAngle; _minDistance = cp.minDistance; _maxDistance = cp.maxDistance; } } else { _target = new GameObject("CameraTarget"); _x = 0f; _y = 0f; } _distanceVector = new Vector3(0.0f,0.0f,-_distance); _focusPosition = _target.transform.position; hasGyro = SystemInfo.supportsGyroscope; if (hasGyro) { Input.gyro.enabled = true; gyro = Input.gyro; } StartCoroutine(autoOrbit(3f)); }
void Start() { gyro = Input.gyro; gyro.enabled = enabled = SystemInfo.supportsGyroscope; }
public void Init(Ioctls ioctls, Core core, Runtime runtime) { ioctls.maSensorStart = delegate(int _sensor, int _interval) { long intervalIn100Nanoseconds = (long)_interval * 10000; if (_sensor == MoSync.Constants.SENSOR_TYPE_ACCELEROMETER && Accelerometer.IsSupported) { mAccelerometer = new Accelerometer(); mAccelerometer.TimeBetweenUpdates = new TimeSpan(intervalIn100Nanoseconds); mAccelerometer.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<AccelerometerReading> args) { Vector3 acc = args.SensorReading.Acceleration; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_ACCELEROMETER, acc); }; } else if (_sensor == MoSync.Constants.SENSOR_TYPE_GYROSCOPE && Gyroscope.IsSupported) { mGyroscope = new Gyroscope(); mGyroscope.TimeBetweenUpdates = new TimeSpan(intervalIn100Nanoseconds); mGyroscope.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<GyroscopeReading> args) { Vector3 rot = args.SensorReading.RotationRate; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_GYROSCOPE, rot); }; } else if (_sensor == MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD && Compass.IsSupported) { mCompass = new Compass(); mCompass.TimeBetweenUpdates = new TimeSpan(intervalIn100Nanoseconds); mCompass.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<CompassReading> args) { Vector3 rot = args.SensorReading.MagnetometerReading; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD, rot); }; } #if false else if (_sensor == MoSync.Constants.SENSOR_TYPE_ORIENTATION && Motion.IsSupported) { mMotion = new Motion(); mMotion.TimeBetweenUpdates = new TimeSpan(intervalIn100Nanoseconds); mMotion.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<MotionReading> args) { }; } #endif else return MoSync.Constants.SENSOR_ERROR_NOT_AVAILABLE; return MoSync.Constants.SENSOR_ERROR_NONE; }; ioctls.maSensorStop = delegate(int _sensor) { switch (_sensor) { case MoSync.Constants.SENSOR_TYPE_ACCELEROMETER: if (mAccelerometer != null) { mAccelerometer.Stop(); mAccelerometer = null; } break; case MoSync.Constants.SENSOR_TYPE_GYROSCOPE: if (mGyroscope != null) { mGyroscope.Stop(); mGyroscope = null; } break; case MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD: if (mCompass != null) { mCompass.Stop(); mCompass = null; } break; case MoSync.Constants.SENSOR_TYPE_ORIENTATION: if (mMotion != null) { mMotion.Stop(); mMotion = null; } break; } return MoSync.Constants.SENSOR_ERROR_NONE; }; ioctls.maLocationStart = delegate() { return 0; }; ioctls.maLocationStop = delegate() { return 0; }; }
void Start() { pv = transform.GetComponent<PhotonView>(); pv.observed = this; transform.parent = GameObject.Find("GameMain").transform; if(pv.isMine){ GameObject.Find("GameMain").GetComponent<GameMain>().SetController(gameObject); if(Application.platform == RuntimePlatform.Android){ gyro = Input.gyro; gyro.enabled = true; } } curRot = transform.rotation; }
void Awake() { GetComponent<Rigidbody>().useGravity = false; gyro = Input.gyro; }
using UnityEngine;
// Use this for initialization void Start() { gyro = Input.gyro; gyro.enabled = true; }
public static void Init_Module(){ _g = Input.gyro ; _g.enabled = true ; }
void OnEnable() { if (hasGyro) { Input.gyro.enabled = true; gyro = Input.gyro; } }
// Use this for initialization void Start() { //자이로 켜줌 gyro = Input.gyro; gyro.enabled = true; }
public void Init(Ioctls ioctls, Core core, Runtime runtime) { ioctls.maSensorStart = delegate(int _sensor, int _interval) { _interval = GetSensorIntervalDefaults(_interval); TimeSpan time = TimeSpan.FromMilliseconds((double)_interval); if (_sensor == MoSync.Constants.SENSOR_TYPE_ACCELEROMETER && Accelerometer.IsSupported) { if (mAccelerometer != null) return MoSync.Constants.SENSOR_ERROR_ALREADY_ENABLED; mAccelerometer = new Accelerometer(); mAccelerometer.TimeBetweenUpdates = time; mAccelerometer.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<AccelerometerReading> args) { Vector3 acc = args.SensorReading.Acceleration; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_ACCELEROMETER, acc); }; mAccelerometer.Start(); } else if (_sensor == MoSync.Constants.SENSOR_TYPE_GYROSCOPE && Gyroscope.IsSupported) { if (mGyroscope != null) return MoSync.Constants.SENSOR_ERROR_ALREADY_ENABLED; mGyroscope = new Gyroscope(); mGyroscope.TimeBetweenUpdates = time; mGyroscope.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<GyroscopeReading> args) { Vector3 rot = args.SensorReading.RotationRate; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_GYROSCOPE, rot); }; mGyroscope.Start(); } else if ((_sensor == MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD || _sensor == MoSync.Constants.SENSOR_TYPE_COMPASS) && Compass.IsSupported) { if (_sensor == MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD && mMagneticFieldEnabled == true) return MoSync.Constants.SENSOR_ERROR_ALREADY_ENABLED; if (_sensor == MoSync.Constants.SENSOR_TYPE_COMPASS && mCompassEnabled == true) return MoSync.Constants.SENSOR_ERROR_ALREADY_ENABLED; if (mCompass == null) { mCompass = new Compass(); mCompass.TimeBetweenUpdates = time; } else { if(time < mCompass.TimeBetweenUpdates) mCompass.TimeBetweenUpdates = time; } if (mCompassEnabled == false && mMagneticFieldEnabled == false) { mCompass.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<CompassReading> args) { if (mMagneticFieldEnabled) { Vector3 rot = args.SensorReading.MagnetometerReading; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD, rot); } if (mCompassEnabled) { Vector3 heading = new Vector3(); heading.X = (float)args.SensorReading.MagneticHeading; SendSensorEventVector(runtime, MoSync.Constants.SENSOR_TYPE_COMPASS, heading); } }; mCompass.Start(); } if (_sensor == MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD) mMagneticFieldEnabled = true; else if (_sensor == MoSync.Constants.SENSOR_TYPE_COMPASS) mCompassEnabled = true; } #if false else if (_sensor == MoSync.Constants.SENSOR_TYPE_ORIENTATION && Motion.IsSupported) { mMotion = new Motion(); mMotion.TimeBetweenUpdates = new TimeSpan(intervalIn100Nanoseconds); mMotion.CurrentValueChanged += delegate(object sender, SensorReadingEventArgs<MotionReading> args) { }; } #endif else return MoSync.Constants.SENSOR_ERROR_NOT_AVAILABLE; return MoSync.Constants.SENSOR_ERROR_NONE; }; ioctls.maSensorStop = delegate(int _sensor) { switch (_sensor) { case MoSync.Constants.SENSOR_TYPE_ACCELEROMETER: if (mAccelerometer != null) { mAccelerometer.Stop(); mAccelerometer = null; } else { return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED; } break; case MoSync.Constants.SENSOR_TYPE_GYROSCOPE: if (mGyroscope != null) { mGyroscope.Stop(); mGyroscope = null; } else { return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED; } break; case MoSync.Constants.SENSOR_TYPE_MAGNETIC_FIELD: if(!mMagneticFieldEnabled) return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED; if (mCompass != null && !mCompassEnabled) { mCompass.Stop(); mCompass = null; } mMagneticFieldEnabled = false; break; case MoSync.Constants.SENSOR_TYPE_COMPASS: if (!mCompassEnabled) return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED; if (mCompass != null && !mMagneticFieldEnabled) { mCompass.Stop(); mCompass = null; } mCompassEnabled = false; break; case MoSync.Constants.SENSOR_TYPE_ORIENTATION: if (mMotion != null) { mMotion.Stop(); mMotion = null; } else { return MoSync.Constants.SENSOR_ERROR_NOT_ENABLED; } break; } return MoSync.Constants.SENSOR_ERROR_NONE; }; ioctls.maLocationStart = delegate() { if (mGeoWatcher == null) { mGeoWatcher = new GeoCoordinateWatcher(); //mGeoWatcher.MovementThreshold = 20; mGeoWatcher.StatusChanged += delegate(object sender, GeoPositionStatusChangedEventArgs args) { int maState; switch (args.Status) { case GeoPositionStatus.Disabled: maState = MoSync.Constants.MA_LPS_OUT_OF_SERVICE; break; case GeoPositionStatus.NoData: case GeoPositionStatus.Initializing: maState = MoSync.Constants.MA_LPS_TEMPORARILY_UNAVAILABLE; break; case GeoPositionStatus.Ready: maState = MoSync.Constants.MA_LPS_AVAILABLE; break; default: throw new Exception("invalid GeoPositionStatus"); } Memory evt = new Memory(2 * 4); evt.WriteInt32(MoSync.Struct.MAEvent.type, MoSync.Constants.EVENT_TYPE_LOCATION_PROVIDER); evt.WriteInt32(MoSync.Struct.MAEvent.state, maState); runtime.PostEvent(new Event(evt)); }; mGeoWatcher.PositionChanged += delegate(object sender, GeoPositionChangedEventArgs<GeoCoordinate> args) { int maValidity = args.Position.Location.IsUnknown ? MoSync.Constants.MA_LOC_INVALID : MoSync.Constants.MA_LOC_QUALIFIED; Memory evt = new Memory(4 + 4 * 8 + 4); GeoCoordinate l = args.Position.Location; evt.WriteInt32(MoSync.Struct.MALocation.state, maValidity); evt.WriteDouble(MoSync.Struct.MALocation.lat, l.Latitude); evt.WriteDouble(MoSync.Struct.MALocation.lon, l.Longitude); evt.WriteDouble(MoSync.Struct.MALocation.horzAcc, l.HorizontalAccuracy); evt.WriteDouble(MoSync.Struct.MALocation.vertAcc, l.VerticalAccuracy); evt.WriteFloat(MoSync.Struct.MALocation.alt, (float)l.Altitude); runtime.PostCustomEvent(MoSync.Constants.EVENT_TYPE_LOCATION, evt); }; mGeoWatcher.Start(); } return 0; }; ioctls.maLocationStop = delegate() { if (mGeoWatcher != null) { mGeoWatcher.Stop(); mGeoWatcher = null; } return 0; }; }