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