@Override public void setColor(final Color3f color) { if (this.colors == null || this.colors.length != this.vertices.length) this.colors = new Color3f[this.vertices.length]; this.color = color != null ? color : DEFAULT_COLOR; for (int i = 0; i < nVertices; i++) colors[i] = this.color; final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; ga.setColors(0, colors); changed = true; }
@Override public void setColor(final List<Color3f> color) { if (color.size() != colors.length) throw new IllegalArgumentException( "Number of colors must equal number of vertices"); this.color = null; color.toArray(this.colors); final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; ga.setColors(0, colors); changed = true; }
public void setTransparentColor(final List<Color4f> color) { this.color = null; final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; final int N = ga.getValidVertexCount(); if (color.size() != N) throw new IllegalArgumentException("list of size " + N + " expected"); final Color4f[] colors = new Color4f[N]; color.toArray(colors); ga.setColors(0, colors); changed = true; }
public void setColor(final List<Color3f> color) { this.color = null; final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; final int N = ga.getValidVertexCount(); if (color.size() != N) throw new IllegalArgumentException("list of size " + N + " expected"); final Color3f[] colors = new Color3f[N]; color.toArray(colors); ga.setColors(0, colors); changed = true; }
public void setColor(final Color3f color) { this.color = color != null ? color : DEFAULT_COLOR; final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; final int N = ga.getVertexCount(); final Color3f colors[] = new Color3f[N]; for (int i = 0; i < N; i++) { colors[i] = this.color; } ga.setColors(0, colors); changed = true; }
@Override public void setColor(final Color3f color) { this.color = color != null ? color : DEFAULT_COLOR; final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; final int N = ga.getVertexCount(); final Color4f colors[] = new Color4f[N]; for (int i = 0; i < N; i++) { colors[i] = new Color4f(this.color.x, this.color.y, this.color.z, 1); } ga.setColors(0, colors); changed = true; }
protected void addVerticesToGeometryArray(final Point3f[] v) { changed = true; mesh.addAll(Arrays.asList(v)); // check maximum vertex count final GeometryArray ga = (GeometryArray) getGeometry(); final int max = ga.getVertexCount(); final int idx = ga.getValidVertexCount(); if (idx + v.length > max) { // enlarge arrays setGeometry(createGeometry()); return; } ga.setValidVertexCount(idx + v.length); ga.setCoordinates(idx, v); // update colors final Color3f[] colors = new Color3f[v.length]; Arrays.fill(colors, this.color); ga.setColors(idx, colors); recalculateNormals(ga); }
ta.setColors(0, colors);
ta.setColors(0, colors);
ta.setColors(0, colors);
@Override public void loadSurfaceColorsFromImage(ImagePlus imp) { if (imp.getType() != ImagePlus.COLOR_RGB) { imp = new Duplicator().run(imp); new StackConverter(imp).convertToRGB(); } final InterpolatedImage ii = new InterpolatedImage(imp); final Calibration cal = imp.getCalibration(); final double pw = cal.pixelWidth; final double ph = cal.pixelHeight; final double pd = cal.pixelDepth; for (int i = 0; i < nVertices; i++) { final Point3f coord = vertices[i]; final int v = (int) Math.round(ii.interpol.get(coord.x / pw, coord.y / ph, coord.z / pd)); colors[i] = new Color3f(((v & 0xff0000) >> 16) / 255f, ((v & 0xff00) >> 8) / 255f, (v & 0xff) / 255f); } final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; ga.setColors(0, colors); changed = true; }
ta.setColors(0, colors);
ta.setColors(0, colors);
public void loadSurfaceColorsFromImage(ImagePlus imp) { final GeometryArray ga = (GeometryArray) getGeometry(); if (ga == null) return; if (imp.getType() != ImagePlus.COLOR_RGB) { imp = new Duplicator().run(imp); new StackConverter(imp).convertToRGB(); } final InterpolatedImage ii = new InterpolatedImage(imp); final int N = ga.getValidVertexCount(); final Color3f[] colors = new Color3f[N]; final Calibration cal = imp.getCalibration(); final double pw = cal.pixelWidth; final double ph = cal.pixelHeight; final double pd = cal.pixelDepth; final Point3f coord = new Point3f(); for (int i = 0; i < N; i++) { ga.getCoordinate(i, coord); final int v = (int) Math.round(ii.interpol.get(coord.x / pw, coord.y / ph, coord.z / pd)); colors[i] = new Color3f(((v & 0xff0000) >> 16) / 255f, ((v & 0xff00) >> 8) / 255f, (v & 0xff) / 255f); } ga.setColors(0, colors); changed = true; }