/** * @param tex0Key * @param textColor * @param meshName * @param modelBuilder * @return */ public static MeshFactory createMesh(String tex0Key, Color textColor, String meshName, ModelFactory modelBuilder) { MeshFactory meshBorder = modelBuilder.addMesh(meshName); // Material fenceMaterial = MaterialFactory.createTextureMaterial(tex0); Material mat = MaterialFactory.createTextureColorMaterial(tex0Key, textColor); int facadeMaterialIndex = modelBuilder.addMaterial(mat); meshBorder.materialID = facadeMaterialIndex; meshBorder.hasTexture = true; return meshBorder; }
private static MeshFactory createRoofMesh(ModelFactory mf, TextureData td, Color color) { Material mat = MaterialFactory.createTextureColorMaterial(td.getTex0(), color); int materialIndex = mf.addMaterial(mat); MeshFactory meshRoof = mf.addMesh("roof_top"); meshRoof.materialID = materialIndex; meshRoof.hasTexture = true; return meshRoof; }
/** * Wall material can few four components like wall color (mixed with base * texture), base texture (mixed with color), optional overlayer texture for * wall material (like bricks) and optional overlayer for wall windows. * * @param facadeColor * facade color * @param facadeTextureData * facade texture data with required base texture, and optional * overlay * @param windowsOverlayerTextureData * optional texture with window overlayer * @return material for facade */ private static Material createWallMaterial(Color facadeColor, TextureData facadeTextureData, TextureData windowsOverlayerTextureData) { Material mat = MaterialFactory.createTextureColorMaterial(facadeTextureData.getTex0(), facadeColor); if (facadeTextureData.getTex1() != null) { mat.getTexturesComponent().add(facadeTextureData.getTex1()); } if (windowsOverlayerTextureData != null) { mat.getTexturesComponent().add(windowsOverlayerTextureData.getTex0()); } return mat; }
/** * Add material representing texture to model. * * @param textureData * @param model * @return */ private static RoofTextureIndex addMateraialTexture(TextureData textureData, Color color, ModelFactory model) { Material facadeMaterial = null; if (color != null) { facadeMaterial = MaterialFactory.createTextureColorMaterial(textureData.getTex0(), color); } else { facadeMaterial = MaterialFactory.createTextureMaterial(textureData.getTex0()); } int facadeMaterialIndex = model.addMaterial(facadeMaterial); return new RoofTextureIndex(facadeMaterialIndex, textureData); }
private static BuildingPartOutput buildNodePart(NodeBuildingPart bp, BuildingModel buildingModel, ModelFactory mf, BuildingElementsTextureManager tm) { if (bp instanceof SphereNodeBuildingPart) { Color floorColor = takeFacadeColor(buildingModel, bp, tm); TextureData floorTD = takeFacadeTextureData(buildingModel, bp, tm, floorColor != null); String tex0Key = floorTD.getTex0(); Material mat = MaterialFactory.createTextureColorMaterial(tex0Key, floorColor); MeshFactory mesh = mf.addMesh("NodePart"); mesh.hasTexture = true; mesh.materialID = mf.cacheMaterial(mat); SphereNodeBuildingPart sphere = (SphereNodeBuildingPart) bp; int pIcross = 12; int icross = pIcross + 1; double height = sphere.getHeight(); double radius = sphere.getRadius(); Point2d point = sphere.getPoint(); // create cross section Point2d[] crossSection = new Point2d[icross]; for (int i = 0; i < icross; i++) { double a = Math.toRadians(180) / (icross - 1) * i - Math.toRadians(90); crossSection[i] = new Point2d(Math.cos(a) * radius, Math.sin(a) * radius + height); } int pIsection = 12; RoofType5v6.buildRotaryShape(mesh, point, pIsection, crossSection, true); } return new BuildingPartOutput(); }
private static void buildFloor(BuildingPart bp, BuildingModel buildingModel, ModelFactory mf, BuildingElementsTextureManager tm, TextureData roofTextureData, Color facadeColor, double minHeight) { Color floorColor = takeFloorColor(buildingModel, bp, tm); TextureData floorTD = takeFloorTextureData(buildingModel, bp, tm, floorColor != null); String tex0Key = floorTD.getTex0(); Material mat = MaterialFactory.createTextureColorMaterial(tex0Key, floorColor); MeshFactory mesh = mf.addMesh("FloorPart"); mesh.hasTexture = true; mesh.materialID = mf.cacheMaterial(mat); PolygonWithHolesList2d buildingPolygon = BuildingUtil.buildingPartToPolygonWithHoles(bp); MeshFactoryUtil.addPolygonWithHolesInYRevert(buildingPolygon, minHeight, mesh, roofTextureData, 0, 0, new Vector3d(1, 0, 0)); }