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); }