public static int[][] addVertexToMeshFactory(MeshFactory meshFactory, Point3d[][] mesh, int pointCount, int crossCount) { int[][] pointsIntex = new int[pointCount][]; for (int i = 0; i < pointCount; i++) { pointsIntex[i] = new int[crossCount]; for (int j = 0; j < crossCount; j++) { Point3d p = mesh[i][j]; int ip = meshFactory.addVertex(p); pointsIntex[i][j] = ip; } } return pointsIntex; }
private static int cachePointIndex(Point2d point, int pointIndex, double height, Integer[] pointsIndexCache, MeshFactory meshBorder) { if (pointsIndexCache[pointIndex] == null) { pointsIndexCache[pointIndex] = meshBorder.addVertex(new Point3d(point.x, height, -point.y)); } return pointsIndexCache[pointIndex]; }
private static int segmentPointToVertex3dIndex(Point2d point, Point2d start, Vector2d direction, MeshFactory mesh) { Point3d vertex = new Point3d(direction.x, 0, -direction.y); vertex.scale(point.x); vertex.x += start.x; vertex.z -= start.y; vertex.y = point.y; int iV = mesh.addVertex(vertex); return iV; }
int vi = pMeshRoof.addVertex(new Point3d(point2d.x, h, -point2d.y));
int ps1it = meshBorder.addVertex(new Point3d(ps1.x, max_height, -ps1.y)); int ps2it = meshBorder.addVertex(new Point3d(ps2.x, max_height, -ps2.y)); int ps1ib = meshBorder.addVertex(new Point3d(ps1.x, min_height, -ps1.y)); int ps2ib = meshBorder.addVertex(new Point3d(ps2.x, min_height, -ps2.y)); Point2d pe2 = simpleOutLine[i]; int pe1it = meshBorder.addVertex(new Point3d(pe1.x, max_height, -pe1.y)); int pe2it = meshBorder.addVertex(new Point3d(pe2.x, max_height, -pe2.y)); int pe1ib = meshBorder.addVertex(new Point3d(pe1.x, min_height, -pe1.y)); int pe2ib = meshBorder.addVertex(new Point3d(pe2.x, min_height, -pe2.y));
int wbi1 = meshWalls.addVertex(new Point3d(beginPoint.x + borderX, 0.0d, -(beginPoint.y + borderY))); int wbi2 = meshWalls.addVertex(new Point3d(beginPoint.x + normX, 0.1d, -(beginPoint.y + normY))); int wbi3 = meshWalls.addVertex(new Point3d(beginPoint.x, 0.15d, -beginPoint.y)); int wbi4 = meshWalls.addVertex(new Point3d(beginPoint.x - normX, 0.1d, -(beginPoint.y - normY))); int wbi5 = meshWalls.addVertex(new Point3d(beginPoint.x - borderX, 0.0d, -(beginPoint.y - borderY))); int wei1 = meshWalls.addVertex(new Point3d(endPoint.x + borderX, 0.0d, -(endPoint.y + borderY))); int wei2 = meshWalls.addVertex(new Point3d(endPoint.x + normX, 0.1d, -(endPoint.y + normY))); int wei3 = meshWalls.addVertex(new Point3d(endPoint.x, 0.15d, -endPoint.y)); int wei4 = meshWalls.addVertex(new Point3d(endPoint.x - normX, 0.1d, -(endPoint.y - normY))); int wei5 = meshWalls.addVertex(new Point3d(endPoint.x - borderX, 0.0d, -(endPoint.y - borderY)));
Double startHeight = getHeight(0, pHeights); int startMi = pMeshBorder.addVertex(new Point3d(start.x, startHeight + pMinHeight, -start.y)); int startHi = pMeshBorder.addVertex(new Point3d(start.x, startHeight + pHeight, -start.y)); Double endHeight = getHeight(i, pHeights); int endMi = pMeshBorder.addVertex(new Point3d(end.x, endHeight + pMinHeight, -end.y)); int endHi = pMeshBorder.addVertex(new Point3d(end.x, endHeight + pHeight, -end.y));
/** * @param meshBorder * @param polygons */ public void solidToModel(MeshFactory meshBorder, ArrayList<Polygon> polygons) { for (Polygon polygon : polygons) { Vertex[] vertices = polygon.getVertices(); FaceFactory faceRight = meshBorder.addFace(FaceType.TRIANGLE_FAN); meshBorder.addTextCoord(new TextCoord(0.5, 0.5)); for (Vertex vertex : vertices) { kendzi.math.geometry.Bool.CSG.Vector pos = vertex.getPos(); Vector normal = vertex.getNormal(); int vi = meshBorder.addVertex(new Point3d(pos.x, pos.y, pos.z)); int ni = meshBorder.addNormal(new Vector3d(normal.x, normal.y, normal.z)); faceRight.addVert(vi, 0, ni); } } }
/** * @param pMeshRoof * @param pPlane * @param pTextureVector * @param pTextureData * @param textureOffsetU * @param textureOffsetV * @param normalIndex * @param face * @param point2d */ private static void addPointToTriangleFace(MeshFactory pMeshRoof, Plane3d pPlane, Vector3d pTextureVector, TextureData pTextureData, double textureOffsetU, double textureOffsetV, int normalIndex, FaceFactory face, Point2d point2d) { double h = pPlane.calcYOfPlane(point2d.x, -point2d.y); Point3d point3d = new Point3d(point2d.x, h, -point2d.y); int vi = pMeshRoof.addVertex(point3d); // Point3d point3d = pMeshRoof.vertices.get(vi); face.addVertIndex(vi); face.addNormalIndex(normalIndex); TextCoord calcUV = TextCordFactory.calcFlatSurfaceUV(point3d, pPlane.getNormal(), pTextureVector, pPlane.getPoint(), pTextureData, textureOffsetU, textureOffsetV); int tci = pMeshRoof.addTextCoord(calcUV); face.addCoordIndex(tci); }
border.hasTexture = true; int b01 = border.addVertex(new Point3d(-0.5 * width1, 0, 0)); int b12 = border.addVertex(new Point3d(0, h1, 0)); int b03 = border.addVertex(new Point3d(0.5 * width1, 0, 0)); int b04 = border.addVertex(new Point3d(0.5 * width1, 0, -d)); int b15 = border.addVertex(new Point3d(0, h1, -d)); int b06 = border.addVertex(new Point3d(-0.5 * width1, 0, -d)); Point3d p7 = new Point3d(0.5 * width1, 0, -d); int t1 = top.addVertex(p1); int t25 = top.addVertex(p25); int t38 = top.addVertex(p38); int t4 = top.addVertex(p4); int t6 = top.addVertex(p6); int t7 = top.addVertex(p7);
int nd = mf.addNormal(new Vector3d(0, -1, 0)); int ruf = mf.addVertex(new Point3d(x + sx, y + sy, z + sz)); int rub = mf.addVertex(new Point3d(x + sx, y + sy, z - sz)); int rdf = mf.addVertex(new Point3d(x + sx, y - sy, z + sz)); int rdb = mf.addVertex(new Point3d(x + sx, y - sy, z - sz)); int luf = mf.addVertex(new Point3d(x - sx, y + sy, z + sz)); int lub = mf.addVertex(new Point3d(x - sx, y + sy, z - sz)); int ldf = mf.addVertex(new Point3d(x - sx, y - sy, z + sz)); int ldb = mf.addVertex(new Point3d(x - sx, y - sy, z - sz));
border.hasTexture = true; int b01 = border.addVertex(new Point3d(-0.5 * width1, 0, 0)); int b11 = border.addVertex(new Point3d(-0.5 * width1, h1, 0)); int b02 = border.addVertex(new Point3d(0.5 * width1, 0, 0)); int b12 = border.addVertex(new Point3d(0.5 * width1, h1, 0)); int b03 = border.addVertex(new Point3d(0.5 * width1, 0, -d)); int b13 = border.addVertex(new Point3d(0.5 * width1, h2, -d)); int b04 = border.addVertex(new Point3d(-0.5 * width1, 0, -d)); int b14 = border.addVertex(new Point3d(-0.5 * width1, h2, -d)); Point3d p4 = new Point3d(-0.5 * width1, h2, -d); int t1 = top.addVertex(p1); int t2 = top.addVertex(p2); int t3 = top.addVertex(p3); int t4 = top.addVertex(p4);