jMonkeyEngine3 – add the 3D axes

Call this method in the public void simpleInitApp() method

private void attachCoordinateAxes(Vector3f pos) {
 Arrow arrow = new Arrow(Vector3f.UNIT_X);
 arrow.setLineWidth(4); // make arrow thicker
 putShape(arrow, ColorRGBA.Red).setLocalTranslation(pos);

 arrow = new Arrow(Vector3f.UNIT_Y);
 arrow.setLineWidth(4); // make arrow thicker
 putShape(arrow, ColorRGBA.Green).setLocalTranslation(pos);

 arrow = new Arrow(Vector3f.UNIT_Z);
 arrow.setLineWidth(4); // make arrow thicker
 putShape(arrow, ColorRGBA.Blue).setLocalTranslation(pos);
 }

private Geometry putShape(Mesh shape, ColorRGBA color) {
 Geometry g = new Geometry("coordinate axis", shape);
 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
 mat.getAdditionalRenderState().setWireframe(true);
 mat.setColor("Color", color);
 g.setMaterial(mat);
 rootNode.attachChild(g);
 return g;
 }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s