Esempio n. 1
0
  /**
   * 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;
  }
Esempio n. 2
0
  /**
   * 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;
  }
  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);
  }