private void SetNewViewpoint ( String url ) { Viewpoint vp = null ; // get the name without the '#' sign String vpURL = url . substring ( 1 , url . length ( ) ) ; for ( Viewpoint viewpoint : viewpoints ) { if ( viewpoint . getName ( ) . equalsIgnoreCase ( vpURL ) ) { vp = viewpoint ; } } if ( vp != null ) { // found the Viewpoint matching the url GVRCameraRig mainCameraRig = gvrContext . getMainScene ( ) . getMainCameraRig ( ) ; float [ ] cameraPosition = vp . getPosition ( ) ; mainCameraRig . getTransform ( ) . setPosition ( cameraPosition [ 0 ] , cameraPosition [ 1 ] , cameraPosition [ 2 ] ) ; // Set the Gaze controller position which is where the pick ray // begins in the direction of camera.lookt() GVRCursorController gazeController = null ; GVRInputManager inputManager = gvrContext . getInputManager ( ) ; List < GVRCursorController > controllerList = inputManager . getCursorControllers ( ) ; for ( GVRCursorController controller : controllerList ) { if ( controller . getControllerType ( ) == GVRControllerType . GAZE ) ; { gazeController = controller ; break ; } } if ( gazeController != null ) { gazeController . setOrigin ( cameraPosition [ 0 ] , cameraPosition [ 1 ] , cameraPosition [ 2 ] ) ; } } else { Log . e ( TAG , "Viewpoint named " + vpURL + " not found (defined)." ) ; } }
end AnchorImplementation class