]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxisActor.java
a4cd903954c6267f2d17a93e64469eec03a8a39c
[simantics/3d.git] / org.simantics.g3d.jme / src / org / simantics / g3d / jme / shape / AxisActor.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 javax.vecmath.Vector3d;\r
15 \r
16 import com.jme3.app.Application;\r
17 import com.jme3.material.Material;\r
18 import com.jme3.math.ColorRGBA;\r
19 import com.jme3.math.Vector3f;\r
20 import com.jme3.scene.Geometry;\r
21 import com.jme3.scene.Mesh;\r
22 import com.jme3.scene.Node;\r
23 import com.jme3.scene.debug.Arrow;\r
24 \r
25 public class AxisActor extends Node {\r
26         \r
27         Application app;\r
28         \r
29         public AxisActor(Application app, String name, Vector3d v) {\r
30                 this.app = app;\r
31                 Vector3f vec = new Vector3f((float)v.x, (float)v.y, (float)v.z);\r
32                 putArrow(Vector3f.ZERO, vec, ColorRGBA.Red);\r
33             \r
34         }\r
35         \r
36         public Geometry putShape(Mesh shape, ColorRGBA color){\r
37         Geometry g = new Geometry("shape", shape);\r
38         Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");\r
39         mat.getAdditionalRenderState().setWireframe(true);\r
40         mat.setColor("Color", color);\r
41         g.setMaterial(mat);\r
42         this.attachChild(g);\r
43         return g;\r
44     }\r
45 \r
46     public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color){\r
47         Arrow arrow = new Arrow(dir);\r
48         arrow.setLineWidth(4); // make arrow thicker\r
49         putShape(arrow, color).setLocalTranslation(pos);\r
50     }\r
51 \r
52 }\r