Conforming to last master branch
This commit is contained in:
parent
888b66892d
commit
9e945462f7
@ -8,7 +8,6 @@ import com.jme3.app.state.AppState;
|
|||||||
import com.jme3.input.vr.OSVR;
|
import com.jme3.input.vr.OSVR;
|
||||||
import com.jme3.input.vr.OpenVR;
|
import com.jme3.input.vr.OpenVR;
|
||||||
import com.jme3.input.vr.VRAPI;
|
import com.jme3.input.vr.VRAPI;
|
||||||
import com.jme3.input.vr.VRBounds;
|
|
||||||
import com.jme3.input.vr.VRInputAPI;
|
import com.jme3.input.vr.VRInputAPI;
|
||||||
import com.jme3.renderer.Camera;
|
import com.jme3.renderer.Camera;
|
||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
@ -28,8 +27,6 @@ public class VREnvironment {
|
|||||||
private VRGuiManager guiManager = null;
|
private VRGuiManager guiManager = null;
|
||||||
private VRMouseManager mouseManager = null;
|
private VRMouseManager mouseManager = null;
|
||||||
private VRViewManager viewmanager = null;
|
private VRViewManager viewmanager = null;
|
||||||
private VRBounds bounds = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The underlying system VR API. By default set to {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE}.
|
* The underlying system VR API. By default set to {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE}.
|
||||||
@ -76,10 +73,7 @@ public class VREnvironment {
|
|||||||
|
|
||||||
guiManager = new VRGuiManager(this);
|
guiManager = new VRGuiManager(this);
|
||||||
mouseManager = new VRMouseManager(this);
|
mouseManager = new VRMouseManager(this);
|
||||||
|
// dummyCam = new Camera(settings.getWidth(), settings.getHeight());
|
||||||
bounds = new VRBounds();
|
|
||||||
|
|
||||||
dummyCam = new Camera();
|
|
||||||
|
|
||||||
processSettings();
|
processSettings();
|
||||||
}
|
}
|
||||||
@ -92,14 +86,6 @@ public class VREnvironment {
|
|||||||
return hardware;
|
return hardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the VR bounds.
|
|
||||||
* @return the VR bounds.
|
|
||||||
*/
|
|
||||||
public VRBounds getVRBounds(){
|
|
||||||
return bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the VR dedicated input.
|
* Get the VR dedicated input.
|
||||||
* @return the VR dedicated input.
|
* @return the VR dedicated input.
|
||||||
@ -346,7 +332,7 @@ public class VREnvironment {
|
|||||||
*/
|
*/
|
||||||
public Camera getCamera() {
|
public Camera getCamera() {
|
||||||
if( isInVR() && getVRViewManager() != null && getVRViewManager().getLeftCamera() != null ) {
|
if( isInVR() && getVRViewManager() != null && getVRViewManager().getLeftCamera() != null ) {
|
||||||
return dummyCam;
|
return getDummyCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
return application.getCamera();
|
return application.getCamera();
|
||||||
@ -361,13 +347,12 @@ public class VREnvironment {
|
|||||||
if (application.getCamera() != null){
|
if (application.getCamera() != null){
|
||||||
dummyCam = application.getCamera().clone();
|
dummyCam = application.getCamera().clone();
|
||||||
} else {
|
} else {
|
||||||
return new Camera();
|
return new Camera(settings.getWidth(), settings.getHeight());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("VR environment is not attached to any application.");
|
throw new IllegalStateException("VR environment is not attached to any application.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dummyCam;
|
return dummyCam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.input.vr;
|
package com.jme3.input.vr;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -184,50 +183,28 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3f getVelocity(int controllerIndex) {
|
public Vector3f getVelocity(int controllerIndex) {
|
||||||
|
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||||
if (environment != null){
|
if( needsNewVelocity[index] ) {
|
||||||
|
OpenVR.hmdTrackedDevicePoses[index].readField("vVelocity");
|
||||||
if (environment.getVRHardware() instanceof OpenVR){
|
needsNewVelocity[index] = false;
|
||||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
}
|
||||||
if( needsNewVelocity[index] ) {
|
tempVel.x = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[0];
|
||||||
((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].readField("vVelocity");
|
tempVel.y = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[1];
|
||||||
needsNewVelocity[index] = false;
|
tempVel.z = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[2];
|
||||||
}
|
return tempVel;
|
||||||
tempVel.x = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity.v[0];
|
|
||||||
tempVel.y = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity.v[1];
|
|
||||||
tempVel.z = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vVelocity.v[2];
|
|
||||||
return tempVel;
|
|
||||||
} 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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3f getAngularVelocity(int controllerIndex) {
|
public Vector3f getAngularVelocity(int controllerIndex) {
|
||||||
|
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||||
if (environment != null){
|
if( needsNewAngVelocity[index] ) {
|
||||||
|
OpenVR.hmdTrackedDevicePoses[index].readField("vAngularVelocity");
|
||||||
if (environment.getVRHardware() instanceof OpenVR){
|
needsNewAngVelocity[index] = false;
|
||||||
|
}
|
||||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
tempVel.x = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[0];
|
||||||
if( needsNewAngVelocity[index] ) {
|
tempVel.y = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[1];
|
||||||
((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].readField("vAngularVelocity");
|
tempVel.z = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[2];
|
||||||
needsNewAngVelocity[index] = false;
|
return tempVel;
|
||||||
}
|
|
||||||
tempVel.x = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity.v[0];
|
|
||||||
tempVel.y = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity.v[1];
|
|
||||||
tempVel.z = ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].vAngularVelocity.v[2];
|
|
||||||
return tempVel;
|
|
||||||
} 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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -332,16 +309,7 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (environment != null){
|
return OpenVR.hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid != 0;
|
||||||
|
|
||||||
if (environment.getVRHardware() instanceof OpenVR){
|
|
||||||
return ((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid != 0;
|
|
||||||
} 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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -349,19 +317,9 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
if( isInputDeviceTracking(index) == false ){
|
if( isInputDeviceTracking(index) == false ){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
index = controllerIndex[index];
|
||||||
if (environment != null){
|
VRUtil.convertMatrix4toQuat(OpenVR.poseMatrices[index], rotStore[index]);
|
||||||
|
return rotStore[index];
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -370,23 +328,12 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (environment != null){
|
// the hmdPose comes in rotated funny, fix that here
|
||||||
|
index = controllerIndex[index];
|
||||||
if (environment.getVRHardware() instanceof OpenVR){
|
OpenVR.poseMatrices[index].toTranslationVector(posStore[index]);
|
||||||
// the hmdPose comes in rotated funny, fix that here
|
posStore[index].x = -posStore[index].x;
|
||||||
index = controllerIndex[index];
|
posStore[index].z = -posStore[index].z;
|
||||||
((OpenVR)environment.getVRHardware()).poseMatrices[index].toTranslationVector(posStore[index]);
|
return posStore[index];
|
||||||
posStore[index].x = -posStore[index].x;
|
|
||||||
posStore[index].z = -posStore[index].z;
|
|
||||||
return posStore[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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -464,7 +411,8 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
if (environment != null){
|
if (environment != null){
|
||||||
controllerCount = 0;
|
controllerCount = 0;
|
||||||
for(int i=0;i<JOpenVRLibrary.k_unMaxTrackedDeviceCount;i++) {
|
for(int i=0;i<JOpenVRLibrary.k_unMaxTrackedDeviceCount;i++) {
|
||||||
if( ((OpenVR)environment.getVRHardware()).getVRSystem().GetTrackedDeviceClass.apply(i) == JOpenVRLibrary.ETrackedDeviceClass.ETrackedDeviceClass_TrackedDeviceClass_Controller ) {
|
int classCallback = ((OpenVR)environment.getVRHardware()).getVRSystem().GetTrackedDeviceClass.apply(i);
|
||||||
|
if( classCallback == JOpenVRLibrary.ETrackedDeviceClass.ETrackedDeviceClass_TrackedDeviceClass_Controller || classCallback == JOpenVRLibrary.ETrackedDeviceClass.ETrackedDeviceClass_TrackedDeviceClass_GenericTracker) {
|
||||||
|
|
||||||
String controllerName = "Unknown";
|
String controllerName = "Unknown";
|
||||||
String manufacturerName = "Unknown";
|
String manufacturerName = "Unknown";
|
||||||
@ -477,12 +425,6 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
|
|
||||||
controllerIndex[controllerCount] = i;
|
controllerIndex[controllerCount] = i;
|
||||||
|
|
||||||
// Adding tracked controller to control.
|
|
||||||
if (trackedControllers == null){
|
|
||||||
trackedControllers = new ArrayList<VRTrackedController>(JOpenVRLibrary.k_unMaxTrackedDeviceCount);
|
|
||||||
}
|
|
||||||
trackedControllers.add(new OpenVRTrackedController(i, this, controllerName, manufacturerName, environment));
|
|
||||||
|
|
||||||
// Send an Haptic pulse to the controller
|
// Send an Haptic pulse to the controller
|
||||||
triggerHapticPulse(controllerCount, 1.0f);
|
triggerHapticPulse(controllerCount, 1.0f);
|
||||||
|
|
||||||
@ -503,7 +445,7 @@ public class OpenVRInput implements VRInputAPI {
|
|||||||
if (environment != null){
|
if (environment != null){
|
||||||
for(int i=0;i<controllerCount;i++) {
|
for(int i=0;i<controllerCount;i++) {
|
||||||
int index = controllerIndex[i];
|
int index = controllerIndex[i];
|
||||||
((OpenVR)environment.getVRHardware()).getVRSystem().GetControllerState.apply(index, cStates[index], 5);
|
((OpenVR)environment.getVRHardware()).getVRSystem().GetControllerState.apply(index, cStates[index], 64);
|
||||||
cStates[index].readField("ulButtonPressed");
|
cStates[index].readField("ulButtonPressed");
|
||||||
cStates[index].readField("rAxis");
|
cStates[index].readField("rAxis");
|
||||||
needsNewVelocity[index] = true;
|
needsNewVelocity[index] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user