/** * Creates the default axes, which are lines of different colors from the origin to the unit * vectors. These are attached to the Node {@link #axes}. */ protected void initAxes() { Geometry geometry; Line line; float lineWidth = 3f; // Create the x axis as a red line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_X); line.setLineWidth(lineWidth); geometry = new Geometry("x", line); geometry.setMaterial(materials.get("XAxis")); axes.attachChild(geometry); // Create the y axis as a green line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_Y); line.setLineWidth(lineWidth); geometry = new Geometry("y", line); geometry.setMaterial(materials.get("YAxis")); axes.attachChild(geometry); // Create the z axis as a blue line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_Z); line.setLineWidth(lineWidth); geometry = new Geometry("z", line); geometry.setMaterial(materials.get("ZAxis")); axes.attachChild(geometry); return; }
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); }
/** * Initialize the axes displayed in the scene. This method should be overridden if custom axes are * desired. You can toggle the axes by using {@link #setDisplayAxes(boolean)}. * * <p>If this method is overridden, you should also override {@link #clearAxes()} to dispose of * them properly when the <code>ViewAppState</code> is cleaned. */ protected void initAxes() { // If necessary, add spatials to the axes. Geometry geometry; Line line; float lineWidth = 3f; // Create the materials for the axis. In a sub-class, this would be done // in initMaterials(). However, adding the materials here is easier for // sub-classes because there would be a dependency between initAxes() // and initMaterials(). setMaterial("XAxis", createBasicMaterial(ColorRGBA.Red)); setMaterial("YAxis", createBasicMaterial(ColorRGBA.Green)); setMaterial("ZAxis", createBasicMaterial(ColorRGBA.Blue)); // Create the x axis as a red line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_X); line.setLineWidth(lineWidth); geometry = new Geometry("x", line); geometry.setMaterial(getMaterial("XAxis")); axes.attachChild(geometry); // Create the y axis as a green line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_Y); line.setLineWidth(lineWidth); geometry = new Geometry("y", line); geometry.setMaterial(getMaterial("YAxis")); axes.attachChild(geometry); // Create the z axis as a blue line of unit length. line = new Line(Vector3f.ZERO, Vector3f.UNIT_Z); line.setLineWidth(lineWidth); geometry = new Geometry("z", line); geometry.setMaterial(getMaterial("ZAxis")); axes.attachChild(geometry); return; }
/** @param l */ public LightModel(Light l) { light = l; if (!(l instanceof AmbientLight)) { symbolMaterial = new Material( CurrentData.getEditorWindow().getB3DApp().getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); symbolMaterial.setColor("Color", l.getColor()); representativeMaterial = new Material( CurrentData.getEditorWindow().getB3DApp().getAssetManager(), "Common/MatDefs/Light/Lighting.j3md"); if (l instanceof DirectionalLight) { /*Light*/ DirectionalLight dLight = (DirectionalLight) l; /*Representativ*/ representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showDirectionalLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setMaterial(representativeMaterial); /*Symbol*/ Vector3f end = CurrentData.getEditorWindow() .getB3DApp() .getCamera() .getLocation() .add(CurrentData.getEditorWindow().getB3DApp().getCamera().getDirection().mult(20)) .add(dLight.getDirection().mult(100)); Line symbolMesh = new Line(representative.getWorldTranslation(), end); symbolMesh.setPointSize(5); symbol = new Geometry("LightSymbol", symbolMesh); symbol.setMaterial(symbolMaterial); } else if (l instanceof PointLight) { PointLight pLight = (PointLight) l; representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showPointLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setMaterial(representativeMaterial); representative.setLocalTranslation(pLight.getPosition()); symbol = new Geometry("LightSymbol", new Sphere(15, 15, pLight.getRadius())); symbol.setMaterial(symbolMaterial); symbolMaterial.getAdditionalRenderState().setWireframe(true); } else if (l instanceof SpotLight) { /*Light*/ SpotLight sLight = (SpotLight) l; /*Representativ*/ representativeMaterial.setTexture( "DiffuseMap", CurrentData.getEditorWindow() .getB3DApp() .getAssetManager() .loadTexture("Textures/showSpotLightTexture.PNG")); representative = new Geometry("LightModel", new Box(1, 1, 1)); representative.setLocalTranslation(sLight.getPosition()); representative.setMaterial(representativeMaterial); /*Symbol*/ Vector3f end = sLight.getPosition().add(sLight.getDirection().mult(sLight.getSpotRange())); Line symbolMesh = new Line(representative.getWorldTranslation(), end); symbolMesh.setPointSize(5); symbol = new Geometry("LightSymbol", symbolMesh); symbol.setMaterial(symbolMaterial); } node.attachChild(representative); if (symbol != null) { node.attachChild(symbol); } } }