if ( ( GeometryArray.TEXTURE_COORDINATE_2 & ga.getVertexFormat() ) == GeometryArray.TEXTURE_COORDINATE_2 ) { texCoords = new float[ga.getVertexCount() * 2]; ga.getTextureCoordinates( 0, ga.getInitialTexCoordIndex( 0 ), texCoords ); for ( int i = 1; i < texCoords.length; i += 2 ) { texCoords[i] = 1 - texCoords[i];
/** * Draws a set of points at the given coordinates with the given colors. * For example, the first point is at (x[0], y[0], z[0]) with color colors[0]. * Much more efficient than drawing individual points. */ public static Shape points (double[] x, double[] y, double[] z, Color[] colors) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new PointArray(coords.length, PointArray.COORDINATES | PointArray.COLOR_4); geom.setCoordinates(0, coords); for (int i = 0; i < x.length; i++) geom.setColor(i, colors[i].getComponents(null)); Shape3D shape = createShape3D(geom); return customShape(shape); }
public Color4f getColorFor(final int _idxVertex) { final Color4f r = new Color4f(); ((GeometryArray) shape_.getGeometry()).getColor(_idxVertex, r); return r; }
/** * @param ga * @return */ private float[] getInterLeaved( GeometryArray ga ) { float[] result = null; if ( ( ga.getVertexFormat() & GeometryArray.INTERLEAVED ) == GeometryArray.INTERLEAVED ) { if ( ( ga.getVertexFormat() & GeometryArray.USE_NIO_BUFFER ) == GeometryArray.USE_NIO_BUFFER ) { Buffer b = ga.getInterleavedVertexBuffer().getBuffer(); if ( b instanceof ByteBuffer ) { result = ( (ByteBuffer) b ).asFloatBuffer().array(); } else if ( b instanceof FloatBuffer ) { result = ( (FloatBuffer) b ).array(); } } else { result = ga.getInterleavedVertices(); } } return result; }
public boolean getRange(final CtuluRange _b) { final GeometryArray geometrie = (GeometryArray) shape_.getGeometry(); final int nbPt = geometrie.getVertexCount(); _b.setToNill(); final double[] vs = new double[3]; for (int i = 0; i < nbPt; i++) { geometrie.getCoordinate(i, vs); _b.expandTo(vs[2]); } return true; }
private float[] exportCoords( GeometryArray ga, Transform3D transformation, double[] lower, double[] upper ) { float[] coords = new float[ga.getVertexCount() * 3]; ga.getCoordinates( ga.getInitialVertexIndex(), coords ); boolean doSceneTransform = ( transformation != null && transformation.getBestType() != Transform3D.IDENTITY ); for ( int i = 0; ( i + 2 ) < coords.length; i += 3 ) { Point3d coord = new Point3d( coords[i], coords[i + 1], coords[i + 2] ); // if ( doUserRotation ) { // userRotationMatrix.transform( coord ); // } if ( doSceneTransform ) { transformation.transform( coord ); } if ( doUserTransform ) { userMatrix.transform( coord ); } coords[i] = (float) coord.x; coords[i + 1] = (float) coord.y; coords[i + 2] = (float) coord.z; upper[0] = max( coords[i], upper[0] ); upper[1] = max( coords[i + 1], upper[1] ); upper[2] = max( coords[i + 2], upper[2] ); lower[0] = min( coords[i], lower[0] ); lower[1] = min( coords[i + 1], lower[1] ); lower[2] = min( coords[i + 2], lower[2] ); } return coords; }
/** * Draws a set of points at the given coordinates. For example, * the first point is at (x[0], y[0], z[0]). * Much more efficient than drawing individual points. */ public static Shape points (double[] x, double[] y, double[] z) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new PointArray(coords.length, PointArray.COORDINATES); geom.setCoordinates(0, coords); Shape3D shape = createShape3D(geom); return shape(shape); }
if ( !( ( GeometryArray.NORMALS & ga.getVertexFormat() ) == GeometryArray.NORMALS ) ) { GeometryInfo inf = new GeometryInfo( ga ); NormalGenerator ng = new NormalGenerator(); ng.generateNormals( inf ); normals = new float[ga.getVertexCount() * 3]; ga.getNormals( ga.getInitialVertexIndex(), normals ); double[] normal = new double[3]; boolean userTransform = doUserTransform;
/** * colore l'objet d'une couleur unique. */ public boolean setCouleur(final Color _c) { if (shape_ == null || shape_.getGeometry() == null) { return false; } isColorUsed_ = true; final int nbPts = ((GeometryArray) shape_.getGeometry()).getVertexCount(); shape_.getAppearance().getColoringAttributes().setColor(new Color3f(_c)); final Color4f[] cs = new Color4f[nbPts]; Arrays.fill(cs, new Color4f(_c)); ((GeometryArray) shape_.getGeometry()).setColors(0, cs); return true; }
int vertexCount = ga.getVertexCount(); if ( vertexCount == 0 ) { LOG.error( "No coordinates found in the geometryArray, this may not be." );
/** * Draws a set of connected lines. For example, the first line is from (x[0], y[0], z[0]) to * (x[1], y[1], z[1]), and the second line is from (x[1], y[1], z[1]) to (x[2], y[2], z[2]). * Much more efficient than drawing individual lines. */ public static Shape lines (double[] x, double[] y, double[] z) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new LineStripArray (coords.length, LineArray.COORDINATES, new int[] {coords.length}); geom.setCoordinates(0, coords); Shape3D shape = createShape3D(geom); return shape(shape); }
protected void calculeBBox(final GeometryArray _geometrie) { if (_geometrie == null) { return; } if (bbox_ == null) { bbox_ = new BoundingBox(); } final int compte = _geometrie.getVertexCount(); final Point3d pts = new Point3d(); for (int i = 0; i < compte; i++) { _geometrie.getCoordinate(i, pts); bbox_.combine(pts); } }
/** * Draws a set of points at the given coordinates with the given colors. * For example, the first point is at (x[0], y[0], z[0]) with color colors[0]. * Much more efficient than drawing individual points. */ public static Shape points (double[] x, double[] y, double[] z, Color[] colors) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new PointArray(coords.length, PointArray.COORDINATES | PointArray.COLOR_4); geom.setCoordinates(0, coords); for (int i = 0; i < x.length; i++) geom.setColor(i, colors[i].getComponents(null)); Shape3D shape = createShape3D(geom); return customShape(shape); }
/** * Draws a set of points at the given coordinates. For example, * the first point is at (x[0], y[0], z[0]). * Much more efficient than drawing individual points. */ public static Shape points (double[] x, double[] y, double[] z) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new PointArray(coords.length, PointArray.COORDINATES); geom.setCoordinates(0, coords); Shape3D shape = createShape3D(geom); return shape(shape); }
public void setPaletteCouleurPlages(final BPalettePlageInterface _newPlage) { isColorUsed_ = false; palette_ = new BPalettePlage(_newPlage.getPlages()); final GeometryArray geometrie = (GeometryArray) shape_.getGeometry(); final int nbPt = geometrie.getVertexCount(); final Color4f[] cs = new Color4f[nbPt]; final double[] vs = new double[3]; for (int i = 0; i < nbPt; i++) { geometrie.getCoordinate(i, vs); Color c = palette_.getColorFor(vs[2]); if (c == null) { c = new Color(1, 1, 1, 1); } cs[i] = new Color4f(c); } setCouleurs(cs); support_.firePropertyChange("paletteCouleur", null, palette_); }
/** * Draws a set of connected lines. For example, the first line is from (x[0], y[0], z[0]) to * (x[1], y[1], z[1]), and the second line is from (x[1], y[1], z[1]) to (x[2], y[2], z[2]). * Much more efficient than drawing individual lines. Vertex colors are specified by the given * array, and line colors are blends of its two vertex colors. */ public static Shape lines (double[] x, double[] y, double[] z, Color[] colors) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new LineStripArray (coords.length, LineArray.COORDINATES | LineArray.COLOR_4, new int[] {coords.length}); geom.setCoordinates(0, coords); for (int i = 0; i < x.length; i++) geom.setColor(i, colors[i].getComponents(null)); Shape3D shape = createShape3D(geom); return customShape(shape); }
/** * Draws a set of connected lines. For example, the first line is from (x[0], y[0], z[0]) to * (x[1], y[1], z[1]), and the second line is from (x[1], y[1], z[1]) to (x[2], y[2], z[2]). * Much more efficient than drawing individual lines. */ public static Shape lines (double[] x, double[] y, double[] z) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new LineStripArray (coords.length, LineArray.COORDINATES, new int[] {coords.length}); geom.setCoordinates(0, coords); Shape3D shape = createShape3D(geom); return shape(shape); }
/** * Draws a set of connected lines. For example, the first line is from (x[0], y[0], z[0]) to * (x[1], y[1], z[1]), and the second line is from (x[1], y[1], z[1]) to (x[2], y[2], z[2]). * Much more efficient than drawing individual lines. Vertex colors are specified by the given * array, and line colors are blends of its two vertex colors. */ public static Shape lines (double[] x, double[] y, double[] z, Color[] colors) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new LineStripArray (coords.length, LineArray.COORDINATES | LineArray.COLOR_4, new int[] {coords.length}); geom.setCoordinates(0, coords); for (int i = 0; i < x.length; i++) geom.setColor(i, colors[i].getComponents(null)); Shape3D shape = createShape3D(geom); return customShape(shape); }
/** * Draws a polygon with the given vertices, which is filled or outlined based on the argument. * * @param filled Is the polygon filled? */ private static Shape polygon (double[] x, double[] y, double[] z, boolean filled) { Point3f[] coords = constructPoint3f(x, y, z); GeometryArray geom = new TriangleFanArray(coords.length, LineArray.COORDINATES, new int[] {coords.length}); geom.setCoordinates(0, coords); GeometryInfo geoinfo = new GeometryInfo((GeometryArray)geom); NormalGenerator normalGenerator = new NormalGenerator(); normalGenerator.generateNormals(geoinfo); Shape3D shape = createShape3D(geoinfo.getIndexedGeometryArray()); if (filled) return shape(shape); else return wireShape(shape); }
private static Shape triangles (double[][] points, Color[] colors, boolean filled) { int size = points.length; Point3f[] coords = new Point3f[size*3]; for (int i = 0; i < size; i++) { coords[3*i] = new Point3f(createVector3f(points[i][0], points[i][1], points[i][2])); coords[3*i+1] = new Point3f(createVector3f(points[i][3], points[i][4], points[i][5])); coords[3*i+2] = new Point3f(createVector3f(points[i][6], points[i][7], points[i][8])); } GeometryArray geom = new TriangleArray(size*3, TriangleArray.COORDINATES | TriangleArray.COLOR_4); geom.setCoordinates(0, coords); for (int i = 0; i < colors.length; i++) { geom.setColor(3 * i + 0, colors[i].getComponents(null)); geom.setColor(3 * i + 1, colors[i].getComponents(null)); geom.setColor(3 * i + 2, colors[i].getComponents(null)); } GeometryInfo geoinfo = new GeometryInfo(geom); NormalGenerator normalGenerator = new NormalGenerator(); normalGenerator.generateNormals(geoinfo); Shape3D shape = createShape3D(geoinfo.getIndexedGeometryArray()); if (filled) return shape(shape); else return wireShape(shape); }