@Override public void update(float tpf) { if (spatial == null) { throw new IllegalArgumentException("The spatial to follow is null, please use the setTarget method"); } target.setLocalTranslation(spatial.getWorldTranslation()); camNode.lookAt(target.getWorldTranslation(), upVector); target.updateLogicalState(tpf); target.updateGeometricState(); }
private void createCameraMotion() { CameraNode camNode = cinematic.bindCamera("topView", cam); camNode.setLocalTranslation(new Vector3f(0, 50, 0)); camNode.lookAt(teapot.getLocalTranslation(), Vector3f.UNIT_Y); CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam); path = new MotionPath(); path.setCycle(true); path.addWayPoint(new Vector3f(20, 3, 0)); path.addWayPoint(new Vector3f(0, 3, 20)); path.addWayPoint(new Vector3f(-20, 3, 0)); path.addWayPoint(new Vector3f(0, 3, -20)); path.setCurveTension(0.83f); cameraMotionEvent = new MotionEvent(camNode2, path); cameraMotionEvent.setLoopMode(LoopMode.Loop); cameraMotionEvent.setLookAt(model.getWorldTranslation(), Vector3f.UNIT_Y); cameraMotionEvent.setDirectionType(MotionEvent.Direction.LookAt); }
@Override public void simpleInitApp() { // activate physics bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); // init a physical test scene PhysicsTestHelper.createPhysicsTestWorldSoccer(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); // Add a physics character to the world physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f, 1.8f), .1f); physicsCharacter.setPhysicsLocation(new Vector3f(0, 1, 0)); characterNode = new Node("character node"); Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); model.scale(0.25f); characterNode.addControl(physicsCharacter); getPhysicsSpace().add(physicsCharacter); rootNode.attachChild(characterNode); characterNode.attachChild(model); // set forward camera node that follows the character camNode = new CameraNode("CamNode", cam); camNode.setControlDir(ControlDirection.SpatialToCamera); camNode.setLocalTranslation(new Vector3f(0, 1, -5)); camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y); characterNode.attachChild(camNode); //disable the default 1st-person flyCam (don't forget this!!) flyCam.setEnabled(false); }
camNode.lookAt(teaNode.getLocalTranslation(), Vector3f.UNIT_Y);
camNode.lookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
@Override public void update(float tpf) { if (spatial == null) { throw new IllegalArgumentException("The spatial to follow is null, please use the setTarget method"); } target.setLocalTranslation(spatial.getWorldTranslation()); camNode.lookAt(target.getWorldTranslation(), upVector); target.updateLogicalState(tpf); target.updateGeometricState(); }
void initialPos() { TempVars vars = TempVars.get(); Quaternion q = vars.quat1; q.fromAngles(0f, FastMath.DEG_TO_RAD * currentAngle, 0f); Vector3f dir = new Vector3f(0f, 0f, 1f); q.mult(dir, dir); vars.release(); smartphone.setLocalTranslation(screenLoc.add(dir.mult(initialDistance))); smartphone.lookAt(screenLoc, Vector3f.UNIT_Y); bitmapText.setText(String.valueOf(distanceToScreen())+"m"); camNode.lookAt(screenQR.getWorldTranslation(), Vector3f.UNIT_Y); }
@Override public Void call() throws Exception { //Move camNode, e.g. behind and above the target: camNode.setLocalTranslation(new Vector3f(0, 5, -5)); // ... for initial hack-up; probably these offsets need to come from GoodyActionExtractor //Rotate the camNode to look at the target: camNode.lookAt(goodyNode.getLocalTranslation(), Vector3f.UNIT_Y); //This mode means that camera copies the movements of the target: camNode.setControlDir(ControlDirection.SpatialToCamera); //Attach the camNode to the Goody Node: goodyNode.attachChild(camNode); //And the root node -- required? getRenderRegCli().getJme3RootDeepNode(null).attachChild(camNode); return null; } }, qStyle);
camNode.setControlDir(CameraControl.ControlDirection.SpatialToCamera); camNode.setLocalTranslation(new Vector3f(0, height, distance)); camNode.lookAt(screenQR.getWorldTranslation(), Vector3f.UNIT_Y); smartphone.attachChild(camNode);