commit
d1166f40c1
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,3 +43,4 @@
|
||||
!/jme3-vr/src/main/resources/**/*.so.dbg
|
||||
!/jme3-vr/src/main/resources/**/*.dll
|
||||
!/jme3-vr/src/main/resources/**/*.pdb
|
||||
/buildMaven.bat
|
||||
|
@ -241,7 +241,7 @@ public class VRAppState extends AbstractAppState {
|
||||
return application.getViewPort();
|
||||
}
|
||||
|
||||
return environment.getVRViewManager().getLeftViewport();
|
||||
return environment.getVRViewManager().getLeftViewPort();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,7 +253,7 @@ public class VRAppState extends AbstractAppState {
|
||||
if( environment.getVRViewManager() == null ){
|
||||
return application.getViewPort();
|
||||
}
|
||||
return environment.getVRViewManager().getRightViewport();
|
||||
return environment.getVRViewManager().getRightViewPort();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,12 +263,12 @@ public class VRAppState extends AbstractAppState {
|
||||
public void setBackgroundColors(ColorRGBA clr) {
|
||||
if( environment.getVRViewManager() == null ) {
|
||||
application.getViewPort().setBackgroundColor(clr);
|
||||
} else if( environment.getVRViewManager().getLeftViewport() != null ) {
|
||||
} else if( environment.getVRViewManager().getLeftViewPort() != null ) {
|
||||
|
||||
environment.getVRViewManager().getLeftViewport().setBackgroundColor(clr);
|
||||
environment.getVRViewManager().getLeftViewPort().setBackgroundColor(clr);
|
||||
|
||||
if( environment.getVRViewManager().getRightViewport() != null ){
|
||||
environment.getVRViewManager().getRightViewport().setBackgroundColor(clr);
|
||||
if( environment.getVRViewManager().getRightViewPort() != null ){
|
||||
environment.getVRViewManager().getRightViewPort().setBackgroundColor(clr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ public abstract class VRApplication implements Application, SystemListener {
|
||||
dummyCam = new Camera();
|
||||
|
||||
initStateManager();
|
||||
|
||||
|
||||
// Create the GUI manager.
|
||||
guiManager = new VRGuiManager(null);
|
||||
|
||||
@ -1085,7 +1085,7 @@ public abstract class VRApplication implements Application, SystemListener {
|
||||
*/
|
||||
public ViewPort getLeftViewPort() {
|
||||
if( viewmanager == null ) return getViewPort();
|
||||
return viewmanager.getLeftViewport();
|
||||
return viewmanager.getLeftViewPort();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1095,7 +1095,7 @@ public abstract class VRApplication implements Application, SystemListener {
|
||||
*/
|
||||
public ViewPort getRightViewPort() {
|
||||
if( viewmanager == null ) return getViewPort();
|
||||
return viewmanager.getRightViewport();
|
||||
return viewmanager.getRightViewPort();
|
||||
}
|
||||
|
||||
|
||||
@ -1106,9 +1106,9 @@ public abstract class VRApplication implements Application, SystemListener {
|
||||
public void setBackgroundColors(ColorRGBA clr) {
|
||||
if( viewmanager == null ) {
|
||||
getViewPort().setBackgroundColor(clr);
|
||||
} else if( viewmanager.getLeftViewport() != null ) {
|
||||
viewmanager.getLeftViewport().setBackgroundColor(clr);
|
||||
if( viewmanager.getRightViewport() != null ) viewmanager.getRightViewport().setBackgroundColor(clr);
|
||||
} else if( viewmanager.getLeftViewPort() != null ) {
|
||||
viewmanager.getLeftViewPort().setBackgroundColor(clr);
|
||||
if( viewmanager.getRightViewPort() != null ) viewmanager.getRightViewPort().setBackgroundColor(clr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import com.jme3.app.state.AppState;
|
||||
import com.jme3.input.vr.OSVR;
|
||||
import com.jme3.input.vr.OpenVR;
|
||||
import com.jme3.input.vr.VRAPI;
|
||||
import com.jme3.input.vr.VRBounds;
|
||||
import com.jme3.input.vr.VRInputAPI;
|
||||
import com.jme3.renderer.Camera;
|
||||
import com.jme3.scene.Spatial;
|
||||
@ -28,6 +29,8 @@ public class VREnvironment {
|
||||
private VRMouseManager mouseManager = null;
|
||||
private VRViewManager viewmanager = null;
|
||||
|
||||
private VRBounds bounds = null;
|
||||
|
||||
/**
|
||||
* The underlying system VR API. By default set to {@link VRConstants#SETTING_VRAPI_OPENVR_VALUE}.
|
||||
*/
|
||||
@ -65,7 +68,6 @@ public class VREnvironment {
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private boolean attached = false;
|
||||
|
||||
public VREnvironment(AppSettings settings){
|
||||
|
||||
@ -73,7 +75,8 @@ public class VREnvironment {
|
||||
|
||||
guiManager = new VRGuiManager(this);
|
||||
mouseManager = new VRMouseManager(this);
|
||||
// dummyCam = new Camera(settings.getWidth(), settings.getHeight());
|
||||
|
||||
bounds = new VRBounds();
|
||||
|
||||
processSettings();
|
||||
}
|
||||
@ -86,6 +89,14 @@ public class VREnvironment {
|
||||
return hardware;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VR bounds.
|
||||
* @return the VR bounds.
|
||||
*/
|
||||
public VRBounds getVRBounds(){
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VR dedicated input.
|
||||
* @return the VR dedicated input.
|
||||
@ -347,7 +358,12 @@ public class VREnvironment {
|
||||
if (application.getCamera() != null){
|
||||
dummyCam = application.getCamera().clone();
|
||||
} else {
|
||||
return new Camera(settings.getWidth(), settings.getHeight());
|
||||
|
||||
if ((settings != null) && (settings.getWidth() != 0) && (settings.getHeight() != 0)){
|
||||
dummyCam = new Camera(settings.getWidth(), settings.getHeight());
|
||||
} else {
|
||||
dummyCam = new Camera();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("VR environment is not attached to any application.");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package com.jme3.input.vr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -183,28 +184,50 @@ public class OpenVRInput implements VRInputAPI {
|
||||
|
||||
@Override
|
||||
public Vector3f getVelocity(int controllerIndex) {
|
||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||
if( needsNewVelocity[index] ) {
|
||||
OpenVR.hmdTrackedDevicePoses[index].readField("vVelocity");
|
||||
needsNewVelocity[index] = false;
|
||||
}
|
||||
tempVel.x = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[0];
|
||||
tempVel.y = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[1];
|
||||
tempVel.z = OpenVR.hmdTrackedDevicePoses[index].vVelocity.v[2];
|
||||
return tempVel;
|
||||
|
||||
if (environment != null){
|
||||
|
||||
if (environment.getVRHardware() instanceof OpenVR){
|
||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||
if( needsNewVelocity[index] ) {
|
||||
((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].readField("vVelocity");
|
||||
needsNewVelocity[index] = false;
|
||||
}
|
||||
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
|
||||
public Vector3f getAngularVelocity(int controllerIndex) {
|
||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||
if( needsNewAngVelocity[index] ) {
|
||||
OpenVR.hmdTrackedDevicePoses[index].readField("vAngularVelocity");
|
||||
needsNewAngVelocity[index] = false;
|
||||
}
|
||||
tempVel.x = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[0];
|
||||
tempVel.y = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[1];
|
||||
tempVel.z = OpenVR.hmdTrackedDevicePoses[index].vAngularVelocity.v[2];
|
||||
return tempVel;
|
||||
|
||||
if (environment != null){
|
||||
|
||||
if (environment.getVRHardware() instanceof OpenVR){
|
||||
|
||||
int index = OpenVRInput.controllerIndex[controllerIndex];
|
||||
if( needsNewAngVelocity[index] ) {
|
||||
((OpenVR)environment.getVRHardware()).hmdTrackedDevicePoses[index].readField("vAngularVelocity");
|
||||
needsNewAngVelocity[index] = false;
|
||||
}
|
||||
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
|
||||
@ -309,7 +332,16 @@ public class OpenVRInput implements VRInputAPI {
|
||||
return false;
|
||||
}
|
||||
|
||||
return OpenVR.hmdTrackedDevicePoses[controllerIndex[index]].bPoseIsValid != 0;
|
||||
if (environment != null){
|
||||
|
||||
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
|
||||
@ -317,9 +349,19 @@ public class OpenVRInput implements VRInputAPI {
|
||||
if( isInputDeviceTracking(index) == false ){
|
||||
return null;
|
||||
}
|
||||
index = controllerIndex[index];
|
||||
VRUtil.convertMatrix4toQuat(OpenVR.poseMatrices[index], rotStore[index]);
|
||||
return rotStore[index];
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -328,12 +370,23 @@ public class OpenVRInput implements VRInputAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
// the hmdPose comes in rotated funny, fix that here
|
||||
index = controllerIndex[index];
|
||||
OpenVR.poseMatrices[index].toTranslationVector(posStore[index]);
|
||||
posStore[index].x = -posStore[index].x;
|
||||
posStore[index].z = -posStore[index].z;
|
||||
return posStore[index];
|
||||
if (environment != null){
|
||||
|
||||
if (environment.getVRHardware() instanceof OpenVR){
|
||||
// the hmdPose comes in rotated funny, fix that here
|
||||
index = controllerIndex[index];
|
||||
((OpenVR)environment.getVRHardware()).poseMatrices[index].toTranslationVector(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
|
||||
@ -411,9 +464,9 @@ public class OpenVRInput implements VRInputAPI {
|
||||
if (environment != null){
|
||||
controllerCount = 0;
|
||||
for(int i=0;i<JOpenVRLibrary.k_unMaxTrackedDeviceCount;i++) {
|
||||
int classCallback = ((OpenVR)environment.getVRHardware()).getVRSystem().GetTrackedDeviceClass.apply(i);
|
||||
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 manufacturerName = "Unknown";
|
||||
try {
|
||||
@ -425,6 +478,12 @@ public class OpenVRInput implements VRInputAPI {
|
||||
|
||||
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
|
||||
triggerHapticPulse(controllerCount, 1.0f);
|
||||
|
||||
|
@ -0,0 +1,93 @@
|
||||
package com.jme3.input.vr;
|
||||
|
||||
import com.jme3.app.VREnvironment;
|
||||
import com.jme3.math.Matrix4f;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
public class OpenVRTrackedController implements VRTrackedController{
|
||||
|
||||
/**
|
||||
* The index of the controller within the unserlying VR API.
|
||||
*/
|
||||
private int controllerIndex = -1;
|
||||
|
||||
/**
|
||||
* The underlying VRAPI.
|
||||
*/
|
||||
private OpenVRInput hardware = null;
|
||||
|
||||
/**
|
||||
* The name of the controller.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private VREnvironment environment;
|
||||
|
||||
/**
|
||||
* Wrap a new VR tracked controller on an OpenVR system.
|
||||
* @param controllerIndex the index of the controller within the underlying VR system.
|
||||
* @param hardware the underlying VR system.
|
||||
* @param name the name of the controller.
|
||||
* @param manufacturer the manufacturer of the controller.
|
||||
* @param environment the VR environment.
|
||||
*/
|
||||
public OpenVRTrackedController(int controllerIndex, OpenVRInput hardware, String name, String manufacturer, VREnvironment environment){
|
||||
this.controllerIndex = controllerIndex;
|
||||
this.hardware = hardware;
|
||||
|
||||
this.name = name;
|
||||
this.manufacturer = manufacturer;
|
||||
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The manufacturer of the controller.
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
@Override
|
||||
public Vector3f getPosition() {
|
||||
if (hardware != null){
|
||||
return hardware.getPosition(controllerIndex);
|
||||
} else {
|
||||
throw new IllegalStateException("No underlying VR API.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Quaternion getOrientation() {
|
||||
if (hardware != null){
|
||||
return hardware.getOrientation(controllerIndex);
|
||||
} else {
|
||||
throw new IllegalStateException("No underlying VR API.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matrix4f getPose(){
|
||||
|
||||
if (environment != null){
|
||||
if (hardware != null){
|
||||
return ((OpenVR)environment.getVRHardware()).poseMatrices[controllerIndex];
|
||||
} else {
|
||||
throw new IllegalStateException("No underlying VR API.");
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("VR tracked device is not attached to any environment.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControllerName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getControllerManufacturer() {
|
||||
return manufacturer;
|
||||
}
|
||||
}
|
@ -16,19 +16,19 @@ public class VRBounds {
|
||||
|
||||
private static Logger logger = Logger.getLogger(VRBounds.class.getName());
|
||||
|
||||
private static VR_IVRChaperone_FnTable vrChaperone;
|
||||
private static Vector2f playSize;
|
||||
private VR_IVRChaperone_FnTable vrChaperone;
|
||||
private Vector2f playSize;
|
||||
|
||||
/**
|
||||
* Initialize the VR bounds.
|
||||
* @return <code>true</code> if the initialization is a success and <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean init() {
|
||||
public boolean init(OpenVR api) {
|
||||
|
||||
logger.config("Initialize VR bounds...");
|
||||
|
||||
if( vrChaperone == null ) {
|
||||
vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, OpenVR.hmdErrorStore).getPointer());
|
||||
vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer());
|
||||
if( vrChaperone != null ) {
|
||||
vrChaperone.setAutoSynch(false);
|
||||
vrChaperone.read();
|
||||
@ -53,7 +53,7 @@ public class VRBounds {
|
||||
* Get the size of the VR world.
|
||||
* @return the size of the VR world.
|
||||
*/
|
||||
public static Vector2f getPlaySize() {
|
||||
public Vector2f getPlaySize() {
|
||||
return playSize;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.jme3.input.vr;
|
||||
|
||||
import com.jme3.math.Matrix4f;
|
||||
import com.jme3.math.Quaternion;
|
||||
import com.jme3.math.Vector3f;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @author Julien Seinturier - (c) 2016 - JOrigin project - <a href="http://www.jorigin.org">http:/www.jorigin.org</a>
|
||||
@ -7,4 +11,40 @@ package com.jme3.input.vr;
|
||||
*/
|
||||
public interface VRTrackedController {
|
||||
|
||||
/**
|
||||
* Get the controller name.
|
||||
* @return the controller name.
|
||||
*/
|
||||
public String getControllerName();
|
||||
|
||||
/**
|
||||
* Get the controller manufacturer.
|
||||
* @return the controller manufacturer.
|
||||
*/
|
||||
public String getControllerManufacturer();
|
||||
|
||||
/**
|
||||
* Get the position of the tracked device. This value is the translation component of the device {@link #getPose() pose}.
|
||||
* @return the position of the tracked device.
|
||||
* @see #getOrientation()
|
||||
* @see #getPose()
|
||||
*/
|
||||
public Vector3f getPosition();
|
||||
|
||||
/**
|
||||
* Get the orientation of the tracked device. This value is the rotation component of the device {@link #getPose() pose}.
|
||||
* @return the orientation of the tracked device.
|
||||
* @see #getPosition()
|
||||
* @see #getPose()
|
||||
*/
|
||||
public Quaternion getOrientation();
|
||||
|
||||
/**
|
||||
* Get the pose of the tracked device.
|
||||
* The pose is a 4x4 matrix than combine the {@link #getPosition() position} and the {@link #getOrientation() orientation} of the device.
|
||||
* @return the pose of the tracked device.
|
||||
* @see #getPosition()
|
||||
* @see #getOrientation()
|
||||
*/
|
||||
public Matrix4f getPose();
|
||||
}
|
||||
|
@ -28,18 +28,20 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
protected VREnvironment environment = null;
|
||||
|
||||
protected Camera leftCamera;
|
||||
protected ViewPort leftViewport;
|
||||
protected ViewPort leftViewPort;
|
||||
protected FilterPostProcessor leftPostProcessor;
|
||||
protected Texture2D leftEyeTexture;
|
||||
protected Texture2D leftEyeDepth;
|
||||
|
||||
protected Camera rightCamera;
|
||||
protected ViewPort rightViewport;
|
||||
protected ViewPort rightViewPort;
|
||||
protected FilterPostProcessor rightPostProcessor;
|
||||
protected Texture2D rightEyeTexture;
|
||||
protected Texture2D rightEyeDepth;
|
||||
|
||||
private float resMult = 1f;
|
||||
protected ViewPort mirrorViewPort;
|
||||
|
||||
private float resMult = 1f;
|
||||
|
||||
private float heightAdjustment;
|
||||
|
||||
@ -54,15 +56,24 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewPort getLeftViewport() {
|
||||
return leftViewport;
|
||||
public ViewPort getLeftViewPort() {
|
||||
return leftViewPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewPort getRightViewport() {
|
||||
return rightViewport;
|
||||
public ViewPort getRightViewPort() {
|
||||
return rightViewPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ViewPort view port} attached to the mirror display.
|
||||
* @return the view port attached to the mirror display.
|
||||
*/
|
||||
public ViewPort getMirrorViewPort() {
|
||||
return mirrorViewPort;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Texture2D getLeftTexture(){
|
||||
return leftEyeTexture;
|
||||
@ -124,7 +135,7 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
public void moveScreenProcessingToEyes() {
|
||||
|
||||
if (environment != null){
|
||||
if( getRightViewport() == null ){
|
||||
if( getRightViewPort() == null ){
|
||||
return;
|
||||
}
|
||||
|
||||
@ -150,7 +161,7 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
public void syncScreenProcessing(ViewPort sourceViewport) {
|
||||
|
||||
if (environment != null){
|
||||
if( getRightViewport() == null ){
|
||||
if( getRightViewPort() == null ){
|
||||
return;
|
||||
}
|
||||
|
||||
@ -163,13 +174,13 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
// clear out all filters & processors, to start from scratch
|
||||
getRightPostProcessor().removeAllFilters();
|
||||
getLeftPostProcessor().removeAllFilters();
|
||||
getLeftViewport().clearProcessors();
|
||||
getRightViewport().clearProcessors();
|
||||
getLeftViewPort().clearProcessors();
|
||||
getRightViewPort().clearProcessors();
|
||||
// if we have no processors to sync, don't add the FilterPostProcessor
|
||||
if( sourceViewport.getProcessors().isEmpty() ) return;
|
||||
// add post processors we just made, which are empty
|
||||
getLeftViewport().addProcessor(getLeftPostProcessor());
|
||||
getRightViewport().addProcessor(getRightPostProcessor());
|
||||
getLeftViewPort().addProcessor(getLeftPostProcessor());
|
||||
getRightViewPort().addProcessor(getRightPostProcessor());
|
||||
// go through all of the filters in the processors list
|
||||
// add them to the left viewport processor & clone them to the right
|
||||
for(SceneProcessor sceneProcessor : sourceViewport.getProcessors()) {
|
||||
@ -202,8 +213,8 @@ public abstract class AbstractVRViewManager implements VRViewManager {
|
||||
VRDirectionalLightShadowRenderer dlsr = (VRDirectionalLightShadowRenderer) sceneProcessor;
|
||||
VRDirectionalLightShadowRenderer dlsrRight = dlsr.clone();
|
||||
dlsrRight.setLight(dlsr.getLight());
|
||||
getRightViewport().getProcessors().add(0, dlsrRight);
|
||||
getLeftViewport().getProcessors().add(0, sceneProcessor);
|
||||
getRightViewPort().getProcessors().add(0, dlsrRight);
|
||||
getLeftViewPort().getProcessors().add(0, sceneProcessor);
|
||||
}
|
||||
}
|
||||
// make sure each has a translucent filter renderer
|
||||
|
@ -42,17 +42,25 @@ public interface VRViewManager {
|
||||
/**
|
||||
* Get the {@link ViewPort viewport} attached to the left eye.
|
||||
* @return the {@link ViewPort viewport} attached to the left eye.
|
||||
* @see #getRightViewport()
|
||||
* @see #getRightViewPort()
|
||||
*/
|
||||
public ViewPort getLeftViewport();
|
||||
public ViewPort getLeftViewPort();
|
||||
|
||||
|
||||
/**
|
||||
* Get the {@link ViewPort viewport} attached to the right eye.
|
||||
* @return the {@link ViewPort viewport} attached to the right eye.
|
||||
* @see #getLeftViewport()
|
||||
* @see #getLeftViewPort()
|
||||
*/
|
||||
public ViewPort getRightViewport();
|
||||
public ViewPort getRightViewPort();
|
||||
|
||||
/**
|
||||
* Get the {@link ViewPort view port} attached to the mirror display.
|
||||
* @return the view port attached to the mirror display.
|
||||
* @see #getLeftViewPort()
|
||||
* @see #getRightViewPort()
|
||||
*/
|
||||
public ViewPort getMirrorViewPort();
|
||||
|
||||
/**
|
||||
* Get the texture attached to the left eye.
|
||||
|
@ -117,18 +117,18 @@ public class VRViewManagerOSVR extends AbstractVRViewManager{
|
||||
/**
|
||||
* Get the {@link ViewPort viewport} attached to the left eye.
|
||||
* @return the {@link ViewPort viewport} attached to the left eye.
|
||||
* @see #getRightViewport()
|
||||
* @see #getRightViewPort()
|
||||
*/
|
||||
public ViewPort getLeftViewport() {
|
||||
public ViewPort getLeftViewPort() {
|
||||
return leftViewport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link ViewPort viewport} attached to the right eye.
|
||||
* @return the {@link ViewPort viewport} attached to the right eye.
|
||||
* @see #getLeftViewport()
|
||||
* @see #getLeftViewPort()
|
||||
*/
|
||||
public ViewPort getRightViewport() {
|
||||
public ViewPort getRightViewPort() {
|
||||
return rightViewport;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ package com.jme3.util;
|
||||
import com.jme3.app.VREnvironment;
|
||||
import com.jme3.input.vr.OpenVR;
|
||||
import com.jme3.input.vr.VRAPI;
|
||||
import com.jme3.input.vr.VRTrackedController;
|
||||
import com.jme3.material.Material;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Quaternion;
|
||||
@ -346,10 +347,10 @@ public class VRViewManagerOpenVR extends AbstractVRViewManager {
|
||||
return;
|
||||
}
|
||||
|
||||
leftEyeTexture = (Texture2D) getLeftViewport().getOutputFrameBuffer().getColorBuffer().getTexture();
|
||||
rightEyeTexture = (Texture2D)getRightViewport().getOutputFrameBuffer().getColorBuffer().getTexture();
|
||||
leftEyeDepth = (Texture2D) getLeftViewport().getOutputFrameBuffer().getDepthBuffer().getTexture();
|
||||
rightEyeDepth = (Texture2D)getRightViewport().getOutputFrameBuffer().getDepthBuffer().getTexture();
|
||||
leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture();
|
||||
rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture();
|
||||
leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture();
|
||||
rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture();
|
||||
|
||||
// main viewport is either going to be a distortion scene or nothing
|
||||
// mirroring is handled by copying framebuffers
|
||||
@ -387,6 +388,7 @@ public class VRViewManagerOpenVR extends AbstractVRViewManager {
|
||||
|
||||
if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) {
|
||||
setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false);
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("This VR environment is not attached to any application.");
|
||||
@ -414,9 +416,35 @@ public class VRViewManagerOpenVR extends AbstractVRViewManager {
|
||||
// grab the hardware handle
|
||||
VRAPI dev = environment.getVRHardware();
|
||||
if( dev != null ) {
|
||||
|
||||
|
||||
// update the HMD's position & orientation
|
||||
dev.updatePose();
|
||||
dev.getPositionAndOrientation(hmdPos, hmdRot);
|
||||
/*
|
||||
// TOREMOVE
|
||||
Vector3f v = dev.getVRinput().getTrackedController(0).getPosition();
|
||||
Quaternion q = dev.getVRinput().getTrackedController(0).getOrientation();
|
||||
if ((v != null)&&(q != null)){
|
||||
hmdPos.set(v);
|
||||
hmdRot.set(q);
|
||||
}
|
||||
|
||||
logger.severe("HMD controller ");
|
||||
logger.severe(" Position "+hmdPos);
|
||||
logger.severe(" Orientation "+hmdRot);
|
||||
|
||||
VRTrackedController tc = null;
|
||||
for(int i = 0; i < dev.getVRinput().getTrackedControllerCount(); i++){
|
||||
tc = dev.getVRinput().getTrackedController(i);
|
||||
logger.severe("Tracked controller "+i+": "+tc.getControllerName());
|
||||
logger.severe(" Position "+tc.getPosition());
|
||||
logger.severe(" Orientation "+tc.getOrientation());
|
||||
logger.severe("");
|
||||
}
|
||||
*/
|
||||
// TOREMOVE
|
||||
|
||||
if( obs != null ) {
|
||||
// update hmdPos based on obs rotation
|
||||
finalRotation.set(objRot);
|
||||
@ -490,18 +518,18 @@ public class VRViewManagerOpenVR extends AbstractVRViewManager {
|
||||
//org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL30.GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
if( !environment.isInstanceRendering()) {
|
||||
leftViewport = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME);
|
||||
leftViewPort = setupViewBuffers(getLeftCamera(), LEFT_VIEW_NAME);
|
||||
rightCamera = getLeftCamera().clone();
|
||||
if( environment.getVRHardware() != null ){
|
||||
getRightCamera().setProjectionMatrix(environment.getVRHardware().getHMDMatrixProjectionRightEye(getRightCamera()));
|
||||
}
|
||||
rightViewport = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME);
|
||||
rightViewPort = setupViewBuffers(getRightCamera(), RIGHT_VIEW_NAME);
|
||||
} else {
|
||||
|
||||
if (environment.getApplication() != null){
|
||||
|
||||
logger.severe("THIS CODE NEED CHANGES !!!");
|
||||
leftViewport = environment.getApplication().getViewPort();
|
||||
leftViewPort = environment.getApplication().getViewPort();
|
||||
//leftViewport.attachScene(app.getRootNode());
|
||||
rightCamera = getLeftCamera().clone();
|
||||
if( environment.getVRHardware() != null ){
|
||||
@ -520,7 +548,7 @@ public class VRViewManagerOpenVR extends AbstractVRViewManager {
|
||||
}
|
||||
|
||||
// setup gui
|
||||
environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewport(), getRightViewport());
|
||||
environment.getVRGUIManager().setupGui(getLeftCamera(), getRightCamera(), getLeftViewPort(), getRightViewPort());
|
||||
|
||||
if( environment.getVRHardware() != null ) {
|
||||
// call these to cache the results internally
|
||||
|
Loading…
x
Reference in New Issue
Block a user