/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (in physics-space coordinates, not * null) */ protected Quaternion getSpatialRotation() { if (applyLocal) { return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (not null) */ private Quaternion getSpatialRotation() { if (applyLocal) { return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (in physics-space coordinates, not * null) */ protected Quaternion getSpatialRotation() { if (applyLocal) { return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (not null) */ private Quaternion getSpatialRotation() { if (applyLocal) { return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (not null) */ private Quaternion getSpatialRotation(){ if(motionState.isApplyPhysicsLocal()){ return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
private Quaternion getSpatialRotation(){ if(motionState.isApplyPhysicsLocal()){ return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Access whichever spatial rotation corresponds to the physics rotation. * * @return the pre-existing quaternion (not null) */ private Quaternion getSpatialRotation(){ if(motionState.isApplyPhysicsLocal()){ return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
private Quaternion getSpatialRotation(){ if(motionState.isApplyPhysicsLocal()){ return spatial.getLocalRotation(); } return spatial.getWorldRotation(); }
/** * Get the observer final rotation within the scene. * @return the observer final rotation within the scene. * @see #getFinalObserverPosition() */ public Quaternion getFinalObserverRotation() { if( viewmanager == null ) { if( observer == null ) { return getCamera().getRotation(); } else return observer.getWorldRotation(); } if( observer == null ) { tempq.set(dummyCam.getRotation()); } else { tempq.set(observer.getWorldRotation()); } return tempq.multLocal(VRhardware.getOrientation()); }
public void setSpatial(Spatial spatial) { this.spatial = spatial; setUserObject(spatial); if (spatial == null) { return; } setPhysicsLocation(spatial.getWorldTranslation()); setPhysicsRotation(spatial.getWorldRotation().toRotationMatrix()); }
@Override public Quaternion getFinalObserverRotation(int index) { OSVRViewManager vrvm = (OSVRViewManager)environment.getVRViewManager(); if( vrvm == null || isInputDeviceTracking(index) == false ) return null; Object obs = environment.getObserver(); if( obs instanceof Camera ) { tempq.set(((Camera)obs).getRotation()); } else { tempq.set(((Spatial)obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); }
/** * Get the observer final rotation within the scene. * @return the observer final rotation within the scene. * @see #getFinalObserverPosition() */ public Quaternion getFinalObserverRotation() { if( environment.getVRViewManager() == null ) { if( environment.getObserver() == null ) { return environment.getCamera().getRotation(); } else { return ((Spatial)environment.getObserver()).getWorldRotation(); } } if( environment.getObserver() == null ) { tempq.set(environment.getDummyCamera().getRotation()); } else { tempq.set(((Spatial)environment.getObserver()).getWorldRotation()); } return tempq.multLocal(environment.getVRHardware().getOrientation()); }
@Override public Quaternion getFinalObserverRotation(int index) { // Copied from OpenVRInput VREnvironment env = hardware.getEnvironment(); OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); Object obs = env.getObserver(); Quaternion tempq = new Quaternion(); // TODO move to class scope? if (obs instanceof Camera) { tempq.set(((Camera) obs).getRotation()); } else { tempq.set(((Spatial) obs).getWorldRotation()); } return tempq.multLocal(getOrientation(index)); }
@Override public Vector3f getFinalObserverPosition(int index) { OSVRViewManager vrvm = (OSVRViewManager) environment.getVRViewManager(); if( vrvm == null || 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()); } }
@Override public Vector3f getFinalObserverPosition(int index) { // Copied from OpenVRInput VREnvironment env = hardware.getEnvironment(); OculusViewManager vrvm = (OculusViewManager) hardware.getEnvironment().getVRViewManager(); Object obs = env.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()); } }
/** * Get the observer final position within the scene. * @return the observer position. * @see #getFinalObserverRotation() */ public Vector3f getFinalObserverPosition() { if( viewmanager == null ) { if( observer == null ) { return getCamera().getLocation(); } else return observer.getWorldTranslation(); } Vector3f pos = VRhardware.getPosition(); if( observer == null ) { dummyCam.getRotation().mult(pos, pos); return pos.addLocal(dummyCam.getLocation()); } else { observer.getWorldRotation().mult(pos, pos); return pos.addLocal(observer.getWorldTranslation()); } }
/** * Alter the transforms of a rigidBody to match the transforms of a bone. * This is used to make the ragdoll follow animated motion in Kinematic mode * * @param link the bone link connecting the bone and the rigidBody * @param position temporary storage used in calculations (not null) * @param tmpRot1 temporary storage used in calculations (not null) */ protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) { //computing position from rotation and scale targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position); //computing rotation tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation()); targetModel.getWorldRotation().mult(tmpRot1, tmpRot1); tmpRot1.normalizeLocal(); //updating physics location/rotation of the physics bone link.rigidBody.setPhysicsLocation(position); link.rigidBody.setPhysicsRotation(tmpRot1); }
/** * Alter the transforms of a rigidBody to match the transforms of a bone. * This is used to make the ragdoll follow animated motion in Kinematic mode * * @param link the bone link connecting the bone and the rigidBody * @param position temporary storage used in calculations (not null) * @param tmpRot1 temporary storage used in calculations (not null) */ protected void matchPhysicObjectToBone(PhysicsBoneLink link, Vector3f position, Quaternion tmpRot1) { //computing position from rotation and scale targetModel.getWorldTransform().transformVector(link.bone.getModelSpacePosition(), position); //computing rotation tmpRot1.set(link.bone.getModelSpaceRotation()).multLocal(link.bone.getModelBindInverseRotation()); targetModel.getWorldRotation().mult(tmpRot1, tmpRot1); tmpRot1.normalizeLocal(); //updating physics location/rotation of the physics bone link.rigidBody.setPhysicsLocation(position); link.rigidBody.setPhysicsRotation(tmpRot1); }
private void spatialToLight(Light light) { final Vector3f worldTranslation = spatial.getWorldTranslation(); if (light instanceof PointLight) { ((PointLight) light).setPosition(worldTranslation); return; } final TempVars vars = TempVars.get(); final Vector3f vec = vars.vect1; if (light instanceof DirectionalLight) { ((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f)); } if (light instanceof SpotLight) { final SpotLight spotLight = (SpotLight) light; spotLight.setPosition(worldTranslation); spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1))); } vars.release(); }
@Override public void update(float tpf) { // update VR pose & cameras if( environment.getVRViewManager() != null ) { environment.getVRViewManager().update(tpf); } else if( environment.getObserver() != null ) { environment.getCamera().setFrame(((Spatial)environment.getObserver()).getWorldTranslation(), ((Spatial)environment.getObserver()).getWorldRotation()); } if( environment.isInVR() == false || environment.getVRGUIManager().getPositioningMode() == VRGUIPositioningMode.MANUAL ) { // only update geometric state here if GUI is in manual mode, or not in VR // it will get updated automatically in the viewmanager update otherwise // TODO isn't this done by SimpleApplication? for (Spatial spatial : application.getGuiViewPort().getScenes()) { //spatial.updateLogicalState(tpf); spatial.updateGeometricState(); } } // use the analog control on the first tracked controller to push around the mouse environment.getVRMouseManager().updateAnalogAsMouse(0, null, null, null, tpf); }