@Override public Quaternion getOrientation() { VRUtil.convertMatrix4toQuat(hmdPose, rotStore); return rotStore; }
} else { if( latencyWaitTime > 0 ) VRUtil.sleepNanos(latencyWaitTime);
public static Quaternion stripToYaw(Quaternion q) { float yaw; float w = q.getW(); float x = q.getX(); float y = q.getY(); float z = q.getZ(); float sqx = x*x; float sqy = y*y; float sqz = z*z; float sqw = w*w; float unit = sqx + sqy + sqz + sqw; // if normalized is one, otherwise // is correction factor float test = x * y + z * w; if (test > 0.499 * unit) { // singularity at north pole yaw = 2 * FastMath.atan2(x, w); } else if (test < -0.499 * unit) { // singularity at south pole yaw = -2 * FastMath.atan2(x, w); } else { yaw = FastMath.atan2(2 * y * w - 2 * x * z, sqx - sqy - sqz + sqw); // roll or heading } FastFullAngles(q, yaw, 0f, 0f); return q; } }
/** * Rotate the GUI to the given direction. * @param dir the direction to rotate to. * @param tpf the time per frame. */ private void rotateScreenTo(Quaternion dir, float tpf) { dir.getRotationColumn(2, look).negateLocal(); dir.getRotationColumn(0, left).negateLocal(); orient.fromAxes(left, dir.getRotationColumn(1, up), look); Quaternion rot = tempq.fromRotationMatrix(orient); if( posMode == VRGUIPositioningMode.AUTO_CAM_ALL_SKIP_PITCH ){ VRUtil.stripToYaw(rot); } if( guiPositioningElastic > 0f && posMode != VRGUIPositioningMode.MANUAL ) { // mix pos & dir with current pos & dir EoldDir.nlerp(rot, tpf * guiPositioningElastic); guiQuadNode.setLocalRotation(EoldDir); } else { guiQuadNode.setLocalRotation(rot); } }
@Override public Quaternion getOrientation() { VRUtil.convertMatrix4toQuat(hmdPose, rotStore); return rotStore; }
@Override public Quaternion getOrientation(int index) { if (isInputDeviceTracking(index) == false) { return null; } if (environment != null) { if (environment.getVRHardware() instanceof LWJGLOpenVR) { index = controllerIndex[index]; VRUtil.convertMatrix4toQuat(((LWJGLOpenVR) environment.getVRHardware()).poseMatrices[index], rotStore[index]); return rotStore[index]; } else { throw new IllegalStateException("VR hardware " + environment.getVRHardware().getClass().getSimpleName() + " is not a subclass of " + LWJGLOpenVR.class.getSimpleName()); } } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } }
@Override public Quaternion getOrientation(int index) { if( isInputDeviceTracking(index) == false ){ return null; } if (environment != null){ if (environment.getVRHardware() instanceof OpenVR){ index = controllerIndex[index]; VRUtil.convertMatrix4toQuat(((OpenVR)environment.getVRHardware()).poseMatrices[index], rotStore[index]); return rotStore[index]; } else { throw new IllegalStateException("VR hardware "+environment.getVRHardware().getClass().getSimpleName()+" is not a subclass of "+OpenVR.class.getSimpleName()); } } else { throw new IllegalStateException("VR input is not attached to a VR environment."); } }