|
|
|
@ -45,6 +45,7 @@ import com.jme3.texture.*; |
|
|
|
|
|
|
|
|
|
import java.nio.IntBuffer; |
|
|
|
|
import java.util.Iterator; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
import java.util.logging.Logger; |
|
|
|
|
|
|
|
|
|
import org.lwjgl.ovr.*; |
|
|
|
@ -75,6 +76,7 @@ public class VRViewManagerOculus extends AbstractVRViewManager { |
|
|
|
|
this.environment = environment; |
|
|
|
|
|
|
|
|
|
VRAPI hardware = environment.getVRHardware(); |
|
|
|
|
Objects.requireNonNull(hardware, "Attached VR Hardware cannot be null"); |
|
|
|
|
if (!(hardware instanceof OculusVR)) { |
|
|
|
|
throw new IllegalStateException("Cannot use Oculus VR view manager on non-Oculus hardware state!"); |
|
|
|
|
} |
|
|
|
@ -102,7 +104,10 @@ public class VRViewManagerOculus extends AbstractVRViewManager { |
|
|
|
|
hardware.updatePose(); |
|
|
|
|
|
|
|
|
|
// TODO deduplicate
|
|
|
|
|
if (environment != null) { |
|
|
|
|
if (environment == null) { |
|
|
|
|
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// grab the observer
|
|
|
|
|
Object obs = environment.getObserver(); |
|
|
|
|
Quaternion objRot; |
|
|
|
@ -114,11 +119,9 @@ public class VRViewManagerOculus extends AbstractVRViewManager { |
|
|
|
|
objRot = ((Spatial) obs).getWorldRotation(); |
|
|
|
|
objPos = ((Spatial) obs).getWorldTranslation(); |
|
|
|
|
} |
|
|
|
|
// grab the hardware handle
|
|
|
|
|
VRAPI dev = environment.getVRHardware(); |
|
|
|
|
if (dev != null) { |
|
|
|
|
|
|
|
|
|
// update the HMD's position & orientation
|
|
|
|
|
dev.getPositionAndOrientation(hmdPos, hmdRot); |
|
|
|
|
hardware.getPositionAndOrientation(hmdPos, hmdRot); |
|
|
|
|
if (obs != null) { |
|
|
|
|
// update hmdPos based on obs rotation
|
|
|
|
|
finalRotation.set(objRot); |
|
|
|
@ -126,12 +129,8 @@ public class VRViewManagerOculus extends AbstractVRViewManager { |
|
|
|
|
finalRotation.multLocal(hmdRot); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
finalizeCamera(dev.getHMDVectorPoseLeftEye(), objPos, leftCamera); |
|
|
|
|
finalizeCamera(dev.getHMDVectorPoseRightEye(), objPos, rightCamera); |
|
|
|
|
} else { |
|
|
|
|
leftCamera.setFrame(objPos, objRot); |
|
|
|
|
rightCamera.setFrame(objPos, objRot); |
|
|
|
|
} |
|
|
|
|
finalizeCamera(hardware.getHMDVectorPoseLeftEye(), objPos, leftCamera); |
|
|
|
|
finalizeCamera(hardware.getHMDVectorPoseRightEye(), objPos, rightCamera); |
|
|
|
|
|
|
|
|
|
if (environment.hasTraditionalGUIOverlay()) { |
|
|
|
|
// update the mouse?
|
|
|
|
@ -143,9 +142,6 @@ public class VRViewManagerOculus extends AbstractVRViewManager { |
|
|
|
|
environment.getVRGUIManager().updateGuiQuadGeometricState(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
throw new IllegalStateException("This VR view manager is not attached to any VR environment."); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|