]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor.java
e0bc5d0747229c3976dbd6c8fea09b26036122e5
[simantics/3d.git] / org.simantics.g3d.jme / src / org / simantics / g3d / jme / shape / AxesActor.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g3d.jme.shape;\r
13 \r
14 import com.jme3.app.Application;\r
15 import com.jme3.material.Material;\r
16 import com.jme3.math.ColorRGBA;\r
17 import com.jme3.math.Vector3f;\r
18 import com.jme3.scene.Geometry;\r
19 import com.jme3.scene.Mesh;\r
20 import com.jme3.scene.Node;\r
21 import com.jme3.scene.debug.Arrow;\r
22 \r
23 public class AxesActor extends Node {\r
24         \r
25         Application app;\r
26         \r
27         public AxesActor(Application app, double size) {\r
28                 this.app = app;\r
29                  putArrow(Vector3f.ZERO, Vector3f.UNIT_X.mult((float)size), ColorRGBA.Red);\r
30              putArrow(Vector3f.ZERO, Vector3f.UNIT_Y.mult((float)size), ColorRGBA.Green);\r
31              putArrow(Vector3f.ZERO, Vector3f.UNIT_Z.mult((float)size), ColorRGBA.Blue);\r
32         }\r
33         \r
34         public Geometry putShape(Mesh shape, ColorRGBA color){\r
35         Geometry g = new Geometry("shape", shape);\r
36         Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");\r
37         mat.getAdditionalRenderState().setWireframe(true);\r
38         mat.setColor("Color", color);\r
39         g.setMaterial(mat);\r
40         this.attachChild(g);\r
41         return g;\r
42     }\r
43 \r
44     public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color){\r
45         Arrow arrow = new Arrow(dir);\r
46         arrow.setLineWidth(4); // make arrow thicker\r
47         putShape(arrow, color).setLocalTranslation(pos);\r
48     }\r
49 \r
50 }\r