Пример #1
0
    @Override
    public void renderTo(Target<?> target) {

      // TODO: join ways back together to reduce the number of caps

      List<VectorXYZ> wallShape =
          asList(
              new VectorXYZ(-width / 2, 0, 0),
              new VectorXYZ(-width / 2, height, 0),
              new VectorXYZ(+width / 2, height, 0),
              new VectorXYZ(+width / 2, 0, 0));

      List<VectorXYZ> path = line.getElevationProfile().getPointsWithEle();

      List<List<VectorXYZ>> strips =
          createShapeExtrusionAlong(wallShape, path, nCopies(path.size(), VectorXYZ.Y_UNIT));

      for (List<VectorXYZ> strip : strips) {
        target.drawTriangleStrip(material, strip, wallTexCoordLists(strip, material));
      }

      /* draw caps */

      List<VectorXYZ> startCap =
          transformShape(wallShape, path.get(0), line.getDirection().xyz(0), VectorXYZ.Y_UNIT);
      List<VectorXYZ> endCap =
          transformShape(
              wallShape,
              path.get(path.size() - 1),
              line.getDirection().invert().xyz(0),
              VectorXYZ.Y_UNIT);

      List<List<VectorXZ>> texCoordLists = globalTexCoordLists(wallShape, material, true);

      target.drawConvexPolygon(material, startCap, texCoordLists);
      target.drawConvexPolygon(material, endCap, texCoordLists);
    }