]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/DualHeadArrowActor.java
Yesterdays change introduced infinite loop for directed path leg updates
[simantics/3d.git] / org.simantics.g3d.jme / src / org / simantics / g3d / jme / shape / DualHeadArrowActor.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 DualHeadArrowActor extends Node {\r
26         \r
27         Application app;\r
28         \r
29         public DualHeadArrowActor(Application app, String name, Vector3d v) {\r
30                 this.app = app;\r
31                 Vector3f vec = new Vector3f((float)(v.x*0.5), (float)(v.y*0.5), (float)(v.z*0.5));\r
32                 Vector3f vecN = new Vector3f(vec);\r
33                 vecN.negate();\r
34                 putArrow(vec, vec, ColorRGBA.Red);\r
35                 putArrow(vec, vecN, ColorRGBA.Red);\r
36             \r
37         }\r
38         \r
39         public Geometry putShape(Mesh shape, ColorRGBA color){\r
40         Geometry g = new Geometry("shape", shape);\r
41         Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");\r
42         mat.getAdditionalRenderState().setWireframe(true);\r
43         mat.setColor("Color", color);\r
44         g.setMaterial(mat);\r
45         this.attachChild(g);\r
46         return g;\r
47     }\r
48 \r
49     public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color){\r
50         Arrow arrow = new Arrow(dir);\r
51         arrow.setLineWidth(4); // make arrow thicker\r
52         putShape(arrow, color).setLocalTranslation(pos);\r
53     }\r
54 \r
55 }\r