Code: Select all
double [][] vertices1 = new double[][] {
{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
double [][] vertices2 = new double[][] {
{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}};
double [][] vertices3 = new double[][] {
{0, 0, 0}, {0, 3, 0}, {3, 0, 0}, {3, 3, 0}};
double[][][] vertices = new double[3][][];
vertices[0] = vertices1;
vertices[1] = vertices2;
vertices[2] = vertices3;
Here is the code I created from "geom" tutorials.
1. I took each group of points from the set of groups of points and then created PointSetFactory for that group.
Code: Select all
factory = new PointSetFactory();
factory.setVertexCount(vertexCount);
factory.setVertexCoordinates(points);
factory.update();
2. Then I set up appearance and labels for this group of points
Here,
ps: PointSet
cmp: SceneGraphComponent
Code: Select all
label(ps, points);
Appearance a = new Appearance();
cmp.setAppearance(a);
cmp.setGeometry(ps);
DefaultGeometryShader dgs = ShaderUtility.createDefaultGeometryShader(
a, false);
DefaultPointShader dps = (DefaultPointShader) dgs.getPointShader();
dps.setDiffuseColor(color);
dgs.setShowFaces(false);
dgs.setShowLines(false);
dgs.setShowPoints(true);
DefaultTextShader pts = (DefaultTextShader) dps.getTextShader();
pts.setDiffuseColor(Color.blue);
Double scale = new Double(0.01);
pts.setScale(.75 * scale);
double[] offset = new double[] { -.1, 0, 0.3 };
pts.setOffset(offset);
pts.setAlignment(SwingConstants.NORTH_WEST);
Font f = new Font("SansSerif", Font.PLAIN, 20);
pts.setFont(f);
Here the label() method is:
Code: Select all
int n = ps.getNumPoints();
ps.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray();
String[] labels = new String[n];
for (int i = 0; i < n; i++)
labels[i] = "[" + points[i][0] + ", " + points[i][1] + ", " + points[i][2] + "]";
ps.setVertexAttributes(Attribute.LABELS,
StorageModel.STRING_ARRAY.createReadOnly(labels));
Code: Select all
root.addChild(node);
Code: Select all
JRViewer.display(root);
Thanks,
Karuna