]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor.java
Alpha-version of jME-bindings for g3d.
[simantics/3d.git] / org.simantics.g3d.jme / src / org / simantics / g3d / jme / shape / AxesActor.java
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 (file)
index 0000000..05f15ee
--- /dev/null
@@ -0,0 +1,39 @@
+package org.simantics.g3d.jme.shape;\r
+\r
+import com.jme3.app.Application;\r
+import com.jme3.material.Material;\r
+import com.jme3.math.ColorRGBA;\r
+import com.jme3.math.Vector3f;\r
+import com.jme3.scene.Geometry;\r
+import com.jme3.scene.Mesh;\r
+import com.jme3.scene.Node;\r
+import com.jme3.scene.debug.Arrow;\r
+\r
+public class AxesActor extends Node {\r
+       \r
+       Application app;\r
+       \r
+       public AxesActor(Application app, double size) {\r
+               this.app = app;\r
+                putArrow(Vector3f.ZERO, Vector3f.UNIT_X.mult((float)size), ColorRGBA.Red);\r
+            putArrow(Vector3f.ZERO, Vector3f.UNIT_Y.mult((float)size), ColorRGBA.Green);\r
+            putArrow(Vector3f.ZERO, Vector3f.UNIT_Z.mult((float)size), ColorRGBA.Blue);\r
+       }\r
+       \r
+       public Geometry putShape(Mesh shape, ColorRGBA color){\r
+        Geometry g = new Geometry("shape", shape);\r
+        Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");\r
+        mat.getAdditionalRenderState().setWireframe(true);\r
+        mat.setColor("Color", color);\r
+        g.setMaterial(mat);\r
+        this.attachChild(g);\r
+        return g;\r
+    }\r
+\r
+    public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color){\r
+        Arrow arrow = new Arrow(dir);\r
+        arrow.setLineWidth(4); // make arrow thicker\r
+        putShape(arrow, color).setLocalTranslation(pos);\r
+    }\r
+\r
+}\r