예제 #1
0
    @Override
    public void renderTo(Target<?> target) {

      float width = parseWidth(node.getTags(), 1.5f);

      /* determine material */

      Material material = null;

      // TODO parse color

      if (material == null) {
        material = Materials.getSurfaceMaterial(node.getTags().getValue("material"));
      }

      if (material == null) {
        material = Materials.getSurfaceMaterial(node.getTags().getValue("surface"), Materials.WOOD);
      }

      /* calculate vectors and corners */

      double directionAngle = parseDirection(node.getTags(), PI);

      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();

      List<VectorXZ> cornerOffsets = new ArrayList<VectorXZ>(4);
      cornerOffsets.add(faceVector.mult(+0.25).add(boardVector.mult(+width / 2)));
      cornerOffsets.add(faceVector.mult(+0.25).add(boardVector.mult(-width / 2)));
      cornerOffsets.add(faceVector.mult(-0.25).add(boardVector.mult(+width / 2)));
      cornerOffsets.add(faceVector.mult(-0.25).add(boardVector.mult(-width / 2)));

      /* draw seat and backrest */

      target.drawBox(material, getBase().addY(0.5), faceVector, 0.05, width, 0.5);

      if (!node.getTags().contains("backrest", "no")) {

        target.drawBox(
            material,
            getBase().add(faceVector.mult(-0.23)).addY(0.5),
            faceVector,
            0.5,
            width,
            0.04);
      }

      /* draw poles */

      for (VectorXZ cornerOffset : cornerOffsets) {
        VectorXZ polePos = node.getPos().add(cornerOffset.mult(0.8));
        target.drawBox(material, polePos.xyz(getBase().y), faceVector, 0.5, 0.08, 0.08);
      }
    }
예제 #2
0
    @Override
    public void renderTo(Target<?> target) {

      float height = parseHeight(node.getTags(), 0.5f);
      float width = parseWidth(node.getTags(), 1);
      float depth = width / 2f;

      /* determine material */

      Material material = null;

      // TODO parse color

      if (material == null) {
        material = Materials.getSurfaceMaterial(node.getTags().getValue("material"));
      }

      if (material == null) {
        material =
            Materials.getSurfaceMaterial(
                node.getTags().getValue("surface"), Materials.GRITBIN_DEFAULT);
      }

      double directionAngle = parseDirection(node.getTags(), PI);

      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();

      /* draw box */
      target.drawBox(material, getBase(), faceVector, height, width, depth);

      /* draw lid */
      List<VectorXYZ> vs = new ArrayList<VectorXYZ>();
      vs.add(getBase().addY(height + 0.2));
      vs.add(
          getBase().add(boardVector.mult(width / 2)).add(faceVector.mult(depth / 2)).addY(height));
      vs.add(
          getBase().add(boardVector.mult(-width / 2)).add(faceVector.mult(depth / 2)).addY(height));
      vs.add(
          getBase()
              .add(boardVector.mult(-width / 2))
              .add(faceVector.mult(-depth / 2))
              .addY(height));
      vs.add(
          getBase().add(boardVector.mult(width / 2)).add(faceVector.mult(-depth / 2)).addY(height));
      vs.add(
          getBase().add(boardVector.mult(width / 2)).add(faceVector.mult(depth / 2)).addY(height));

      target.drawTriangleFan(material.brighter(), vs, null);
    }
예제 #3
0
    @Override
    public void renderTo(Target<?> target) {

      float width = parseWidth(node.getTags(), 4);
      float height = parseHeight(node.getTags(), 3.5f);
      float minHeight = height / 5;

      double directionAngle = parseDirection(node.getTags(), PI);

      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ boardVector = faceVector.rightNormal();

      /* draw board */

      VectorXYZ[] vsPoster = {
        getBase().add(boardVector.mult(width / 2)).addY(height),
        getBase().add(boardVector.mult(width / 2)).addY(minHeight),
        getBase().add(boardVector.mult(-width / 2)).addY(height),
        getBase().add(boardVector.mult(-width / 2)).addY(minHeight)
      };

      List<VectorXYZ> vsListPoster = asList(vsPoster);

      target.drawTriangleStrip(
          ADVERTISING_POSTER,
          vsListPoster,
          texCoordLists(vsListPoster, ADVERTISING_POSTER, STRIP_FIT));

      VectorXYZ[] vsBoard = {vsPoster[2], vsPoster[3], vsPoster[0], vsPoster[1]};

      List<VectorXYZ> vsListBoard = asList(vsBoard);

      target.drawTriangleStrip(
          CONCRETE, vsListBoard, texCoordLists(vsListBoard, CONCRETE, STRIP_WALL));

      /* draw poles */

      VectorXZ[] poles = {
        node.getPos().add(boardVector.mult(-width / 4)),
        node.getPos().add(boardVector.mult(+width / 4))
      };

      for (VectorXZ pole : poles) {
        target.drawBox(CONCRETE, pole.xyz(getBase().y), faceVector, minHeight, 0.2, 0.1);
      }
    }
예제 #4
0
    @Override
    public void renderTo(Target<?> target) {

      double ele = getBase().y;

      double directionAngle = parseDirection(node.getTags(), PI);

      Material boxMaterial = POSTBOX_DEUTSCHEPOST;
      Material otherMaterial = STEEL;

      VectorXZ faceVector = VectorXZ.fromAngle(directionAngle);
      VectorXZ rightVector = faceVector.rightNormal();

      // shape depends on type
      if (node.getTags().contains("type", "Rondell")) {

        float height = parseHeight(node.getTags(), 2.2f);
        float width = parseWidth(node.getTags(), 3f);
        float rondelWidth = width * 2 / 3;
        float boxWidth = width * 1 / 3;
        float roofOverhang = 0.3f;

        /* draw rondel */
        target.drawColumn(
            boxMaterial,
            null,
            getBase().add(rightVector.mult(-rondelWidth / 2)),
            height,
            rondelWidth / 2,
            rondelWidth / 2,
            false,
            true);
        /* draw box */
        target.drawBox(
            boxMaterial,
            getBase().add(rightVector.mult(boxWidth / 2)).add(faceVector.mult(-boxWidth / 2)),
            faceVector,
            height,
            boxWidth,
            boxWidth);
        /* draw roof */
        target.drawColumn(
            otherMaterial,
            null,
            getBase().addY(height),
            0.1,
            rondelWidth / 2 + roofOverhang / 2,
            rondelWidth / 2 + roofOverhang / 2,
            true,
            true);

      } else if (node.getTags().contains("type", "Paketbox")) {

        float height = parseHeight(node.getTags(), 1.5f);
        float width = parseHeight(node.getTags(), 1.0f);
        float depth = width;

        target.drawBox(boxMaterial, getBase(), faceVector, height, width * 2, depth * 2);

      } else { // type=Schrank or type=24/7 Station (they look roughly the same) or no type
               // (fallback)

        float height = parseHeight(node.getTags(), 2.2f);
        float width = parseWidth(node.getTags(), 3.5f);
        float depth = width / 3;
        float roofOverhang = 0.3f;

        /* draw box */
        target.drawBox(boxMaterial, getBase(), faceVector, height, width, depth);
        /*  draw small roof */
        target.drawBox(
            otherMaterial,
            node.getPos().add(faceVector.mult(roofOverhang)).xyz(ele + height),
            faceVector,
            0.1,
            width,
            depth + roofOverhang * 2);
      }
    }