// Update is called once per frame void Update() { vrTracker tracker = null; vrKeyboard keyb = null; if (MiddleVR.VRDeviceMgr != null) { tracker = MiddleVR.VRDeviceMgr.GetTracker(Tracker); keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); } if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_SPACE)) { if (tracker != null) { float yaw = tracker.GetYaw(); vrQuat neutralOr = new vrQuat(0, 0, 0, 1); neutralOr.SetEuler(-yaw, 0, 0); vrQuat nq = neutralOr.GetInverse(); tracker.SetNeutralOrientation(nq); } } }
protected void Update() { vrTracker tracker = null; vrKeyboard keyboard = null; var deviceMgr = MiddleVR.VRDeviceMgr; if (deviceMgr != null) { tracker = deviceMgr.GetTracker(Tracker); keyboard = deviceMgr.GetKeyboard(); } if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_SPACE)) { if (tracker != null) { float yaw = tracker.GetYaw(); vrQuat neutralQ = new vrQuat(); neutralQ.SetEuler(-yaw, 0.0f, 0.0f); vrQuat invNeutralQ = neutralQ.GetInverse(); tracker.SetNeutralOrientation(invNeutralQ); } } }
void Update() { if (m_Init == true) { // Multiply by scale value only if used if (UsePositionScale) { // Position if (UsePositionX) { m_DestinationVirtualTracker.SetX(PositionScaleValue * m_SourceTracker.GetX()); } // Inverting Unity Y and MiddleVR Z because of different coordinate systems if (UsePositionY) { m_DestinationVirtualTracker.SetZ(PositionScaleValue * m_SourceTracker.GetZ()); } // Inverting Unity Y and MiddleVR Z because of different coordinate systems if (UsePositionZ) { m_DestinationVirtualTracker.SetY(PositionScaleValue * m_SourceTracker.GetY()); } } else { // Position if (UsePositionX) { m_DestinationVirtualTracker.SetX(m_SourceTracker.GetX()); } // Inverting Unity Y and MiddleVR Z because of different coordinate systems if (UsePositionY) { m_DestinationVirtualTracker.SetZ(m_SourceTracker.GetZ()); } // Inverting Unity Y and MiddleVR Z because of different coordinate systems if (UsePositionZ) { m_DestinationVirtualTracker.SetY(m_SourceTracker.GetY()); } } // Orientation if (UseYaw) { m_DestinationVirtualTracker.SetYaw(m_SourceTracker.GetYaw()); } if (UsePitch) { m_DestinationVirtualTracker.SetPitch(m_SourceTracker.GetPitch()); } if (UseRoll) { m_DestinationVirtualTracker.SetRoll(m_SourceTracker.GetRoll()); } } }
protected void Update() { if (m_IsInit) { float scale = 1.0f; if (UsePositionScale) { scale = PositionScaleValue; } // Position // // Show how coordinates values can be changed when feeding a virtual tracker. // if (UsePositionX) { m_DestinationVirtualTracker.SetX(scale * m_SourceTracker.GetX()); } if (UsePositionY) { m_DestinationVirtualTracker.SetZ(scale * m_SourceTracker.GetZ()); } if (UsePositionZ) { m_DestinationVirtualTracker.SetY(scale * m_SourceTracker.GetY()); } // Orientation // // Note that it is suggested to use quaternions if you do not need // to decompose a rotation. // if (UseYaw) { m_DestinationVirtualTracker.SetYaw(m_SourceTracker.GetYaw()); } if (UsePitch) { m_DestinationVirtualTracker.SetPitch(m_SourceTracker.GetPitch()); } if (UseRoll) { m_DestinationVirtualTracker.SetRoll(m_SourceTracker.GetRoll()); } } }