use of org.scijava.java3d.TriangleArray in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method createShape.
@SuppressWarnings("unused")
private static Shape3D createShape(Builder settings) {
final LocalList<Point3f> points = new LocalList<>(1);
points.push(new Point3f());
// We try and match the geometry and appearance of the standard mesh.
// Do this by creating a mesh with a single point and get the Geometry and Appearance.
GeometryArray ga;
CustomMesh mesh;
final float transparency = getTransparency(settings);
// Support drawing as points ...
if (settings.getRendering() == 0) {
mesh = new TransparentItemPointMesh(points, null, transparency);
((ItemPointMesh) mesh).setPointSize((float) settings.getPixelSize());
updateAppearance(mesh, settings);
// Assume the TransparentItemPointMesh sets COLOR_4
ga = (GeometryArray) mesh.getGeometry();
} else {
final Rendering r = Rendering.forNumber(settings.getRendering());
final List<Point3f> point = Shape3DHelper.createLocalisationObject(r);
final Point3f[] vertices = point.toArray(new Point3f[1]);
// Correct the direction
ItemTriangleMesh.checkFacets(vertices);
final double creaseAngle = (r.isHighResolution()) ? 44 : 0;
mesh = new ItemTriangleMesh(vertices, points.toArray(new Point3f[1]), null, null, transparency, creaseAngle, null);
updateAppearance(mesh, settings);
final int nVertices = vertices.length;
ga = new TriangleArray(nVertices, GeometryArray.COORDINATES | GeometryArray.NORMALS);
// Copy the coords and normals. We don't require the vertex colours.
final float[] coords = new float[nVertices * 3];
final float[] normals = new float[nVertices * 3];
final GeometryArray gaToCopy = (GeometryArray) mesh.getGeometry();
gaToCopy.getCoordinates(0, coords);
gaToCopy.getNormals(0, normals);
ga.setCoordinates(0, coords);
ga.setNormals(0, normals);
ga.setValidVertexCount(nVertices);
}
return new Shape3D(ga, mesh.getAppearance());
}
Aggregations