private void randomizeTransform(Spatial spat){ spat.setLocalTranslation((float) Math.random() * 10, (float) Math.random() * 10, (float) Math.random() * 10); spat.setLocalTranslation((float) Math.random() * 10, (float) Math.random() * 10, (float) Math.random() * 10); spat.setLocalScale((float) Math.random() * 2, (float) Math.random() * 2, (float) Math.random() * 2); }
@Override protected void controlUpdate(float tpf) { time += tpf; spatial.setLocalTranslation(origPos.x + FastMath.cos(time) * direction, origPos.y, origPos.z + FastMath.sin(time) * direction); }
/** * Centers the spatial in the origin of the world bound. * @return The spatial on which this method is called, e.g <code>this</code>. */ public Spatial center() { Vector3f worldTrans = getWorldTranslation(); Vector3f worldCenter = getWorldBound().getCenter(); Vector3f absTrans = worldTrans.subtract(worldCenter); setLocalTranslation(absTrans); return this; }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 6f, 3f, FastMath.sin(angle) * 6f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf) { angle1 += tpf * 0.25f; angle1 %= FastMath.TWO_PI; angle2 += tpf * 0.50f; angle2 %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle1) * 4f, 0.5f, FastMath.sin(angle1) * 4f)); p2.setPosition(new Vector3f(FastMath.cos(angle2) * 4f, 0.5f, FastMath.sin(angle2) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); lightMd2.setLocalTranslation(p2.getPosition()); } }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 4f, 0.5f, FastMath.sin(angle) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); }
@Override public void simpleUpdate(float tpf){ angle += tpf * 0.25f; angle %= FastMath.TWO_PI; pl.setPosition(new Vector3f(FastMath.cos(angle) * 4f, 0.5f, FastMath.sin(angle) * 4f)); lightMdl.setLocalTranslation(pl.getPosition()); }
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f)); golem.addLight(sun); return golem; } }
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
protected Spatial makeCharacter() { // load a character from jme3test-test-data Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); golem.scale(0.5f); golem.setLocalTranslation(-1.0f, -1.5f, -0.6f); // We must add a light to make the model visible DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal()); golem.addLight(sun); return golem; } }
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
private void updateMarkerElevations() { for (Spatial s : markers.getChildren()) { float h = terrain.getHeight(new Vector2f(s.getLocalTranslation().x, s.getLocalTranslation().z)); s.setLocalTranslation(s.getLocalTranslation().x, h+1, s.getLocalTranslation().z); } }
public void setupSignpost(){ Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); // mat.setBoolean("VertexLighting", true); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); }
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); TangentBinormalGenerator.generate(signpost); signpost.setMaterial(matSp); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 23.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); TangentBinormalGenerator.generate(signpost); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 23.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(signpost); }
public void setupSignpost() { Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml"); Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"); // mat.setBoolean("VertexLighting", true); signpost.setMaterial(mat); signpost.rotate(0, FastMath.HALF_PI, 0); signpost.setLocalTranslation(12, 3.5f, 30); signpost.setLocalScale(4); signpost.setShadowMode(ShadowMode.CastAndReceive); TangentBinormalGenerator.generate(signpost); rootNode.attachChild(signpost); }
private void lightToSpatial(Light light) { TempVars vars = TempVars.get(); if (light instanceof PointLight) { PointLight pLight = (PointLight) light; Vector3f vecDiff = vars.vect1.set(pLight.getPosition()).subtractLocal(spatial.getWorldTranslation()); spatial.setLocalTranslation(vecDiff.addLocal(spatial.getLocalTranslation())); } if (light instanceof DirectionalLight) { DirectionalLight dLight = (DirectionalLight) light; vars.vect1.set(dLight.getDirection()).multLocal(-1.0f); Vector3f vecDiff = vars.vect1.subtractLocal(spatial.getWorldTranslation()); spatial.setLocalTranslation(vecDiff.addLocal(spatial.getLocalTranslation())); } vars.release(); //TODO add code for Spot light here when it's done }
private void buildPlayer() { spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml"); CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft); spaceCraft.setShadowMode(ShadowMode.CastAndReceive); spaceCraft.setLocalTranslation(new Vector3f(-140, 50, -23)); spaceCraft.setLocalRotation(new Quaternion(new float[]{0, 0.01f, 0})); hoverControl = new PhysicsHoverControl(colShape, 500); spaceCraft.addControl(hoverControl); rootNode.attachChild(spaceCraft); getPhysicsSpace().add(hoverControl); hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02); ChaseCamera chaseCam = new ChaseCamera(cam, inputManager); spaceCraft.addControl(chaseCam); flyCam.setEnabled(false); }