Package org.osm2world.core.target.common.material

Examples of org.osm2world.core.target.common.material.Material


      float nacelleDepth = poleHeight * 0.1f;
      float bladeLength = poleHeight / 2;
     
      /* determine material */
     
      Material poleMaterial = null;
      Material nacelleMaterial = Materials.STEEL;
      Material bladeMaterial = Materials.STEEL; // probably fibre, but color matches roughly :)
     
      //TODO parse color
     
      if (poleMaterial == null) {
        poleMaterial = Materials.getSurfaceMaterial(
View Full Code Here


    public void renderTo(Target<?> target) {

      VectorXYZ base = getBase().addY(-0.5);
      double height = parseHeight(node.getTags(), 14);

      Material material = Materials.getSurfaceMaterial(node.getTags().getValue("material"));
      if (material == null) {
        material = Materials.getSurfaceMaterial(node.getTags().getValue("surface"), Materials.STEEL);
      }
     
      // draw base column
View Full Code Here

     
      /* determine defaults for building type */
     
      int defaultLevels = 3;
      double defaultHeightPerLevel = 2.5;
      Material defaultMaterialWall = Materials.BUILDING_DEFAULT;
      Material defaultMaterialRoof = Materials.ROOF_DEFAULT;
      Material defaultMaterialWindows = Materials.BUILDING_WINDOWS;
      String defaultRoofShape = "flat";
     
      String buildingValue = getValue("building");
     
      if ("greenhouse".equals(buildingValue)) {
        defaultLevels = 1;
        defaultMaterialWall = Materials.GLASS;
        defaultMaterialRoof = Materials.GLASS_ROOF;
        defaultMaterialWindows = null;
      } else if ("garage".equals(buildingValue)
          || "garages".equals(buildingValue)) {
        defaultLevels = 1;
        defaultMaterialWall = Materials.CONCRETE;
        defaultMaterialRoof = Materials.CONCRETE;
        defaultMaterialWindows = Materials.GARAGE_DOORS;
      } else if ("hut".equals(buildingValue)
          || "shed".equals(buildingValue)) {
        defaultLevels = 1;
      } else if ("cabin".equals(buildingValue)) {
        defaultLevels = 1;
        defaultMaterialWall = Materials.WOOD_WALL;
        defaultMaterialRoof = Materials.WOOD;
      } else if ("roof".equals(buildingValue)) {
        defaultLevels = 1;
        defaultMaterialWindows = null;
      } else if ("church".equals(buildingValue)
          || "hangar".equals(buildingValue)
          || "industrial".equals(buildingValue)) {
        defaultMaterialWindows = null;
      } else {
        if (getValue("building:levels") == null) {
          defaultMaterialWindows = null;
        }
      }
     
      /* determine levels */
     
      buildingLevels = defaultLevels;
     
      Float parsedLevels = null;
     
      if (getValue("building:levels") != null) {
        parsedLevels = parseOsmDecimal(
            getValue("building:levels"), false);
      }
     
      if (parsedLevels != null) {
        buildingLevels = (int)(float)parsedLevels;
      } else if (parseHeight(tags, parseHeight(buildingTags, -1)) > 0) {
        buildingLevels = max(1, (int)(parseHeight(tags, parseHeight(
            buildingTags, -1)) / defaultHeightPerLevel));
      }
     
      minLevel = 0;
     
      if (getValue("building:min_level") != null) {
        Float parsedMinLevel = parseOsmDecimal(
            getValue("building:min_level"), false);
        if (parsedMinLevel != null) {
          minLevel = (int)(float)parsedMinLevel;
        }
      }
     
      /* determine roof shape */
     
      boolean explicitRoofTagging = true;
     
      if (!("no".equals(area.getTags().getValue("roof:lines"))) && hasComplexRoof(area)) {
        roof = new ComplexRoof();
      } else {
       
        String roofShape = getValue("roof:shape");
        if (roofShape == null) { roofShape = getValue("building:roof:shape"); }
       
        if (roofShape == null) {
          roofShape = defaultRoofShape;
          explicitRoofTagging = false;
        }
       
        try {
         
          if ("pyramidal".equals(roofShape)) {
            roof = new PyramidalRoof();
          } else if ("onion".equals(roofShape)) {
            roof = new OnionRoof();
          } else if ("skillion".equals(roofShape)) {
            roof = new SkillionRoof();
          } else if ("gabled".equals(roofShape)) {
            roof = new GabledRoof();
          } else if ("hipped".equals(roofShape)) {
            roof = new HippedRoof();
          } else if ("half-hipped".equals(roofShape)) {
            roof = new HalfHippedRoof();
          } else if ("gambrel".equals(roofShape)) {
            roof = new GambrelRoof();
          } else if ("mansard".equals(roofShape)) {
            roof = new MansardRoof();
          } else if ("dome".equals(roofShape)) {
            roof = new DomeRoof();
          } else if ("round".equals(roofShape)) {
            roof = new RoundRoof();
          } else {
            roof = new FlatRoof();
          }
         
        } catch (InvalidGeometryException e) {
          System.err.println("falling back to FlatRoof: " + e);
          roof = new FlatRoof();
          explicitRoofTagging = false;
        }
       
      }
     
      /* determine height */
     
      double fallbackHeight = buildingLevels * defaultHeightPerLevel;
     
      fallbackHeight += roof.getRoofHeight();
     
      fallbackHeight = parseHeight(buildingTags, (float)fallbackHeight);
     
      double height = parseHeight(tags, (float)fallbackHeight);
        heightWithoutRoof = height - roof.getRoofHeight();
     
      /* determine materials */
       
        if (defaultMaterialRoof == Materials.ROOF_DEFAULT
            && explicitRoofTagging && roof instanceof FlatRoof) {
          defaultMaterialRoof = Materials.CONCRETE;
        }
       
        if (useBuildingColors) {
         
          materialWall = buildMaterial(
              getValue("building:material"),
              getValue("building:colour"),
              defaultMaterialWall, false);
          materialRoof = buildMaterial(
              getValue("roof:material"),
              getValue("roof:colour"),
              defaultMaterialRoof, true);
         
        } else {
         
          materialWall = defaultMaterialWall;
          materialRoof = defaultMaterialRoof;
         
        }
       
        if (materialWall == Materials.GLASS) {
        // avoid placing windows into a glass front
        // TODO: the == currently only works if GLASS is not colorable
        defaultMaterialWindows = null;
        }
       
        materialWallWithWindows = materialWall;
       
        if (drawBuildingWindows) {

          Material materialWindows = defaultMaterialWindows;
         
          if (materialWindows != null) {
           
            materialWallWithWindows = materialWallWithWindows.
                withAddedLayers(materialWindows.getTextureDataList());
           
          }
         
        }
       
View Full Code Here

   
    private Material buildMaterial(String materialString,
        String colorString, Material defaultMaterial,
        boolean roof) {
     
      Material material = defaultMaterial;
     
      if (materialString != null) {
        if ("brick".equals(materialString)) {
          material = Materials.BRICK;
        } else if ("glass".equals(materialString)) {
          material = roof ? Materials.GLASS_ROOF : Materials.GLASS;
        } else if ("wood".equals(materialString)) {
          material = Materials.WOOD_WALL;
        } else if (Materials.getSurfaceMaterial(materialString) != null) {
          material = Materials.getSurfaceMaterial(materialString);
        }
      }
     
      boolean colorable = material.getNumTextureLayers() == 0
          || material.getTextureDataList().get(0).colorable;
     
      if (colorString != null && colorable) {
       
        Color color;
       
        if ("white".equals(colorString)) {
          color = new Color(240, 240, 240);
        } else if ("black".equals(colorString)) {
          color = new Color(76, 76, 76);
        } else if ("grey".equals(colorString)) {
          color = new Color(100, 100, 100);
        } else if ("red".equals(colorString)) {
          if (roof) {
            color = new Color(204, 0, 0);
          } else {
            color = new Color(255, 190, 190);
          }
        } else if ("green".equals(colorString)) {
          if (roof) {
            color = new Color(150, 200, 130);
          } else {
            color = new Color(190, 255, 190);
          }
        } else if ("blue".equals(colorString)) {
          if (roof) {
            color = new Color(100, 50, 200);
          } else {
            color = new Color(190, 190, 255);
          }
        } else if ("yellow".equals(colorString)) {
          color = new Color(255, 255, 175);
        } else if ("pink".equals(colorString)) {
          color = new Color(225, 175, 225);
        } else if ("orange".equals(colorString)) {
          color = new Color(255, 225, 150);
        } else if ("brown".equals(colorString)) {
          if (roof) {
            color = new Color(120, 110, 110);
          } else {
            color = new Color(170, 130, 80);
          }
        } else {
          color = parseColor(colorString);
        }
       
        if (color != null) {
          material = new ImmutableMaterial(
              material.getLighting(), color,
              material.getAmbientFactor(),
              material.getDiffuseFactor(),
              material.getTransparency(),
              material.getTextureDataList());
        }
       
      }
     
      return material;
View Full Code Here

TOP

Related Classes of org.osm2world.core.target.common.material.Material

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.