private void createballs() { System.out.println((frames / time) + ";" + val); for (int i = val; i < val+1 ; i++) { Geometry s = sphere.clone().clone(false); s.setMaterial(mat); s.setLocalTranslation(i - 30, 5, (((i) * 2) % 40) - 50); s.setShadowMode(ShadowMode.CastAndReceive); rootNode.attachChild(s); } if (val == 300) { stop(); } val += 1; time = 0; frames = 0; } float time;
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); SphereCollisionShape bulletCollisionShape = new SphereCollisionShape(0.4f); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletg.addControl(bulletNode); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } if (name.equals("gc") && !keyPressed) { System.gc(); } } };
public void addBrick(Vector3f ori) { Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(mat); reBoxg.setLocalTranslation(ori); reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f ); reBoxg.addControl(new RigidBodyControl(1.5f)); reBoxg.setShadowMode(ShadowMode.CastAndReceive); reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f); this.rootNode.attachChild(reBoxg); this.getPhysicsSpace().add(reBoxg); }
public void setupFloor() { Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"); Box floor = new Box(50, 1f, 50); TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); }
public void addBrick(Vector3f ori) { Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(mat); reBoxg.setLocalTranslation(ori); reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f ); reBoxg.addControl(new RigidBodyControl(1.5f)); reBoxg.setShadowMode(ShadowMode.CastAndReceive); reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f); this.batchNode.attachChild(reBoxg); this.getPhysicsSpace().add(reBoxg); nbBrick++; }
private void addBrick(Vector3f ori) { Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(matBullet); reBoxg.setLocalTranslation(ori); reBoxg.addControl(new RigidBodyControl(1.5f)); reBoxg.setShadowMode(ShadowMode.CastAndReceive); this.rootNode.attachChild(reBoxg); this.getPhysicsSpace().add(reBoxg); }
public void setupFloor(){ Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"); Box floor = new Box(50, 1f, 50); TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); }
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletg.addControl(bulletNode); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } } };
public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(cam.getLocation()); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletg.addControl(bulletNode); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletNode); } } };
public void addBrick(Vector3f ori) { Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(mat); reBoxg.setLocalTranslation(ori); //for geometry with sphere mesh the physics system automatically uses a sphere collision shape reBoxg.addControl(new RigidBodyControl(1.5f)); reBoxg.setShadowMode(ShadowMode.CastAndReceive); reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f); this.rootNode.attachChild(reBoxg); this.getPhysicsSpace().add(reBoxg); }
public void initFloor() { Box floorBox = new Box(10f, 0.1f, 5f); floorBox.scaleTextureCoordinates(new Vector2f(3, 6)); Geometry floor = new Geometry("floor", floorBox); floor.setMaterial(mat3); floor.setShadowMode(ShadowMode.Receive); floor.setLocalTranslation(0, 0, 0); floor.addControl(new RigidBodyControl(0)); this.rootNode.attachChild(floor); this.getPhysicsSpace().add(floor); }
public void initFloor() { Box floorBox = new Box(10f, 0.1f, 5f); floorBox.scaleTextureCoordinates(new Vector2f(3, 6)); Geometry floor = new Geometry("floor", floorBox); floor.setMaterial(mat3); floor.setShadowMode(ShadowMode.Receive); floor.setLocalTranslation(0, 0, 0); floor.addControl(new RigidBodyControl(0)); this.rootNode.attachChild(floor); this.getPhysicsSpace().add(floor); }
protected Geometry makeFloor() { Box box = new Box(220, .2f, 220); box.scaleTextureCoordinates(new Vector2f(10, 10)); Geometry floor = new Geometry("the Floor", box); floor.setLocalTranslation(200, -9, 200); Material matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg"); grass.setWrap(WrapMode.Repeat); matGroundL.setTexture("DiffuseMap", grass); floor.setMaterial(matGroundL); floor.setShadowMode(ShadowMode.CastAndReceive); return floor; } }
public void setupFloor() { Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); Geometry geom = new Geometry("floor", q); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.White); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.move(0, -0.3f, 0); geom.setShadowMode(RenderQueue.ShadowMode.Receive); rootNode.attachChild(geom); }
public void initFloor() { Box floorBox = new Box(10f, 0.1f, 5f); floorBox.scaleTextureCoordinates(new Vector2f(3, 6)); Geometry floor = new Geometry("floor", floorBox); floor.setMaterial(mat3); floor.setShadowMode(ShadowMode.Receive); floor.setLocalTranslation(0, -0.1f, 0); floor.addControl(new RigidBodyControl(new BoxCollisionShape(new Vector3f(10f, 0.1f, 5f)), 0)); this.rootNode.attachChild(floor); this.getPhysicsSpace().add(floor); }
public void setupFloor() { Quad q = new Quad(20, 20); q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10)); Geometry geom = new Geometry("floor", q); Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); mat.setColor("Diffuse", ColorRGBA.White); mat.setColor("Specular", ColorRGBA.White); mat.setColor("Ambient", ColorRGBA.Black); mat.setBoolean("UseMaterialColors", true); mat.setFloat("Shininess", 0); geom.setMaterial(mat); geom.rotate(-FastMath.HALF_PI, 0, 0); geom.center(); geom.setShadowMode(RenderQueue.ShadowMode.Receive); rootNode.attachChild(geom); }
public void setupFloor(){ Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat); mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat); // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat); mat.setFloat("Shininess",3); // mat.setBoolean("VertexLighting", true); Box floor = new Box(50, 1f, 50); TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); }
private void bulletControl() { shootingChannel.setAnim("Dodge", 0.1f); shootingChannel.setLoopMode(LoopMode.DontLoop); Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(matBullet); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(character.getPhysicsLocation().add(cam.getDirection().mult(5))); RigidBodyControl bulletControl = new BombControl(bulletCollisionShape, 1); bulletControl.setCcdMotionThreshold(0.1f); bulletControl.setLinearVelocity(cam.getDirection().mult(80)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); getPhysicsSpace().add(bulletControl); }
public void onAction(String name, boolean keyPressed, float tpf) { Sphere bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); Material mat2 = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); key2.setGenerateMips(true); Texture tex2 = app.getAssetManager().loadTexture(key2); mat2.setTexture("ColorMap", tex2); if (name.equals("shoot") && !keyPressed) { Geometry bulletg = new Geometry("bullet", bullet); bulletg.setMaterial(mat2); bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setLocalTranslation(app.getCamera().getLocation()); RigidBodyControl bulletControl = new RigidBodyControl(10); bulletg.addControl(bulletControl); bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25)); bulletg.addControl(bulletControl); rootNode.attachChild(bulletg); space.add(bulletControl); } } };
public void setupFloor() { Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m"); mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat); mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat); mat.setBoolean("UseMaterialColors", true); mat.setColor("Diffuse", ColorRGBA.White.clone()); mat.setColor("Ambient", ColorRGBA.White.clone()); // mat.setColor("Specular", ColorRGBA.White.clone()); // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat); mat.setFloat("Shininess", 0); // mat.setBoolean("VertexLighting", true); Box floor = new Box(50, 1f, 50); TangentBinormalGenerator.generate(floor); floor.scaleTextureCoordinates(new Vector2f(5, 5)); Geometry floorGeom = new Geometry("Floor", floor); floorGeom.setMaterial(mat); floorGeom.setShadowMode(ShadowMode.Receive); rootNode.attachChild(floorGeom); }