@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().enableDebug(assetManager); 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(Vector3f.ZERO, 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); }
Node createDebugGeometry() { Line l = new Line(from.getPlanet().getPosition(), to.getPlanet().getPosition()); line = new Geometry("Line #" + from.getPlanet().getID() + " to #" + to.getPlanet().getID(), l); Material material = new Material( SolarWarsApplication.getInstance().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); Player p = from.getPlanet().getOwner(); ColorRGBA c; if (p == null) { c = ColorRGBA.White.clone(); c.a = 0.5f; material.setColor("Color", c); } else { c = p.getColor(); c.a = 0.5f; material.setColor("Color", c); } material.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha); line.setMaterial(material); createLabel(); Node lineNode = new Node(line.getName() + "_Node"); lineNode.attachChild(line); lineNode.attachChild(label); // Vector3f pos = to.getPlanet().getPosition(). // subtract(from.getPlanet().getPosition()); // lineNode.setLocalTranslation(pos.mult(0.5f)); return lineNode; }
@Override public void simpleInitApp() { /** create a blue box at coordinates (1,-1,1) */ Box box1 = new Box(new Vector3f(1, -1, 1), 1, 1, 1); Geometry blue = new Geometry("Box", box1); Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md"); mat1.setColor("Color", ColorRGBA.Blue); blue.setMaterial(mat1); /** create a red box straight above the blue one at (1,3,1) */ Box box2 = new Box(new Vector3f(1, 3, 1), 1, 1, 1); Geometry red = new Geometry("Box", box2); Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md"); mat2.setColor("Color", ColorRGBA.Red); red.setMaterial(mat2); /** Create a pivot node at (0,0,0) and attach it to the root node */ Node pivot = new Node("pivot"); rootNode.attachChild(pivot); // put this node in the scene /** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */ pivot.attachChild(blue); pivot.attachChild(red); /** Rotate the pivot node: Note that both boxes have rotated! */ pivot.rotate(.4f, .4f, 0f); }
private void createMaterial() { mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat1.setColor("Color", ColorRGBA.Green); mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat2.setColor("Color", ColorRGBA.Red); mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat3.setColor("Color", ColorRGBA.Yellow); }
private Material getMaterial(ColorRGBA color) { Material mat = new Material(main.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); mat.setColor("Diffuse", color); ColorRGBA clone = color.clone(); clone.multLocal(0.8f); clone.a = 1f; mat.setColor("Ambient", clone); mat.setBoolean("UseMaterialColors", true); return mat; }
/** * Generates a new, basic material for use in the jME3 app. * * @param color The color of the material. * @return A jME3 Material using Lighting.j3md. */ public Material createLitMaterial(ColorRGBA color) { Material material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); material.setBoolean("UseMaterialColors", true); material.setColor("Diffuse", color); material.setFloat("Shininess", 12f); material.setColor("Specular", ColorRGBA.White); material.setColor("Ambient", ColorRGBA.LightGray); material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); return material; }
public static void LoadObjectHelper() { highlightMat = new Material(Main.s_AssetManager, "Common/MatDefs/Misc/Unshaded.j3md"); Texture texture = Main.s_AssetManager.loadTexture("Models/tree.png"); highlightMat.setTexture("ColorMap", texture); greenTrans = new Material(Main.s_AssetManager, "Common/MatDefs/Misc/Unshaded.j3md"); greenTrans.setColor("Color", new ColorRGBA(0, 1, 0, 0.3f)); greenTrans.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); redTrans = new Material(Main.s_AssetManager, "Common/MatDefs/Misc/Unshaded.j3md"); redTrans.setColor("Color", new ColorRGBA(1, 0, 0, 0.3f)); redTrans.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); }
private void displayPlayersPositions() { Map<Vector3f, Integer> playerPositions = gm.getMapManager().getBoard().getPlayerPositions(); Iterator it = playerPositions.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); Vector3f pos = (Vector3f) pairs.getKey(); Integer number = (Integer) pairs.getValue(); Box b = new Box(Vector3f.ZERO, 2.0f, 1.0f, 2.0f); Geometry geom = new Geometry("Box", b); Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.randomColor()); geom.setMaterial(mat); geom.setLocalTranslation(pos.x, 0, pos.z); String geomName = "PLAYERMARKER"; geom.setName(geomName); geom.setUserData(geomName, pos); playerNodes.attachChild(geom); displayLocationName(number.toString(), new Vector3f(pos.x, 1, pos.z)); } }
public void renderImage( RenderImage image, int x, int y, int width, int height, Color color, float imageScale) { RenderImageJme jmeImage = (RenderImageJme) image; textureColorMaterial.setColor("Color", convertColor(color, tempColor)); textureColorMaterial.setTexture("ColorMap", jmeImage.getTexture()); quad.clearBuffer(Type.TexCoord); quad.setBuffer(quadDefaultTC); float x0 = x + 0.5f * width * (1f - imageScale); float y0 = y + 0.5f * height * (1f - imageScale); tempMat.loadIdentity(); tempMat.setTranslation(x0, getHeight() - y0, 0); tempMat.setScale(width * imageScale, height * imageScale, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); textureColorMaterial.render(quadGeom, rm); // System.out.format("renderImage1(%s, %d, %d, %d, %d, %s, %f)\n", // jmeImage.getTexture().getKey().toString(), x, y, width, height, color.toString(), // imageScale); }
public void UserJoin(HostedConnection source, Message message) { boolean bfound = false; // SMObjectShare SMObjshare = (SMObjectShare)smobj; for (SMObjectPlayerController player : players) { if (source.getId() == Integer.parseInt(player.smobjshare.userid)) { SMObjectShare shareobject = (SMObjectShare) message; player.smobjshare = shareobject; // player.getSpatial().setLocalTranslation(shareobject.x, shareobject.y, shareobject.z); bfound = true; } } if (!bfound) { Box objplayer = new Box(Vector3f.ZERO, 1, 1, 1); Geometry geomplayer = new Geometry("Box", objplayer); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("m_Color", ColorRGBA.Brown); geomplayer.setMaterial(mat); Spatial spl = (Spatial) geomplayer; SMObjectPlayerController newplayer = new SMObjectPlayerController(spl); newplayer.smobjshare = new SMObjectShare(); newplayer.smobjshare.userid = Integer.toString(source.getId()); newplayer.smobjshare.userid = Integer.toString(source.getId()); source.send(newplayer.smobjshare); rootNode.attachChild(newplayer.getSpatial()); players.add(newplayer); } }
@Override public void simpleInitApp() { // add a random cube Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.randomColor()); geom.setMaterial(mat); geom.move( (FastMath.nextRandomFloat() * 10) - 5, (FastMath.nextRandomFloat() * 10) - 5, (FastMath.nextRandomFloat() * -10)); rootNode.attachChild(geom); // add saved cubes String userHome = System.getProperty("user.home"); BinaryImporter importer = BinaryImporter.getInstance(); importer.setAssetManager(assetManager); try { File file = new File(userHome + "/mycoolgame/savedgame.j3o"); Node sceneNode = (Node) importer.load(file); sceneNode.setName("My restored node"); rootNode.attachChild(sceneNode); Logger.getLogger(SaveAndLoad.class.getName()).log(Level.INFO, "Success: Loaded saved node."); } catch (IOException ex) { Logger.getLogger(SaveAndLoad.class.getName()) .log(Level.INFO, "Warning: Could not load saved node.", ex); } }
@Override public void simpleInitApp() { loadHintText(); initCrossHairs(); setupKeys(); createMarker(); // WIREFRAME material matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); matWire.getAdditionalRenderState().setWireframe(true); matWire.setColor("Color", ColorRGBA.Green); createTerrain(); // createTerrainGrid(); DirectionalLight light = new DirectionalLight(); light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize()); rootNode.addLight(light); AmbientLight ambLight = new AmbientLight(); ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f)); rootNode.addLight(ambLight); cam.setLocation(new Vector3f(0, 256, 0)); cam.lookAtDirection(new Vector3f(0, -1f, 0).normalizeLocal(), Vector3f.UNIT_X); }
/** A red ball that marks the last spot that was "hit" by the "shot". */ protected void initMark() { Sphere sphere = new Sphere(30, 30, 0.2f); mark = new Geometry("BOOM!", sphere); Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mark_mat.setColor("Color", ColorRGBA.Red); mark.setMaterial(mark_mat); }
@Override public void simpleInitApp() { JmeCanvasContext ctx = (JmeCanvasContext) getContext(); gui = new GUI(this, ctx.getCanvas()); gui.show(); flyCam.setEnabled(false); Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); rootNode.attachChild(geom); cinematic = new Cinematic(rootNode, 5); MotionPath path = new MotionPath(); path.addWayPoint(Vector3f.ZERO.clone()); path.addWayPoint(new Vector3f(10, 0, 0)); MotionEvent motionEvent = new MotionEvent(geom, path, 5); cinematic.addCinematicEvent(0, motionEvent); cinematic.fitDuration(); cinematic.setLoopMode(LoopMode.Loop); stateManager.attach(cinematic); }
/** A cube object for target practice */ protected Geometry makeCube(String name, float x, float y, float z) { Box box = new Box(new Vector3f(x, y, z), 1, 1, 1); Geometry cube = new Geometry(name, box); Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat1.setColor("Color", ColorRGBA.randomColor()); cube.setMaterial(mat1); return cube; }
/** A floor to show that the "shot" can go through several objects. */ protected Geometry makeFloor() { Box box = new Box(new Vector3f(0, -4, -5), 15, .2f, 15); Geometry floor = new Geometry("the Floor", box); Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat1.setColor("Color", ColorRGBA.Gray); floor.setMaterial(mat1); return floor; }
private Geometry putShape(SimpleApplication game, Mesh shape, ColorRGBA color) { Geometry g = new Geometry("coordinate axis", shape); Material mat = new Material(game.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.getAdditionalRenderState().setWireframe(true); mat.setColor("Color", color); g.setMaterial(mat); game.getRootNode().attachChild(g); return g; }
private void initBox() { Box b = new Box(1, 1, 1); Geometry blue = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); blue.setMaterial(mat); /** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */ rootNode.attachChild(blue); }
public void makeToonish(Spatial spatial) { if (spatial instanceof Node) { Node n = (Node) spatial; for (Spatial child : n.getChildren()) makeToonish(child); } else if (spatial instanceof Geometry) { Geometry g = (Geometry) spatial; Material m = g.getMaterial(); if (m.getMaterialDef().getName().equals("Phong Lighting")) { Texture t = assetManager.loadTexture("Textures/ColorRamp/toon.png"); // t.setMinFilter(Texture.MinFilter.NearestNoMipMaps); // t.setMagFilter(Texture.MagFilter.Nearest); m.setTexture("ColorRamp", t); m.setBoolean("UseMaterialColors", true); m.setColor("Specular", ColorRGBA.Black); m.setColor("Diffuse", ColorRGBA.White); m.setBoolean("VertexLighting", true); } } }
/** * Creates a SimpleWaterProcessor * * @param manager the asset manager */ public SimpleWaterProcessor(AssetManager manager) { this.manager = manager; material = new Material(manager, "Common/MatDefs/Water/SimpleWater.j3md"); material.setFloat("waterDepth", waterDepth); material.setFloat("waterTransparency", waterTransparency / 10); material.setColor("waterColor", ColorRGBA.White); material.setVector3("lightPos", new Vector3f(1, -1, 1)); material.setFloat("distortionScale", distortionScale); material.setFloat("distortionMix", distortionMix); material.setFloat("texScale", texScale); updateClipPlanes(); }
@Override public void simpleInitApp() { Sphere sphereMesh = new Sphere(32, 32, 1f); Geometry spherePlainGeo = new Geometry("rough sphere", sphereMesh); Material spherePlainMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); spherePlainMat.setFloat("Shininess", 0f); // [1,128] spherePlainMat.setBoolean("UseMaterialColors", true); spherePlainMat.setColor("Ambient", ColorRGBA.Black); spherePlainMat.setColor("Diffuse", ColorRGBA.Cyan); spherePlainMat.setColor("Specular", ColorRGBA.White); spherePlainGeo.setMaterial(spherePlainMat); spherePlainGeo.move(-2.5f, 0, 0); rootNode.attachChild(spherePlainGeo); Geometry sphereShinyGeo = new Geometry("normal sphere", sphereMesh); Material sphereShinyMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); sphereShinyMat.setBoolean("UseMaterialColors", true); sphereShinyMat.setColor("Ambient", ColorRGBA.Black); sphereShinyMat.setColor("Diffuse", ColorRGBA.Cyan); sphereShinyMat.setColor("Specular", ColorRGBA.White); sphereShinyMat.setFloat("Shininess", 4f); // [1,128] sphereShinyGeo.setMaterial(sphereShinyMat); rootNode.attachChild(sphereShinyGeo); Geometry sphereVeryShinyGeo = new Geometry("Smooth sphere", sphereMesh); Material sphereVeryShinyMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); sphereVeryShinyMat.setBoolean("UseMaterialColors", true); sphereVeryShinyMat.setColor("Ambient", ColorRGBA.Black); sphereVeryShinyMat.setColor("Diffuse", ColorRGBA.Cyan); sphereVeryShinyMat.setColor("Specular", ColorRGBA.White); sphereVeryShinyMat.setFloat("Shininess", 100f); // [1,128] sphereVeryShinyGeo.setMaterial(sphereVeryShinyMat); sphereVeryShinyGeo.move(2.5f, 0, 0); rootNode.attachChild(sphereVeryShinyGeo); /** Must add a light to make the lit object visible! */ DirectionalLight sun = new DirectionalLight(); sun.setDirection(new Vector3f(1, 0, -2)); sun.setColor(ColorRGBA.White); rootNode.addLight(sun); }
public void renderQuad(int x, int y, int width, int height, Color color) { colorMaterial.setColor("Color", convertColor(color, tempColor)); tempMat.loadIdentity(); tempMat.setTranslation(x, getHeight() - y, 0); tempMat.setScale(width, height, 0); rm.setWorldMatrix(tempMat); rm.setForcedRenderState(renderState); colorMaterial.render(quadGeom, rm); // System.out.format("renderQuad1(%d, %d, %d, %d, %s)\n", x, y, width, height, // color.toString()); }
public Recording(TerrainHeighmapCreator app, Camera cam, Node sceneNode) { this.app = app; this.cam = cam; this.sceneNode = new Node("record"); sceneNode.attachChild(this.sceneNode); this.points = new ArrayList<>(); sphereMesh = new Sphere(8, 8, 0.25f * TerrainHeighmapCreator.TERRAIN_SCALE); sphereMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); sphereMat.setColor("Color", ColorRGBA.Blue); arrowMat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); arrowMat.getAdditionalRenderState().setWireframe(true); arrowMat.setColor("Color", ColorRGBA.Red); app.getNifty().addXml("org/shaman/terrain/vegetation/DummyScreen.xml"); app.getInputManager() .addMapping("RecordingAdd", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); app.getInputManager() .addMapping("RecordingSpeed-", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true)); app.getInputManager() .addMapping("RecordingSpeed+", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false)); app.getInputManager().addListener(this, "RecordingAdd", "RecordingSpeed-", "RecordingSpeed+"); }
@Override public void simpleInitApp() { Box a = new Box(Vector3f.ZERO, 1, 1, 1); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); for (int i = 0; i < 10; i++) { Geometry geom = new Geometry("Box" + i, a); geom.setLocalTranslation(0, i * 3, 0); geom.updateModelBound(); geom.setMaterial(mat); rootNode.attachChild(geom); } guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); ch = new BitmapText(guiFont, false); ch.setSize(guiFont.getCharSet().getRenderedSize()); ch.setText( "The Scene is Written to writej3o.j3o file, see it in your project folder!!!"); // crosshairs ch.setColor(new ColorRGBA(1f, 0.8f, 0.1f, 1f)); ch.setLocalTranslation(settings.getWidth() * 0.2f, settings.getHeight() * 0.1f, 0); String str = new String("assets/Models/writej3o.j3o"); // convert to / for windows if (File.separatorChar == '\\') { str = str.replace('\\', '/'); } if (!str.endsWith("/")) { str += "/"; } File MaFile = new File(str); MaFile.setWritable(true); MaFile.canWrite(); MaFile.canRead(); try { BinaryExporter.getInstance().save(rootNode, MaFile); guiNode.attachChild(ch); } catch (IOException ex) { System.out.println("Baddddd"); } viewPort.setBackgroundColor(ColorRGBA.Gray); flyCam.setMoveSpeed(30); }
protected void createMaterial() { Material material; if (alpha < 1f && transparent) { diffuse.a = alpha; } if (shadeless) { material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); material.setColor("Color", diffuse.clone()); material.setTexture("ColorMap", diffuseMap); // TODO: Add handling for alpha map? } else { material = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); material.setBoolean("UseMaterialColors", true); material.setColor("Ambient", ambient.clone()); material.setColor("Diffuse", diffuse.clone()); material.setColor("Specular", specular.clone()); material.setFloat("Shininess", shininess); // prevents "premature culling" bug if (diffuseMap != null) material.setTexture("DiffuseMap", diffuseMap); if (specularMap != null) material.setTexture("SpecularMap", specularMap); if (normalMap != null) material.setTexture("NormalMap", normalMap); if (alphaMap != null) material.setTexture("AlphaMap", alphaMap); } if (transparent) { material.setTransparent(true); material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); material.getAdditionalRenderState().setAlphaTest(true); material.getAdditionalRenderState().setAlphaFallOff(0.01f); } material.setName(matName); matList.put(matName, material); }
private Spatial createFollowBox() { // add spatial representing the position the driving car is steering towards Box box = new Box(new Vector3f(0, 0, 0), 1f, 1f, 1f); Geometry followBox = new Geometry("followBox", box); followBox.setLocalTranslation(0, 0, 0); Material followBoxMaterial = new Material(sim.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); followBoxMaterial.setColor("Color", ColorRGBA.Green); followBox.setMaterial(followBoxMaterial); followBox.setLocalScale(0.4f); sim.getSceneNode().attachChild(followBox); if (!settings.isPathVisible()) followBox.setCullHint(CullHint.Always); return followBox; }
@Override public void simpleInitApp() { initOpenCL1(); Box b = new Box(1, 1, 1); // create cube shape 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 initCounter = 0; time = 0; flyCam.setDragToRotate(true); }
public static Material getLightingColor(ColorRGBA color) { // We first check if the requested color exist in the map if (colorsMap.containsKey(color)) { return colorsMap.get(color); } // At this point, we know that the color doesn't exist. // We must create a new material, add it to the map and return it. Material res = new Material(am, "Common/MatDefs/Light/Lighting.j3md"); res.setColor("Diffuse", color); res.setFloat("Shininess", 10f); res.setBoolean("UseMaterialColors", true); colorsMap.put(color, res); return res; }
private void displayMap() { MapManager mm = gm.getMapManager(); Board bord = mm.getBoard(); List<Location> locations = bord.getLocations(); if (locations != null && locations.size() > 0) { for (Location loc : locations) { Box b = new Box(Vector3f.ZERO, 2.0f, 0.2f, 2.0f); Geometry geom = new Geometry("Box", b); // Spatial geom = app.getAssetManager().loadModel("Models/Suzanne.j3o"); // Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); // mat.setBoolean("UseMaterialColors", true); // mat.setColor("Specular", ColorRGBA.White); // mat.setColor("Diffuse", ColorRGBA.White); // mat.setFloat("Shininess", 5f); // [1,128] Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Orange); geom.setMaterial(mat); geom.setLocalTranslation(loc.getX(), 1, loc.getY()); String geomName = "LOCATION_" + loc.getName(); geom.setName(geomName); geom.setUserData(geomName, loc); displayLocationName(loc.getName(), new Vector3f(loc.getX(), 1, loc.getY())); List<Transport> transports = loc.getTransports(); if (transports != null && transports.size() > 0) { for (Transport transport : transports) { if (transport.getTarget() != loc) { drawTransportLine(loc, transport.getTarget(), transport.getCost()); } } } locationNodes.attachChild(geom); } } }
private void drawTransportLine(Location start, Location end, double cost) { Vector3f lineStart = new Vector3f(start.getX(), 0.5f, start.getY()); Vector3f lineEnd = new Vector3f(end.getX(), 0.5f, end.getY()); Vector3f middle = lineStart.add(lineEnd).divide(2.0f); displayTransportCost(cost, middle); Line line = new Line(lineStart, lineEnd); line.setLineWidth(3.0f); Material lineMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); lineMaterial.setColor("Color", ColorRGBA.Magenta); Geometry lineGeometry = new Geometry("line", line); lineGeometry.setMaterial(lineMaterial); lineNodes.attachChild(lineGeometry); }