public override void OnNewPoses() { var deviceIndex = viveRole.GetDeviceIndex(); // set targetPose to device pose targetPose = VivePose.GetPose(deviceIndex) * new RigidPose(posOffset, Quaternion.Euler(rotOffset)); ModifyPose(ref targetPose, origin); // transform to world space var o = origin != null ? origin : transform.parent; if (o != null) { targetPose = new RigidPose(o) * targetPose; targetPose.pos.Scale(o.localScale); } if (m_snap) { m_snap = false; transform.position = targetPose.pos; transform.rotation = targetPose.rot; } SetIsValid(VivePose.IsValid(deviceIndex)); }
public virtual void OnNewPoses() { var deviceIndex = m_viveRole.GetDeviceIndex(); var isValid = VivePose.IsValid(deviceIndex); if (isValid) { TrackPose(VivePose.GetPose(deviceIndex), origin); } SetIsValid(isValid); }
public virtual void OnNewPoses() { TrackPose(VivePose.GetPose(role), origin); var isValidCurrent = VivePose.IsValid(role); if (isValid != isValidCurrent) { isValid = isValidCurrent; onIsValidChanged.Invoke(isValid); } }
public virtual void OnNewPoses() { var deviceIndex = m_viveRole.GetDeviceIndex(); if (VRModule.IsValidDeviceIndex(deviceIndex)) { m_staticExCamPose = VivePose.GetPose(deviceIndex); } if (isQuadViewActive) { RigidPose.SetPose(transform, m_staticExCamPose, m_origin); } }
public virtual void OnNewPoses() { var deviceIndex = m_viveRole.GetDeviceIndex(); var isValid = VivePose.IsValid(deviceIndex); if (isValid) { var pose = VivePose.GetPose(deviceIndex); if (m_origin != null && m_origin != transform.parent) { pose = new RigidPose(m_origin.transform) * pose; TrackPose(pose, false); } else { TrackPose(pose, true); } } SetIsValid(isValid); }
public override void OnNewPoses() { targetPose = VivePose.GetPose(role) * new Pose(posOffset, Quaternion.Euler(rotOffset)); ModifyPose(ref targetPose, origin); // transform to world space var o = origin != null ? origin : transform.parent; if (o != null) { targetPose = new Pose(o) * targetPose; targetPose.pos.Scale(o.localScale); } var poseValid = VivePose.IsValid(role); if (!isPoseValid && poseValid) { transform.position = targetPose.pos; transform.rotation = targetPose.rot; } SetIsValid(poseValid); }
public void Refresh() { m_sortedDevices.Clear(); UnmappingAll(); MappingRoleIfUnbound(BodyRole.Head, 0u); // get related poses and record controller/tracker devices var hmdPose = VivePose.GetPose(0u); // preserve only y-axis rotation hmdPose.rot = Quaternion.Euler(0f, hmdPose.rot.eulerAngles.y, 0f); // move center to half height hmdPose.pos = Vector3.Scale(hmdPose.pos, new Vector3(1f, 0.5f, 1f)); var halfHeight = hmdPose.pos.y; var centerPoseInverse = hmdPose.GetInverse(); for (uint i = 1; i < VRModule.MAX_DEVICE_COUNT; ++i) { if (!IsTrackingDevice(i)) { continue; } var relatedCenterPos = centerPoseInverse.InverseTransformPoint(VRModule.GetCurrentDeviceState(i).pose.pos); m_directionPoint[i] = HandRoleHandler.GetDirectionPoint(new Vector2(relatedCenterPos.x, -relatedCenterPos.y)); m_distanceSqr[i] = relatedCenterPos.sqrMagnitude / (halfHeight * halfHeight); m_sortedDevices.Add(i); } if (m_sortedDevices.Count == 0) { return; } var index = m_sortedDevices.Count - 1; // pointing last index // find 2 feet, should be most farest 2 devices m_sortedDevices.Sort(CompareDistance); if (IsFoot(m_sortedDevices[index])) { if (m_sortedDevices.Count <= 1) { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); return; } if (!IsFoot(m_sortedDevices[index - 1])) { // only 1 foot found MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); m_sortedDevices.RemoveAt(index--); if (index < 0) { return; } } else { // 2 feet found, determine lef/right foot if (m_directionPoint[m_sortedDevices[index]] < m_directionPoint[m_sortedDevices[index - 1]]) { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); MappingRoleIfUnbound(BodyRole.LeftFoot, m_sortedDevices[index - 1]); } else { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index - 1]); MappingRoleIfUnbound(BodyRole.LeftFoot, m_sortedDevices[index]); } m_sortedDevices.RemoveAt(index--); m_sortedDevices.RemoveAt(index--); if (index < 0) { return; } } } // find 2 hands, should be most left and most right device m_sortedDevices.Sort(CompareDirection); // right most device as right hand MappingRoleIfUnbound(BodyRole.RightHand, m_sortedDevices[0]); if (m_sortedDevices.Count == 1) { return; } // left most device as left hand MappingRoleIfUnbound(BodyRole.LeftHand, m_sortedDevices[index]); if (m_sortedDevices.Count == 2) { return; } // middle one as hip MappingRoleIfUnbound(BodyRole.Hip, m_sortedDevices[index / 2]); }
public void Refresh() { m_sortedDevices.Clear(); UnmappingAll(); MappingRoleIfUnbound(BodyRole.Head, 0u); // get related poses and record controller/tracker devices var hmdPose = VivePose.GetPose(0u); // preserve only y-axis rotation hmdPose.rot = Quaternion.Euler(0f, hmdPose.rot.eulerAngles.y, 0f); // move center to half height hmdPose.pos = Vector3.Scale(hmdPose.pos, new Vector3(1f, 0.5f, 1f)); var halfHeight = hmdPose.pos.y; var centerPoseInverse = hmdPose.GetInverse(); for (uint i = 1; i < ViveRole.MAX_DEVICE_COUNT; ++i) { if (!IsControllerOrTracker(i)) { continue; } var relatedCenterPos = (centerPoseInverse * VivePose.GetPose(i)).pos; var normalizedPosOnPlane = Vector3.ProjectOnPlane(relatedCenterPos, Vector3.forward) / halfHeight; // normalize m_direction[i] = GetDirection(normalizedPosOnPlane); m_distance[i] = normalizedPosOnPlane.magnitude; m_sortedDevices.Add(i); } if (m_sortedDevices.Count == 0) { return; } var index = m_sortedDevices.Count - 1; // pointing last index // find 2 feet, should be most farest 2 devices m_sortedDevices.Sort(CompareDistance); if (IsFoot(m_sortedDevices[index])) { if (m_sortedDevices.Count <= 1) { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); return; } if (!IsFoot(m_sortedDevices[index - 1])) { // only 1 foot found MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); m_sortedDevices.RemoveAt(index--); if (index < 0) { return; } } else { // 2 feet found, deside lef/right foot if (m_direction[m_sortedDevices[index]] < m_direction[m_sortedDevices[index - 1]]) { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index]); MappingRoleIfUnbound(BodyRole.LeftFoot, m_sortedDevices[index - 1]); } else { MappingRoleIfUnbound(BodyRole.RightFoot, m_sortedDevices[index - 1]); MappingRoleIfUnbound(BodyRole.LeftFoot, m_sortedDevices[index]); } m_sortedDevices.RemoveAt(index--); m_sortedDevices.RemoveAt(index--); if (index < 0) { return; } } } // find 2 hands, should be most left and most right device m_sortedDevices.Sort(CompareDirection); // right most device as right hand MappingRoleIfUnbound(BodyRole.RightHand, m_sortedDevices[0]); if (m_sortedDevices.Count == 1) { return; } // left most device as left hand MappingRoleIfUnbound(BodyRole.LeftHand, m_sortedDevices[index]); if (m_sortedDevices.Count == 2) { return; } // middle one as hip MappingRoleIfUnbound(BodyRole.Hip, m_sortedDevices[index / 2]); }
public virtual void OnNewPoses() { TrackPose(VivePose.GetPose(role), origin); SetIsValid(VivePose.IsValid(role)); }