]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d.jme/src/org/simantics/g3d/jme/shape/AxesActor2.java
Calculating turn specific coordinates
[simantics/3d.git] / org.simantics.g3d.jme / src / org / simantics / g3d / jme / shape / AxesActor2.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.AxisAngle4d;\r
15 import javax.vecmath.Vector3d;\r
16 \r
17 import org.simantics.g3d.math.MathTools;\r
18 import org.simantics.g3d.shape.Color4d;\r
19 import org.simantics.g3d.shape.Cone;\r
20 import org.simantics.g3d.shape.Cylinder;\r
21 import org.simantics.g3d.shape.Sphere;\r
22 \r
23 import com.jme3.app.Application;\r
24 \r
25 public class AxesActor2 extends MeshNode {\r
26         \r
27         public AxesActor2(Application app, double size) {\r
28                 super(app);\r
29                 \r
30                 int res = 16;\r
31                 \r
32                 org.simantics.g3d.shape.Mesh cone_x = Cone.create(size*0.3, res);\r
33                 org.simantics.g3d.shape.Mesh cone_y = Cone.create(size*0.3, res);\r
34                 org.simantics.g3d.shape.Mesh cone_z = Cone.create(size*0.3, res);\r
35                 cone_x.rotate(MathTools.getQuat(new AxisAngle4d(0,0,-1,Math.PI*0.5)));\r
36                 cone_z.rotate(MathTools.getQuat(new AxisAngle4d(1,0,0,Math.PI*0.5)));\r
37                 cone_x.translate(new Vector3d(size,0,0));\r
38                 cone_y.translate(new Vector3d(0,size,0));\r
39                 cone_z.translate(new Vector3d(0,0,size));\r
40                 \r
41                 org.simantics.g3d.shape.Mesh tube_x = Cylinder.create(MathTools.ORIGIN, new Vector3d(size,0,0), size*0.1, res);\r
42                 org.simantics.g3d.shape.Mesh tube_y = Cylinder.create(MathTools.ORIGIN, new Vector3d(0,size,0), size*0.1, res);\r
43                 org.simantics.g3d.shape.Mesh tube_z = Cylinder.create(MathTools.ORIGIN, new Vector3d(0,0,size), size*0.1, res);\r
44                 \r
45                 org.simantics.g3d.shape.Mesh sphere = Sphere.create(size*0.3, res, res*2/3);\r
46                 \r
47                 Color4d x_col = new Color4d(1,0,0,1);\r
48                 Color4d y_col = new Color4d(1,1,0,1);\r
49                 Color4d z_col = new Color4d(0,1,0,1);\r
50                 Color4d o_col = new Color4d(0,0,1,1);\r
51                 \r
52                 cone_x.setColor(x_col);\r
53                 tube_x.setColor(x_col);\r
54                 cone_y.setColor(y_col);\r
55                 tube_y.setColor(y_col);\r
56                 cone_z.setColor(z_col);\r
57                 tube_z.setColor(z_col);\r
58                 sphere.setColor(o_col);\r
59                 \r
60                 sphere.add(cone_x);\r
61                 sphere.add(tube_x);\r
62                 sphere.add(cone_y);\r
63                 sphere.add(tube_y);\r
64                 sphere.add(cone_z);\r
65                 sphere.add(tube_z);\r
66                 \r
67                 setMesh(sphere);\r
68         }\r
69         \r
70         \r
71 }\r