public void translate(Tuple3DReadOnly translation) { for (Point3D32 vertex : vertices) vertex.add(translation); }
private static void translateMeshVertices(MeshDataHolder meshToModify, Tuple3DReadOnly offset) { Point3D32 offset3f = new Point3D32(offset); for (Point3D32 vertex : meshToModify.getVertices()) vertex.add(offset3f); }
/** * Update the meshes of this generator to represent a cloud of sphere located at the given * locations. * <p> * The resulting meshes can be obtained using {@link #getMeshDataHolders()}. * </p> * * @param pointLocations the positions for each sphere. * @throws RuntimeException if {@code pointLocations.length != this.getNumberOfPoints()}. */ public void compute(Point3DReadOnly[] pointLocations) { if (pointLocations.length != meshDataHolders.length) throw new RuntimeException("Unexpected array size. Expected: " + meshDataHolders.length + ", but was: " + pointLocations.length); for (int i = 0; i < meshDataHolders.length; i++) { Point3DReadOnly center = pointLocations[i]; Point3D32[] pointVertices = meshDataHolders[i].getVertices(); Point3D32[] templateVertices = pointTemplate.getVertices(); for (int vertexIndex = 0; vertexIndex < pointVertices.length; vertexIndex++) { pointVertices[vertexIndex].add(templateVertices[vertexIndex], center); } } }
/** * Utility method to translate a given mesh using a given translation. * @param input the mesh to translate. Not modified. * @param offsetX translation along the x-axis to apply to the mesh. * @param offsetY translation along the y-axis to apply to the mesh. * @param offsetZ translation along the z-axis to apply to the mesh. * @return the translated mesh. */ public static MeshDataHolder translate(MeshDataHolder input, float offsetX, float offsetY, float offsetZ) { Point3D32[] inputVertices = input.getVertices(); TexCoord2f[] texturePoints = input.getTexturePoints(); int[] triangleIndices = input.getTriangleIndices(); Vector3D32[] normals = input.getVertexNormals(); Point3D32[] outputVertices = new Point3D32[inputVertices.length]; for (int i = 0; i < inputVertices.length; i++) { outputVertices[i] = new Point3D32(offsetX, offsetY, offsetZ); outputVertices[i].add(inputVertices[i]); } return new MeshDataHolder(outputVertices, texturePoints, triangleIndices, normals); }