/** Add mesh to model. * @return added mesh */ public MeshFactory addMesh() { return addMesh((String) null); }
private static MeshFactory createWallMesh(ModelFactory mf, int partNumber, Material mat) { MeshFactory mesh = mf.addMesh("WallPart: " + partNumber); mesh.hasTexture = true; mesh.materialID = mf.cacheMaterial(mat); return mesh; }
MeshFactory createOrGetMeshFactory(String textureKey) { MeshFactory meshFactory = catchMesh.get(textureKey); if (meshFactory == null) { meshFactory = mf.addMesh(textureKey); Material mat = MaterialFactory.createTextureMaterial(textureKey); int iMat = mf.addMaterial(mat); meshFactory.materialID = iMat; meshFactory.hasTexture = true; catchMesh.put(textureKey, meshFactory); } return meshFactory; } }
/** * @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; }
private static void buildModel(RoofTypeOutput rto, List<RoofDormerTypeOutput> roofExtensionsList, ModelFactory modelFactory) { for (MeshFactory mf : rto.getMesh()) { transformMeshFactory(mf, rto.getTransformationMatrix()); modelFactory.addMesh(mf); } for (RoofDormerTypeOutput roofDormerTypeOutput : roofExtensionsList) { if (roofDormerTypeOutput == null) { continue; } SimpleMatrix roofMatrix = rto.getTransformationMatrix() .mult(roofDormerTypeOutput.getTransformationMatrix()); for (MeshFactory mf : roofDormerTypeOutput.getMesh()) { transformMeshFactory(mf, roofMatrix); modelFactory.addMesh(mf); } } } }
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)); }
@Override public void buildWorldObject() { ModelFactory model = ModelFactory.modelBuilder(); MeshFactory mesh = model.addMesh("water"); TextureData waterTexture = getWaterTextureData();// new // TextureData("#c=#008EFF", // 1d, 1d); Material waterMaterial = MaterialFactory.createTextureMaterial(waterTexture.getTex0()); int waterMaterialIndex = model.addMaterial(waterMaterial); mesh.materialID = waterMaterialIndex; mesh.hasTexture = true; Vector3d nt = new Vector3d(0, 1, 0); Point3d planeRightTopPoint = new Point3d(0, 0.05, 0); List<PolygonWithHolesList2d> polyList = getMultiPolygonWithHoles(); for (PolygonWithHolesList2d poly : polyList) { List<Triangle2d> triangles = Poly2TriSimpleUtil.triangulate(poly); Plane3d planeTop = new Plane3d(planeRightTopPoint, nt); Vector3d roofTopLineVector = new Vector3d(-1, 0, 0); MeshFactoryUtil.addPolygonToRoofMesh(mesh, triangles, planeTop, roofTopLineVector, waterTexture, 0, 0); } this.model = model.toModel(); this.model.setUseLight(true); this.model.setUseTexture(true); buildModel = true; }
MeshFactory meshWalls = modelBuilder.addMesh("road");