public static TextureData takeWindowsColumnsTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, WallPart wp, BuildingElementsTextureManager tm) { String mt = null; TextureData td = tm.findTexture(new TextureFindCriteria(Type.WINDOWS, mt, null, null, null, false)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
@Override public TextureData findTexture(TextureFindCriteria pTextureFindCriteria) { boolean colorable = pTextureFindCriteria.isColorable(); Type type = pTextureFindCriteria.getType(); if (Type.WINDOW.equals(type)) { key = TextureLibraryKey.BUILDING_WINDOW; String keyStr = this.textureLibraryStorageService.getKey(key, pTextureFindCriteria.getTypeName()/*, pTextureFindCriteria.getSubTypeName()*/); if ( pTextureFindCriteria.getHeight() != null || pTextureFindCriteria.getWidth() != null) { textureSet = filterByBestSizeMatch(pTextureFindCriteria, textureSet); TextureData textureData = getRadnomTextureFromSet(textureSet, pTextureFindCriteria.getId());
/** * @param pTextureFindCriteria * @param textureSet * @return */ public List<TextureData> filterByBestSizeMatch(TextureFindCriteria pTextureFindCriteria, List<TextureData> textureSet) { TextureData best = null; double bestError = Double.MAX_VALUE; double height = pTextureFindCriteria.getHeight() == null ? 0 : pTextureFindCriteria.getHeight(); double width = pTextureFindCriteria.getWidth() == null ? 0 : pTextureFindCriteria.getWidth(); for (TextureData td : textureSet) { double dH = td.getHeight() - height; double dW = td.getWidth() - width; double err = dH * dH + dW * dW; if (err < bestError) { bestError = err; best = td; } } return Arrays.asList(best); } }
public static TextureData findWindowTextureData(BuildingNodeElement be, BuildingElementsTextureManager pTextureMenager) { TextureData td = null; if (be instanceof WindowBuildingElement) { WindowBuildingElement wbe = (WindowBuildingElement) be; td = pTextureMenager.findTexture(new TextureFindCriteria(Type.WINDOW, wbe.getWindowType(), null, wbe .getWidth(), wbe.getHeight(), false)); } else if (be instanceof EntranceBuildingElement) { EntranceBuildingElement wbe = (EntranceBuildingElement) be; td = pTextureMenager.findTexture(new TextureFindCriteria(Type.ENTERENCE, wbe.getEntranceType(), null, wbe .getWidth(), wbe.getHeight(), false)); } else { throw new RuntimeException("unsuported buidlding element " + be); } if (td == null) { td = createEmptyTextureData(); } return td; }
public static TextureData takeFloorTextureData(BuildingModel buildingModel, BuildingPart bp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (bp.getFloorMaterialType() != null) { mt = bp.getFloorMaterialType(); } else if (buildingModel.getFloorMaterialType() != null) { mt = buildingModel.getFloorMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FLOOR, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
public static TextureData takeFacadeTextureData(BuildingModel buildingModel, NodeBuildingPart bp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (bp.getFacadeMaterialType() != null) { mt = bp.getFacadeMaterialType(); } else if (buildingModel.getFacadeMaterialType() != null) { mt = buildingModel.getFacadeMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FACADE, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
private static TextureData takeRoofTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (w.getRoofMaterialType() != null) { mt = w.getRoofMaterialType(); } else if (bp.getRoofMaterialType() != null) { mt = bp.getRoofMaterialType(); } else if (buildingModel.getRoofMaterialType() != null) { mt = buildingModel.getRoofMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.ROOF, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }
public static TextureData takeFacadeTextureData(BuildingModel buildingModel, BuildingPart bp, Wall w, WallPart wp, BuildingElementsTextureManager tm, boolean colorable) { String mt = null; if (wp != null && wp.getFacadeMaterialType() != null) { mt = wp.getFacadeMaterialType(); } else if (w.getFacadeMaterialType() != null) { mt = w.getFacadeMaterialType(); } else if (bp.getFacadeMaterialType() != null) { mt = bp.getFacadeMaterialType(); } else if (buildingModel.getFacadeMaterialType() != null) { mt = buildingModel.getFacadeMaterialType(); } TextureData td = tm.findTexture(new TextureFindCriteria(Type.FACADE, mt, null, null, null, colorable)); if (td == null) { td = new TextureData(null, 1, 1); } return td; }