private Geometry createInstance(float x, float z) { Mesh mesh; if (FastMath.nextRandomInt(0, 1) == 1) mesh = mesh2; else mesh = mesh1; Geometry geometry = new Geometry("randomGeom", mesh); geometry.setMaterial(materials[FastMath.nextRandomInt(0, materials.length - 1)]); geometry.setLocalTranslation(x, 0, z); return geometry; }
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); // create cube shape Geometry geom = new Geometry("Box", b); // create cube geometry from the shape Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material mat.setColor("Color", ColorRGBA.Blue); // set color of material to blue geom.setMaterial(mat); // set the cube's material rootNode.attachChild(geom); // make the cube appear in the scene } }
public Geometry createHDRBox(){ Box boxMesh = new Box(1, 1, 1); Geometry box = new Geometry("Box", boxMesh); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Textures/HdrTest/Memorial.hdr")); box.setMaterial(mat); return box; }
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); System.out.println("Attaching test state."); stateManager.attach(new TestState()); }
/** A cube object for target practice */ protected Geometry makeCube(String name, float x, float y, float z) { Box box = new Box(1, 1, 1); Geometry cube = new Geometry(name, box); cube.setLocalTranslation(x, y, z); Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat1.setColor("Color", ColorRGBA.randomColor()); cube.setMaterial(mat1); return cube; }
private void createCollisionMarker() { Sphere s = new Sphere(6, 6, 1); collisionMarker = new Geometry("collisionMarker"); collisionMarker.setMesh(s); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Orange); collisionMarker.setMaterial(mat); rootNode.attachChild(collisionMarker); } private ActionListener actionListener = new ActionListener() {
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); }
private Geometry createFirstCube() { Vector3f loc = player.getLocalTranslation(); loc.addLocal(4, 0, 0); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); geom.setLocalTranslation(loc); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); return geom; }
private Geometry CreateLinearPath() { Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", ColorRGBA.Blue); Geometry lineGeometry = new Geometry("line", new Curve(spline, 0)); lineGeometry.setMaterial(mat); return lineGeometry; }
/** Make a solid floor and add it to the scene. */ public void initFloor() { Geometry floor_geo = new Geometry("Floor", floor); floor_geo.setMaterial(floor_mat); floor_geo.setLocalTranslation(0, -0.1f, 0); this.rootNode.attachChild(floor_geo); /* Make the floor physical with mass 0.0f! */ floor_phy = new RigidBodyControl(0.0f); floor_geo.addControl(floor_phy); bulletAppState.getPhysicsSpace().add(floor_phy); }
/** A red ball that marks the last spot that was "hit" by the "shot". */ protected void initMark() { Arrow arrow = new Arrow(Vector3f.UNIT_Z.mult(2f)); //Sphere sphere = new Sphere(30, 30, 0.2f); mark = new Geometry("BOOM!", arrow); //mark = new Geometry("BOOM!", sphere); Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mark_mat.getAdditionalRenderState().setLineWidth(3); mark_mat.setColor("Color", ColorRGBA.Red); mark.setMaterial(mark_mat); }
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++; }
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); }
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); }
@Override public void simpleInitApp() { Quad quadMesh = new Quad(512,512); Geometry quad = new Geometry("Quad", quadMesh); quad.setQueueBucket(Bucket.Gui); mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png")); quad.setMaterial(mat); guiNode.attachChildAt(quad, 0); nextColor = ColorRGBA.randomColor(); prevColor = ColorRGBA.Black; }
public Geometry putShape(Mesh shape, ColorRGBA color, float lineWidth){ Geometry g = new Geometry("shape", shape); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.getAdditionalRenderState().setLineWidth(lineWidth); mat.setColor("Color", color); g.setMaterial(mat); rootNode.attachChild(g); return g; }
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); }
@Override protected void initialize(Application app) { debugNode = new Node("Environment debug Node"); Sphere s = new Sphere(16, 16, 0.15f); debugGeom = new Geometry("debugEnvProbe", s); debugMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/reflect.j3md"); debugGeom.setMaterial(debugMaterial); debugBounds = BoundingSphereDebug.createDebugSphere(app.getAssetManager()); if (scene == null) { scene = app.getViewPort().getScenes().get(0); } }
private void setupPlanet() { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); //immovable sphere with mesh collision shape Sphere sphere = new Sphere(64, 64, 20); planet = new Geometry("Sphere", sphere); planet.setMaterial(material); planet.setLocalTranslation(30, -15, 30); planet.addControl(new RigidBodyControl(new MeshCollisionShape(sphere), 0)); rootNode.attachChild(planet); getPhysicsSpace().add(planet); }