protected void resetView() { resetZoom(); scrollRoot.setLocalTranslation(0, 0, 0); }
/** * Used to reset cubeField */ private void gameReset(){ Score = 0; lowCap = 10; colorInt = 0; highCap = 40; difficulty = highCap; for (Geometry cube : cubeField){ cube.removeFromParent(); } cubeField.clear(); if (fcube != null){ fcube.removeFromParent(); } fcube = createFirstCube(); obstacleColors.clear(); obstacleColors.add(ColorRGBA.Orange); obstacleColors.add(ColorRGBA.Red); obstacleColors.add(ColorRGBA.Yellow); renderer.setBackgroundColor(ColorRGBA.White); speed = lowCap / 400f; coreTime = 20.0f; coreTime2 = 10.0f; diffHelp=lowCap; player.setLocalTranslation(0,0,0); }
/** * Sets the transforms of this bone in model space (relative to the root bone) * * Must update all bones in skeleton for this to work. * @param translation translation in model space * @param rotation rotation in model space */ public void setUserTransformsInModelSpace(Vector3f translation, Quaternion rotation) { if (!userControl) { throw new IllegalStateException("You must call setUserControl(true) in order to setUserTransformsInModelSpace to work"); } // TODO: add scale here ??? modelPos.set(translation); modelRot.set(rotation); //if there is an attached Node we need to set its local transforms too. if(attachNode != null){ attachNode.setLocalTranslation(translation); attachNode.setLocalRotation(rotation); } }
@Override public void simpleUpdate(float tpf){ // cam.setLocation(new Vector3f(5.0347548f, 6.6481347f, 3.74853f)); // cam.setRotation(new Quaternion(-0.19183293f, 0.80776674f, -0.37974006f, -0.40805697f)); angle += tpf; angle %= FastMath.TWO_PI; movingNode.setLocalTranslation(new Vector3f(FastMath.cos(angle) * 3f, 2, FastMath.sin(angle) * 3f)); }
@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 Node createLimb(float width, float height, Vector3f location, boolean rotate) { int axis = rotate ? PhysicsSpace.AXIS_X : PhysicsSpace.AXIS_Y; CapsuleCollisionShape shape = new CapsuleCollisionShape(width, height, axis); Node node = new Node("Limb"); RigidBodyControl rigidBodyControl = new RigidBodyControl(shape, 1); node.setLocalTranslation(location); node.addControl(rigidBodyControl); return node; }
/** * For debuging porpose only * Will return a Node meant to be added to a GUI presenting the 2 cube maps in a cross pattern with all the mip maps. * * @param manager the asset manager * @return a debug node */ public static Node getDebugGui(AssetManager manager, LightProbe probe) { if (!probe.isReady()) { throw new UnsupportedOperationException("This EnvProbe is not ready yet, try to test isReady()"); } Node debugNode = new Node("debug gui probe"); Node debugPfemCm = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(probe.getPrefilteredEnvMap(), manager); debugNode.attachChild(debugPfemCm); debugPfemCm.setLocalTranslation(520, 0, 0); return debugNode; }
public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("stop") && isPressed) { ikControl.setEnabled(!ikControl.isEnabled()); ikControl.setIKMode(); } if (name.equals("one") && isPressed) { //ragdoll.setKinematicMode(); targetPoint = model.getWorldTranslation().add(new Vector3f(0,2,4)); targetNode.setLocalTranslation(targetPoint); ikControl.setIKTarget(ikControl.getBone("Hand.L"), targetPoint, 2); ikControl.setIKMode(); } if (name.equals("two") && isPressed) { //ragdoll.setKinematicMode(); targetPoint = model.getWorldTranslation().add(new Vector3f(-3,3,0)); targetNode.setLocalTranslation(targetPoint); ikControl.setIKTarget(ikControl.getBone("Hand.R"), targetPoint, 3); ikControl.setIKMode(); } } }, "one", "two");
@Override public void simpleUpdate(float tpf) { timeElapsed += tpf; lightNode.setLocalTranslation(FastMath.cos(timeElapsed), lightNode.getLocalTranslation().y, FastMath.sin(timeElapsed)); spotLight.setDirection(new Vector3f(FastMath.cos(-timeElapsed*.7f), -1.0f, FastMath.sin(-timeElapsed*.7f))); } }
public void setupRobotGuy(){ Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m"); model.getChild(0).setMaterial(mat); // model.setAnimation("Walk"); model.setLocalTranslation(30, 10.5f, 30); model.setLocalScale(2); model.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(model); }
public WorldOfInception() { //base level vector position hash == seed super(new InceptionLevel(null, Vector3f.ZERO)); currentLevel = super.getStateManager().getState(InceptionLevel.class); currentLevel.takeOverParent(); currentLevel.getRootNode().setLocalScale(Vector3f.UNIT_XYZ); currentLevel.getRootNode().setLocalTranslation(Vector3f.ZERO); }
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); }
private void scaleAsChild(float percent, Vector3f dist) { float childScale = mapValue(percent, 1.0f / poiRadius, 1); Vector3f distToHorizon = dist.normalize(); Vector3f scaledDistToHorizon = distToHorizon.mult(childScale * poiRadius); Vector3f rootOff = dist.add(scaledDistToHorizon); debugTools.setBlueArrow(Vector3f.ZERO, rootOff); getRootNode().setLocalScale(childScale); getRootNode().setLocalTranslation(rootOff); //prepare player position already Vector3f playerPosition = dist.normalize().mult(-poiRadius); setPlayerPosition(playerPosition); }
private void createMarkerPoints(float count) { Node center = createAxisMarker(10); markers.attachChild(center); float xS = (count-1)*terrain.getTerrainSize() - (terrain.getTerrainSize()/2); float zS = (count-1)*terrain.getTerrainSize() - (terrain.getTerrainSize()/2); float xSi = xS; float zSi = zS; for (int x=0; x<count*2; x++) { for (int z=0; z<count*2; z++) { Node m = createAxisMarker(5); m.setLocalTranslation(xSi, 0, zSi); markers.attachChild(m); zSi += terrain.getTerrainSize(); } zSi = zS; xSi += terrain.getTerrainSize(); } }
m.setTexture("CubeMap", probe.getPrefilteredEnvMap()); n.setLocalTranslation(probe.getPosition()); n.getChild(1).setLocalScale(probe.getArea().getRadius()); break;
public void setupFloor() { mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"); Node floorGeom = new Node("floorGeom"); Quad q = new Quad(100, 100); q.scaleTextureCoordinates(new Vector2f(10, 10)); Geometry g = new Geometry("geom", q); g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X)); floorGeom.attachChild(g); TangentBinormalGenerator.generate(floorGeom); floorGeom.setLocalTranslation(-50, 22, 60); //floorGeom.setLocalScale(100); floorGeom.setMaterial(mat); rootNode.attachChild(floorGeom); }
public void setupFloor() { mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR.j3m"); //mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR2.j3m"); Node floorGeom = new Node("floorGeom"); Quad q = new Quad(100, 100); q.scaleTextureCoordinates(new Vector2f(10, 10)); Geometry g = new Geometry("geom", q); g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X)); floorGeom.attachChild(g); TangentBinormalGenerator.generate(floorGeom); floorGeom.setLocalTranslation(-50, 22, 60); //floorGeom.setLocalScale(100); floorGeom.setMaterial(mat); rootNode.attachChild(floorGeom); }
model.setLocalTranslation(4, 0, -7f);
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.1f); setupKeys(); mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", ColorRGBA.Green); mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat2.getAdditionalRenderState().setWireframe(true); mat2.setColor("Color", ColorRGBA.Red); // An obstacle mesh, does not move (mass=0) Node node2 = new Node(); node2.setName("mesh"); node2.setLocalTranslation(new Vector3f(2.5f, 0, 0f)); node2.addControl(new RigidBodyControl(new MeshCollisionShape(new Box(4, 4, 0.1f)), 0)); rootNode.attachChild(node2); getPhysicsSpace().add(node2); // The floor, does not move (mass=0) Node node3 = new Node(); node3.setLocalTranslation(new Vector3f(0f, -6, 0f)); node3.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(100, 1, 100)), 0)); rootNode.attachChild(node3); getPhysicsSpace().add(node3); }
n2.setLocalTranslation(Vector3f.UNIT_X.mult(5)); n2.attachChild(n);