Geometry zAxis;
Geometry xzGrid;
Geometry xyGrid;
Geometry yzGrid;
ScenegraphNode coordNode = new ScenegraphNode("Coodination Grid");
ScenegraphNode labelNode = new ScenegraphNode("Grid labels");
coordNode.attachChild(labelNode);
// create x-axis
Arrow arrowX = new Arrow(new Vector3f(size, 0.0f, 0.0f));
xAxis = new Geometry("X-Axis", arrowX);
mat = new Material(am, Materials.UNSHADED);
mat.setColor("Color", ColorRGBA.Red);
xAxis.setMaterial(mat);
// create xy-grid
Grid xyPlane = new Grid(size, size, segSize);
xyGrid = new Geometry("XY-Plane", xyPlane);
xyGrid.setMaterial(mat);
xyGrid.rotateUpTo(new Vector3f(0.0f, 0.0f, 1.0f));
xyGrid.setLocalTranslation(new Vector3f(-offset, offset, 0.0f));
// create y-axis
Arrow arrowY = new Arrow(new Vector3f(0.0f, size, 0.0f));
yAxis = new Geometry("Y-Axis", arrowY);
mat = new Material(am, Materials.UNSHADED);
mat.setColor("Color", ColorRGBA.Green);
yAxis.setMaterial(mat);
// create yz-grid
Grid yzPlane = new Grid(size, size, segSize);
yzGrid = new Geometry("YZ-Plane", yzPlane);
yzGrid.setMaterial(mat);
yzGrid.rotateUpTo(new Vector3f(1.0f, 0.0f, 0.0f));
yzGrid.setLocalTranslation(new Vector3f(0.0f, offset, -offset));
// create z-axis
Arrow arrowZ = new Arrow(new Vector3f(0.0f, 0.0f, size));
zAxis = new Geometry("Z-Axis", arrowZ);
mat = new Material(am, Materials.UNSHADED);
mat.setColor("Color", ColorRGBA.Blue);
zAxis.setMaterial(mat);
// create xz-grid
Grid xzPlane = new Grid(size, size, segSize);
xzGrid = new Geometry("XZ-Plane", xzPlane);
xzGrid.setMaterial(mat);
xzGrid.rotateUpTo(new Vector3f(0.0f, 1.0f, 0.0f));
xzGrid.setLocalTranslation(new Vector3f(-offset, 0.0f, -offset));
// attach arrows to coordination node
coordNode.attachChild(xAxis);
coordNode.attachChild(yAxis);
coordNode.attachChild(zAxis);
// attach grids to coordination node
coordNode.attachChild(xyGrid);
coordNode.attachChild(xzGrid);
coordNode.attachChild(yzGrid);
Vector3f pos = new Vector3f(0, 0, 0);
BitmapText vertId = new BitmapText(guiFont);
vertId.setSize(.1f);
vertId.setText("x0, y0, z0");
vertId.setName("Gridlabel - x0, y0, z0");
vertId.setLocalTranslation(pos);
vertId.addControl(bc.cloneForSpatial(vertId));
labelNode.attachChild(vertId);
for (int x = 1; x < offset; x++) {
pos.set(x, 0, 0);
vertId = new BitmapText(guiFont);
vertId.setSize(.2f);
vertId.setText("x" + x);
vertId.setName("Gridlabel - x" + x);
vertId.setLocalTranslation(pos);
vertId.addControl(bc.cloneForSpatial(vertId));
labelNode.attachChild(vertId);
}
for (int y = 1; y < offset; y++) {
pos.set(0, y, 0);
vertId = new BitmapText(guiFont);
vertId.setSize(.2f);
vertId.setText("y" + y);
vertId.setName("Gridlabel - y" + y);
vertId.setLocalTranslation(pos);
vertId.addControl(bc.cloneForSpatial(vertId));
labelNode.attachChild(vertId);
}
for (int z = 1; z < offset; z++) {
pos.set(0, 0, z);
vertId = new BitmapText(guiFont);
vertId.setSize(.2f);
vertId.setText("z" + z);
vertId.setName("Gridlabel - z" + z);
vertId.setLocalTranslation(pos);
vertId.addControl(bc.cloneForSpatial(vertId));
labelNode.attachChild(vertId);
}
return coordNode;
}