use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.
the class OpenVRInput method getFinalObserverPosition.
@Override
public Vector3f getFinalObserverPosition(int index) {
if (environment != null) {
VRViewManagerOpenVR vrvm = (VRViewManagerOpenVR) environment.getVRViewManager();
if (vrvm != null) {
if (isInputDeviceTracking(index) == false) {
return null;
}
Object obs = environment.getObserver();
Vector3f pos = getPosition(index);
if (obs instanceof Camera) {
((Camera) obs).getRotation().mult(pos, pos);
return pos.addLocal(((Camera) obs).getLocation());
} else {
((Spatial) obs).getWorldRotation().mult(pos, pos);
return pos.addLocal(((Spatial) obs).getWorldTranslation());
}
} else {
throw new IllegalStateException("VR environment has no valid view manager.");
}
} else {
throw new IllegalStateException("VR input is not attached to a VR environment.");
}
}
use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.
the class VREnvironment method atttach.
/**
* Attach the VR environment to the given app state and application.
* This method should be called within the {@link AppState#stateAttached(com.jme3.app.state.AppStateManager) stateAttached(com.jme3.app.state.AppStateManager)} method
* from the app state.
* @param appState the app state to attach.
* @param application the application to attach.
*/
public void atttach(AppState appState, Application application) {
this.application = application;
this.app = appState;
// Instanciate view manager
if (vrBinding == VRConstants.SETTING_VRAPI_OPENVR_VALUE) {
viewmanager = new VRViewManagerOpenVR(this);
} else if (vrBinding == VRConstants.SETTING_VRAPI_OSVR_VALUE) {
viewmanager = new VRViewManagerOSVR(this);
} else {
logger.severe("Cannot instanciate view manager, unknown VRAPI type: " + vrBinding);
}
}
use of com.jme3.util.VRViewManagerOpenVR in project jmonkeyengine by jMonkeyEngine.
the class VRApplication method initialize.
@Override
public void initialize() {
logger.config("Initialize VR application...");
initialize_internal();
cam.setFrustumFar(fFar);
cam.setFrustumNear(fNear);
dummyCam = cam.clone();
if (isInVR()) {
logger.config("VR mode enabled.");
if (VRhardware != null) {
VRhardware.initVRCompositor(compositorAllowed());
} else {
logger.warning("No VR system found.");
}
//FIXME: WARNING !!
viewmanager = new VRViewManagerOpenVR(null);
viewmanager.setResolutionMultiplier(resMult);
inputManager.addMapping(RESET_HMD, new KeyTrigger(KeyInput.KEY_F9));
setLostFocusBehavior(LostFocusBehavior.Disabled);
} else {
logger.config("VR mode disabled.");
viewPort.attachScene(rootNode);
guiViewPort.attachScene(guiNode);
}
if (viewmanager != null) {
viewmanager.initialize();
}
simpleInitApp();
// any filters created, move them now
if (viewmanager != null) {
viewmanager.moveScreenProcessingToEyes();
// print out camera information
if (isInVR()) {
logger.info("VR Initialization Information");
if (viewmanager.getLeftCamera() != null) {
logger.info("camLeft: " + viewmanager.getLeftCamera().toString());
}
if (viewmanager.getRightCamera() != null) {
logger.info("camRight: " + viewmanager.getRightCamera().toString());
}
}
}
}
Aggregations