public static Plane3d[] createPlanes(List<CrossSectionElement> crossSection) { Plane3d[] seg = new Plane3d[crossSection.size() - 1]; for (int i = 1; i < crossSection.size(); i++) { CrossSectionElement first = crossSection.get(i - 1); CrossSectionElement second = crossSection.get(i); Point3d p = new Point3d(0, first.p.y, -first.p.x); Vector3d v = new Vector3d(0, second.p.x - first.p.x, second.p.y - first.p.y); v.normalize(); Plane3d plane3d = new Plane3d(p, v); seg[i - 1] = plane3d; } return seg; }
/** * Creates planes for each edge in polygon. * * @param polygon * the polygon * @param height * the height of roof * @param m * the middle point * @return the planes for each polygon edge */ public static Plane3d[] createPlanes(List<Point2d> polygon, double height, Point2d m) { int size = polygon.size(); Plane3d[] ret = new Plane3d[size]; // Point3d center = new Point3d(m.x, height, -m.y); for (int i = 0; i < size; i++) { Point2d p1 = polygon.get(i); Point2d p2 = polygon.get((i + 1) % size); Vector3d v1 = new Vector3d(p1.x - m.x, -height, -(p1.y - m.y)); Vector3d v2 = new Vector3d(p2.x - m.x, -height, -(p2.y - m.y)); v1.cross(v1, v2); v1.normalize(); Point3d point = new Point3d(p1.x, 0, -p1.y); // Point3d point = new Point3d(p2.x, 0, -p2.y); Plane3d p = new Plane3d(point, v1); ret[i] = p; } return ret; }
private Plane3d createEdgePlane(LineSegment2d edge, double heightFactor) { Vector3d faceNormal = calcFaceNormal(edge, heightFactor); return new Plane3d(new Point3d(edge.getBegin().x, 0, -edge.getBegin().y), faceNormal); }
public static void buildFlatRoof(PolygonList2d borderPolygon, MeshFactory meshRoof, TextureData roofTexture) { MultiPolygonList2d topMP = new MultiPolygonList2d(borderPolygon); // build flat Point3d planeRightTopPoint = new Point3d(0, 0, 0); Vector3d nt = new Vector3d(0, 1, 0); Plane3d planeTop = new Plane3d(planeRightTopPoint, nt); Vector3d roofTopLineVector = new Vector3d(-1d, 0, 0); MeshFactoryUtil.addPolygonToRoofMesh(meshRoof, topMP, planeTop, roofTopLineVector, roofTexture); }
private static void addPolygonWithHolesInY(PolygonWithHolesList2d polygonWithHolesList2d, double height, MeshFactory meshFactory, TextureData textureData, double textureStartPointX, double textureStartPointY, Vector3d textureDirection, boolean top) { List<Triangle2d> topMP = Poly2TriSimpleUtil.triangulate(polygonWithHolesList2d); Vector3d yt = new Vector3d(0, 1, 0); if (!top) { yt.negate(); } Point3d textureStartPoint = new Point3d(textureStartPointX, height, -textureStartPointY); Plane3d planeTop = new Plane3d(textureStartPoint, yt); addPolygonToRoofMesh(meshFactory, topMP, planeTop, textureDirection, textureData, 0, 0); }
/** * Build roof hook space for rectangle edge. * * @param pEdge * rectangle edge number XXX * @param pRectangleContur * rectangle XXX * @param pPolygonPlane * polygon and plane defining height connected with rectangle * edge * @return roof hook space */ public static PolygonRoofHooksSpace buildRecHookSpace(Point2d p1, Vector2d v1, PolygonPlane pPolygonPlane) { if (pPolygonPlane == null) { return null; } Plane3d plane = new Plane3d(pPolygonPlane.getPlane().getPoint(), pPolygonPlane.getPlane().getNormal()); return new PolygonRoofHooksSpace(p1, v1, pPolygonPlane.getPolygon(), plane); }
Vector3d planeNormal = TransformationMatrix3d.transform(pPlane.getNormal(), tr3d); this.plane = new Plane3d(planePoint, planeNormal); SimpleMatrix trBack = TransformationMatrix3d.tranA(p1.x, 0, -p1.y).mult(TransformationMatrix3d.rotYA(angle));
/** * Creates roof plane. * * @param h1 * height 1 * @param h2 * height 2 * @param h3 * height 3 * @param recHeight * @param recWidth * @return roof plane */ private Plane3d createRoofPlane(double h1, double h2, double h3, double recWidth, double recHeight) { Point3d p1 = new Point3d(0, h1, 0); Vector3d v2 = new Vector3d(0, h2, -recHeight); v2.sub(p1); Vector3d v3 = new Vector3d(recWidth, h3, 0); v3.sub(p1); Vector3d normal = new Vector3d(); normal.cross(v3, v2); return new Plane3d(p1, normal); }
public RectangleRoofHooksSpace(Point2d p1, Vector2d v1, double b, Plane3d pPlane) { super(); // this.p1 = p1; // this.v1 = v1; this.b = b; double angle = Math.atan2(v1.y, v1.x); // Math.toDegrees(angle); SimpleMatrix tr2d = TransformationMatrix2d.rotZA(-angle).mult(TransformationMatrix2d.tranA(-p1.x, -p1.y)); SimpleMatrix tr3d = TransformationMatrix3d.rotYA(-angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); this.p1 = TransformationMatrix2d.transform(p1, tr2d); this.v1 = TransformationMatrix2d.transform(v1, tr2d); Point3d planePoint= TransformationMatrix3d.transform(pPlane.getPoint(), tr3d); Vector3d planeNormal = TransformationMatrix3d.transform(pPlane.getNormal(), tr3d); this.plane = new Plane3d(planePoint, planeNormal); SimpleMatrix trBack = TransformationMatrix3d.rotYA(angle).mult(TransformationMatrix3d.tranA(-p1.x, 0, p1.y)); this.transformationMatrix = trBack; }
final Plane3d planeBottom = new Plane3d(planeLeftBottomPoint, nb); final Plane3d planeMiddleBottom = new Plane3d(planeLeftBottomPoint, nmb); final Plane3d planeTop = new Plane3d(planeRightTopPoint, nt); final Plane3d planeMiddleTop = new Plane3d(planeRightTopPoint, nmt); final Plane3d planeLeft = new Plane3d(planeLeftBottomPoint, nl); final Plane3d planeMiddleLeft = new Plane3d(planeLeftBottomPoint, nml); final Plane3d planeRight = new Plane3d(planeRightTopPoint, nr); final Plane3d planeMiddleRight = new Plane3d(planeRightTopPoint, nmr);
@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; }
Plane3d planeTop = new Plane3d(pp1, n);
Plane3d planeCenter = new Plane3d(planeRightCenterPoint, nt);