public void onAnalog(String name, float value, float tpf) { Vector3f left = rootNode.getLocalRotation().mult(Vector3f.UNIT_X.negate()); Vector3f forward = rootNode.getLocalRotation().mult(Vector3f.UNIT_Z.negate()); Vector3f up = rootNode.getLocalRotation().mult(Vector3f.UNIT_Y); //TODO: properly scale input based on current scaling level tpf = tpf * (10 - (9.0f * currentLevel.getCurrentScaleAmount())); if (name.equals("StrafeLeft") && value > 0) { walkDirection.addLocal(left.mult(tpf)); } else if (name.equals("StrafeRight") && value > 0) { walkDirection.addLocal(left.negate().multLocal(tpf)); } else if (name.equals("Forward") && value > 0) { walkDirection.addLocal(forward.mult(tpf)); } else if (name.equals("Back") && value > 0) { walkDirection.addLocal(forward.negate().multLocal(tpf)); } else if (name.equals("StrafeUp") && value > 0) { walkDirection.addLocal(up.mult(tpf)); } else if (name.equals("StrafeDown") && value > 0) { walkDirection.addLocal(up.negate().multLocal(tpf)); } else if (name.equals("Up") && value > 0) { //TODO: rotate rootNode, needs to be global } else if (name.equals("Down") && value > 0) { } else if (name.equals("Left") && value > 0) { } else if (name.equals("Right") && value > 0) { } else if (name.equals("Esc")) { stop(); } }
@Override public void simpleUpdate(float tpf) { Vector3f camDir = cam.getDirection().mult(0.2f); Vector3f camLeft = cam.getLeft().mult(0.2f); camDir.y = 0; camLeft.y = 0; viewDirection.set(camDir); walkDirection.set(0, 0, 0); if (leftStrafe) { walkDirection.addLocal(camLeft); } else if (rightStrafe) { walkDirection.addLocal(camLeft.negate()); } if (leftRotate) { viewDirection.addLocal(camLeft.mult(0.02f)); } else if (rightRotate) { viewDirection.addLocal(camLeft.mult(0.02f).negate()); } if (forward) { walkDirection.addLocal(camDir); } else if (backward) { walkDirection.addLocal(camDir.negate()); } physicsCharacter.setWalkDirection(walkDirection); physicsCharacter.setViewDirection(viewDirection); }
@Override public void simpleUpdate(float tpf) { Vector3f camDir = cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f); walkDirection.set(0,0,0); if(left) walkDirection.addLocal(camLeft); if(right) walkDirection.addLocal(camLeft.negate()); if(up) walkDirection.addLocal(camDir); if(down) walkDirection.addLocal(camDir.negate()); player.setWalkDirection(walkDirection); cam.setLocation(player.getPhysicsLocation()); }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } } }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } } }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } }
/** * This is the main event loop--walking happens here. * We check in which direction the player is walking by interpreting * the camera direction forward (camDir) and to the side (camLeft). * The setWalkDirection() command is what lets a physics-controlled player walk. * We also make sure here that the camera moves with player. */ @Override public void simpleUpdate(float tpf) { camDir.set(cam.getDirection()).multLocal(0.6f); camLeft.set(cam.getLeft()).multLocal(0.4f); walkDirection.set(0, 0, 0); if (left) { walkDirection.addLocal(camLeft); } if (right) { walkDirection.addLocal(camLeft.negate()); } if (up) { walkDirection.addLocal(camDir); } if (down) { walkDirection.addLocal(camDir.negate()); } player.setWalkDirection(walkDirection); cam.setLocation(player.getPhysicsLocation()); } }
@Override public void simpleUpdate(final float tpf) { Vector3f camDir = this.cam.getDirection().clone().multLocal(0.6f); Vector3f camLeft = this.cam.getLeft().clone().multLocal(0.4f); this.walkDirection.set(0, 0, 0); if (this.left) { this.walkDirection.addLocal(camLeft); } if (this.right) { this.walkDirection.addLocal(camLeft.negate()); } if (this.up) { this.walkDirection.addLocal(camDir); } if (this.down) { this.walkDirection.addLocal(camDir.negate()); } if (usePhysics) { this.player3.setWalkDirection(this.walkDirection); this.cam.setLocation(this.player3.getPhysicsLocation()); } } }
private void scaleAsParent(float percent, Vector3f playerPos, Vector3f dist) { float scale = mapValue(percent, 1.0f, poiRadius); Vector3f distToHorizon = dist.subtract(dist.normalize()); Vector3f offLocation = playerPos.add(distToHorizon); Vector3f rootOff = offLocation.mult(scale).negate(); rootOff.addLocal(dist); debugTools.setGreenArrow(Vector3f.ZERO, offLocation); getRootNode().setLocalScale(scale); getRootNode().setLocalTranslation(rootOff); }
/** * This is the main event loop--walking happens here. * We check in which direction the player is walking by interpreting * the camera direction forward (camDir) and to the side (camLeft). * The setWalkDirection() command is what lets a physics-controlled player walk. * We also make sure here that the camera moves with player. */ @Override public void simpleUpdate(float tpf) { camDir.set(cam.getDirection()).multLocal(0.6f); camLeft.set(cam.getLeft()).multLocal(0.4f); walkDirection.set(0, 0, 0); if (left) { walkDirection.addLocal(camLeft); } if (right) { walkDirection.addLocal(camLeft.negate()); } if (up) { walkDirection.addLocal(camDir); } if (down) { walkDirection.addLocal(camDir.negate()); } player.setWalkDirection(walkDirection); cam.setLocation(player.getPhysicsLocation()); } }
public void simpleInitApp() { cam.setLocation(new Vector3f(0f, 0.5f, 3f)); viewPort.setBackgroundColor(ColorRGBA.LightGray); // Add a light source to the scene. DirectionalLight directionalLight = new DirectionalLight(); directionalLight.setColor(ColorRGBA.Magenta); directionalLight.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(directionalLight); // Create and add a teapot to the scene graph. Spatial teapotModel = assetManager.loadModel("Models/Teapot/Teapot.obj"); rootNode.attachChild(teapotModel); // Create the two moving quads with custom blend modes. createLeftQuad(); createRightQuad(); }
public void simpleInitApp() { Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl); rootNode.attachChild(teaGeom); // Setup first view cam.setParallelProjection(true); float aspect = (float) cam.getWidth() / cam.getHeight(); cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize); inputManager.addListener(this, "Size+", "Size-"); inputManager.addMapping("Size+", new KeyTrigger(KeyInput.KEY_W)); inputManager.addMapping("Size-", new KeyTrigger(KeyInput.KEY_S)); }
dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl);
dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl);
@Override public void simpleInitApp() { cam.setLocation(new Vector3f(10f, 3f, 40f)); cam.lookAtDirection(Vector3f.UNIT_Z.negate(), Vector3f.UNIT_Y); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); rootNode.addLight(dl); AnimComposer composer; Spatial originalModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); composer = originalModel.getControl(AnimComposer.class); composer.setCurrentAction("Walk"); rootNode.attachChild(originalModel); Spatial clonedModel = originalModel.clone(); clonedModel.move(10, 0, 0); composer = clonedModel.getControl(AnimComposer.class); composer.setCurrentAction("push"); rootNode.attachChild(clonedModel); Spatial exportedModel = BinaryExporter.saveAndLoad(assetManager, originalModel); exportedModel.move(20, 0, 0); composer = exportedModel.getControl(AnimComposer.class); composer.setCurrentAction("pull"); rootNode.attachChild(exportedModel); } }
dl.setDirection(Vector3f.UNIT_XYZ.negate()); rootNode.addLight(dl);
dl.setDirection(Vector3f.UNIT_XYZ.negate());