X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.jme%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fjme%2Fshape%2FAxesActor.java;fp=org.simantics.g3d.jme%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fjme%2Fshape%2FAxesActor.java;h=05f15ee103774b65a0b116b7d86d3be2776a6feb;hb=5b4454ce3dac8d0cf04caaaa696f300c16be99a0;hp=0000000000000000000000000000000000000000;hpb=2e9c37990c979fe7a877a6a9d0de65ee27f3b56f;p=simantics%2F3d.git diff --git a/org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor.java b/org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor.java new file mode 100644 index 00000000..05f15ee1 --- /dev/null +++ b/org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor.java @@ -0,0 +1,39 @@ +package org.simantics.g3d.jme.shape; + +import com.jme3.app.Application; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.debug.Arrow; + +public class AxesActor extends Node { + + Application app; + + public AxesActor(Application app, double size) { + this.app = app; + putArrow(Vector3f.ZERO, Vector3f.UNIT_X.mult((float)size), ColorRGBA.Red); + putArrow(Vector3f.ZERO, Vector3f.UNIT_Y.mult((float)size), ColorRGBA.Green); + putArrow(Vector3f.ZERO, Vector3f.UNIT_Z.mult((float)size), ColorRGBA.Blue); + } + + public Geometry putShape(Mesh shape, ColorRGBA color){ + Geometry g = new Geometry("shape", shape); + Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); + mat.getAdditionalRenderState().setWireframe(true); + mat.setColor("Color", color); + g.setMaterial(mat); + this.attachChild(g); + return g; + } + + public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color){ + Arrow arrow = new Arrow(dir); + arrow.setLineWidth(4); // make arrow thicker + putShape(arrow, color).setLocalTranslation(pos); + } + +}