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