/** * Retrieves the texture coordinates of a given {@code (red, green, blue)} in the image of this {@link TextureColorPalette}. * @param red the red component, in the range {@code 0.0-1.0}. * @param green the green component, in the range {@code 0.0-1.0}. * @param blue the blue component, in the range {@code 0.0-1.0}. * @return the corresponding texture coordinates. */ public default float[] getTextureLocation(double red, double green, double blue) { return getTextureLocation((int) (255 * red), (int) (255 * green), (int) (255 * blue)); }
/** * @return the JavaFX {@link Material} to use with the generated material to enable the multi-color feature. */ public Material generateMaterial() { PhongMaterial material = new PhongMaterial(); material.setDiffuseMap(colorPalette.getColorPalette()); return material; }
/** * @return the JavaFX {@link Material} to use with the generated material to enable the multi-color feature. */ public Material generateMaterial() { PhongMaterial material = new PhongMaterial(); material.setDiffuseMap(colorPalette.getColorPalette()); return material; }
/** * Retrieves the texture coordinates of a given {@code (red, green, blue)} in the image of this {@link TextureColorPalette}. * @param red the red component, in the range {@code 0.0-1.0}. * @param green the green component, in the range {@code 0.0-1.0}. * @param blue the blue component, in the range {@code 0.0-1.0}. * @return the corresponding texture coordinates. */ public default float[] getTextureLocation(double red, double green, double blue) { return getTextureLocation((int) (255 * red), (int) (255 * green), (int) (255 * blue)); }
/** * Retrieves the texture coordinates of a given {@code (red, green, blue)} in the image of this {@link TextureColorPalette}. * @param red the red component, in the range {@code 0-255}. * @param green the green component, in the range {@code 0-255}. * @param blue the blue component, in the range {@code 0-255}. * @return the corresponding texture coordinates. */ public default float[] getTextureLocation(int red, int green, int blue) { return getTextureLocation(Color.rgb(red, green, blue)); }
/** * Retrieves the texture coordinates of a given {@code (red, green, blue)} in the image of this {@link TextureColorPalette}. * @param red the red component, in the range {@code 0-255}. * @param green the green component, in the range {@code 0-255}. * @param blue the blue component, in the range {@code 0-255}. * @return the corresponding texture coordinates. */ public default float[] getTextureLocation(int red, int green, int blue) { return getTextureLocation(Color.rgb(red, green, blue)); }
private MeshDataHolder setColor(MeshDataHolder input, Color color) { if (input == null) return null; Point3f[] vertices = input.getVertices(); int[] triangleIndices = input.getTriangleIndices(); Vector3f[] vertexNormals = input.getVertexNormals(); TexCoord2f[] inputTexturePoints = input.getTexturePoints(); TexCoord2f[] outputTexturePoints = new TexCoord2f[inputTexturePoints.length]; float[] textureLocation = colorPalette.getTextureLocation(color); for (int i = 0; i < inputTexturePoints.length; i++) outputTexturePoints[i] = new TexCoord2f(textureLocation); return new MeshDataHolder(vertices, outputTexturePoints, triangleIndices, vertexNormals); } }
/** * Add a 3D line to this builder. * @param x0 x-coordinate of the line start. * @param y0 y-coordinate of the line start. * @param z0 z-coordinate of the line start. * @param xf x-coordinate of the line end. * @param yf y-coordinate of the line end. * @param zf z-coordinate of the line end. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(float x0, float y0, float z0, float xf, float yf, float zf, float lineWidth, Color startColor, Color endColor) { MeshDataHolder lineMeshData = MeshDataGenerator.Line(x0, y0, z0, xf, yf, zf, lineWidth); float expectedDistance = 2.0f * lineWidth * lineWidth; Point3f[] vertices = lineMeshData.getVertices(); TexCoord2f[] texturePoints = lineMeshData.getTexturePoints(); Point3f start = new Point3f(x0, y0, z0); for (int i = 0; i < vertices.length; i++) { if (MathTools.epsilonEquals(vertices[i].distanceSquared(start), expectedDistance, 1.0e-5)) texturePoints[i].set(colorPalette.getTextureLocation(startColor)); else texturePoints[i].set(colorPalette.getTextureLocation(endColor)); } meshBuilder.addMesh(lineMeshData); }
private MeshDataHolder setColor(MeshDataHolder input, Color color) { if (input == null) return null; Point3D32[] vertices = input.getVertices(); int[] triangleIndices = input.getTriangleIndices(); Vector3D32[] vertexNormals = input.getVertexNormals(); TexCoord2f[] inputTexturePoints = input.getTexturePoints(); TexCoord2f[] outputTexturePoints = new TexCoord2f[inputTexturePoints.length]; float[] textureLocation = colorPalette.getTextureLocation(color); for (int i = 0; i < inputTexturePoints.length; i++) outputTexturePoints[i] = new TexCoord2f(textureLocation); return new MeshDataHolder(vertices, outputTexturePoints, triangleIndices, vertexNormals); } }
/** * Add a 3D line to this builder. * @param x0 x-coordinate of the line start. * @param y0 y-coordinate of the line start. * @param z0 z-coordinate of the line start. * @param xf x-coordinate of the line end. * @param yf y-coordinate of the line end. * @param zf z-coordinate of the line end. * @param lineWidth width of the line. * @param startColor color at the line start. Color accuracy depends on the color palette in use. * @param endColor color at the line end. Color accuracy depends on the color palette in use. */ public void addLine(float x0, float y0, float z0, float xf, float yf, float zf, float lineWidth, Color startColor, Color endColor) { MeshDataHolder lineMeshData = MeshDataGenerator.Line(x0, y0, z0, xf, yf, zf, lineWidth); Point3D32[] vertices = lineMeshData.getVertices(); TexCoord2f[] texturePoints = lineMeshData.getTexturePoints(); Point3D32 start = new Point3D32(x0, y0, z0); Point3D32 end = new Point3D32(xf, yf, zf); for (int i = 0; i < vertices.length; i++) { if (vertices[i].distanceSquared(start) < vertices[i].distanceSquared(end)) texturePoints[i].set(colorPalette.getTextureLocation(startColor)); else texturePoints[i].set(colorPalette.getTextureLocation(endColor)); } meshBuilder.addMesh(lineMeshData); }