public void onAnalog(String binding, float value, float tpf) { if (binding.equals("START") && !START){ START = true; guiNode.detachChild(pressStart); System.out.println("START"); }else if (START == true && binding.equals("Left")){ player.move(0, 0, -(speed / 2f) * value * fpsRate); camAngle -= value*tpf; }else if (START == true && binding.equals("Right")){ player.move(0, 0, (speed / 2f) * value * fpsRate); camAngle += value*tpf; } }
@Override public void simpleUpdate(float tpf) { super.simpleUpdate(tpf); n.rotate(0, tpf, 0); n.move(0.1f*tpf, 0, 0); n2.rotate(0, 0, -tpf); }
public void onAnalog(String name, float value, float tpf) { //computing the normalized direction of the cam to move the teaNode direction.set(cam.getDirection()).normalizeLocal(); if (name.equals("moveForward")) { direction.multLocal(5 * tpf); teaNode.move(direction); } if (name.equals("moveBackward")) { direction.multLocal(-5 * tpf); teaNode.move(direction); } if (name.equals("moveRight")) { direction.crossLocal(Vector3f.UNIT_Y).multLocal(5 * tpf); teaNode.move(direction); } if (name.equals("moveLeft")) { direction.crossLocal(Vector3f.UNIT_Y).multLocal(-5 * tpf); teaNode.move(direction); } if (name.equals("rotateRight") && rotate) { teaNode.rotate(0, 5 * tpf, 0); } if (name.equals("rotateLeft") && rotate) { teaNode.rotate(0, -5 * tpf, 0); } }
player.move(speed * tpf * fpsRate, 0, 0); if (cubeField.size() > difficulty){ cubeField.remove(0);
public void simpleUpdate( float tpf ) { if( scroll.lengthSquared() != 0 ) { scrollRoot.move(scroll.mult(tpf)); } if( zoom.lengthSquared() != 0 ) { Vector3f current = testRoot.getLocalScale(); testRoot.setLocalScale(current.add(zoom.mult(tpf))); } }
@Override public void simpleUpdate(float tpf) { if(forward){ model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(tpf)); }else if(backward){ model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(-tpf)); }else if(leftRotate){ model.rotate(0, tpf, 0); }else if(rightRotate){ model.rotate(0, -tpf, 0); } fpsText.setText(cam.getLocation() + "/" + cam.getRotation()); }
@Override public void simpleUpdate(float tpf) { float move = tpf * 1; boolean colliding = false; List<PhysicsSweepTestResult> sweepTest = bulletAppState.getPhysicsSpace().sweepTest(capsuleCollisionShape, new Transform(capsule.getWorldTranslation()), new Transform(capsule.getWorldTranslation().add(dist, 0, 0))); for (PhysicsSweepTestResult result : sweepTest) { if (result.getCollisionObject().getCollisionShape() != capsuleCollisionShape) { PhysicsCollisionObject collisionObject = result.getCollisionObject(); fpsText.setText("Almost colliding with " + collisionObject.getUserObject().toString()); colliding = true; } } if (!colliding) { // if the sweep is clear then move the spatial capsule.move(move, 0, 0); } } }
@Override public void simpleInitApp() { obstacleCollisionShape = new CapsuleCollisionShape(0.3f, 0.5f); capsuleCollisionShape = new CapsuleCollisionShape(1f, 1f); stateManager.attach(bulletAppState); capsule = new Node("capsule"); capsule.move(-2, 0, 0); capsule.addControl(new RigidBodyControl(capsuleCollisionShape, 1)); capsule.getControl(RigidBodyControl.class).setKinematic(true); bulletAppState.getPhysicsSpace().add(capsule); rootNode.attachChild(capsule); obstacle = new Node("obstacle"); obstacle.move(2, 0, 0); RigidBodyControl bodyControl = new RigidBodyControl(obstacleCollisionShape, 0); obstacle.addControl(bodyControl); bulletAppState.getPhysicsSpace().add(obstacle); rootNode.attachChild(obstacle); bulletAppState.setDebugEnabled(true); }
Node monkey = new Node("n_" + x + "_" + y); monkey.attachChild(g); monkey.move(x * 2, 0, y * 2);
target.move(0, 0, 0); ChaseCameraAppState chaseCam = new ChaseCameraAppState(); chaseCam.setTarget(target);
target.move(0, 1, 0); ChaseCameraAppState chaseCam = new ChaseCameraAppState(); chaseCam.setTarget(target);
target.move(0, 1, 0); ChaseCameraAppState chaseCam = new ChaseCameraAppState(); chaseCam.setTarget(target);
stateManager.attach(cinematic); jaime.move(0, 0, -3); AnimationFactory af = new AnimationFactory(0.7f, "JumpForward"); af.addTimeTranslation(0, new Vector3f(0, 0, -3));
public void onAnalog(String binding, float value, float tpf) { if (binding.equals("START") && !START){ START = true; guiNode.detachChild(pressStart); System.out.println("START"); }else if (START == true && binding.equals("Left")){ player.move(0, 0, -(speed / 2f) * value * fpsRate); camAngle -= value*tpf; }else if (START == true && binding.equals("Right")){ player.move(0, 0, (speed / 2f) * value * fpsRate); camAngle += value*tpf; } }
private void translate(Vector3f offset) { Node translation = new Node(); translation.move(offset); currentNode.attachChild(translation); currentNode = translation; }
private void translate(Vector3f offset) { Node translation = new Node(); translation.move(offset); currentNode.attachChild(translation); currentNode = translation; }
void moveForward() { Vector3f dir = screenLoc.subtract(smartphone.getLocalTranslation()); dir.normalizeLocal(); dir.multLocal(step); smartphone.move(dir); bitmapText.setText(String.valueOf(distanceToScreen()+"m")); }
void moveBackward() { Vector3f dir = screenLoc.subtract(smartphone.getLocalTranslation()); dir.normalizeLocal(); dir.multLocal(step); dir.negateLocal(); smartphone.move(dir); bitmapText.setText(String.valueOf(distanceToScreen())+"m"); }
void createBodyPresenceSensor(String id, Vector3f pos, Vector3f dir) { Node devicePS1 = new Node(); devicePS1.setUserData("ROLE", "PresenceSensor"); devicePS1.setUserData("ID", id); devicePS1.move(pos); devicePS1.rotate(new Quaternion().fromAngles(dir.x, dir.y, dir.z)); app.getRootNode().attachChild(devicePS1); }
private void refreshResource() { ArtResource temp = getResource(); if (temp != currentResource) { currentResource = temp; Node nodeObject = (Node) AssetUtils.loadModel(worldState.getAssetManager(), currentResource.getName()); nodeObject.move(0, MapLoader.FLOOR_HEIGHT, 0); ((Node) getSpatial()).detachAllChildren(); for (Spatial spat : nodeObject.getChildren()) { ((Node) getSpatial()).attachChild(spat); } } }