Normand Briere
2018-07-07 09ddd38fd4a8a7100c834a5e976f4796fae53541
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mocap.figure;
 
import javax.media.j3d.Switch;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3d;
 
import com.sun.j3d.utils.geometry.Box;
import com.sun.j3d.utils.geometry.Sphere;
 
import j3d.Util;
import mocap.scene.CoordCross;
 
/**
 * Joint geometry consists of a geometric representation of the joint itself (a sphere, a cube).
 * 
 * @author Michael Kipp
 */
public class JointGeom
{
 
   public static final int NONE = -1, CROSS = 0, SPHERE_SMALL = 1,
           SPHERE_BIG = 2, CUBE = 3;
   private static final float SIZE_CROSS = .2f;
   private static final float SIZE_SPHERE_SMALL = .1f;
   private static final float SIZE_SPHERE_BIG = .005f;
   private static final float SIZE_CUBE = .03f;
   private Switch _switch;
 
   public JointGeom(TransformGroup parent, float radius)
   {
       _switch = new Switch();
       _switch.setCapability(Switch.ALLOW_SWITCH_WRITE);
 
       // option 1: cross
//        _switch.addChild(new CoordCross(SIZE_CROSS).getRoot());
 
       // option 2: small sphere
       Sphere s = new Sphere(radius); // SIZE_SPHERE_SMALL);
//        _switch.addChild(s);
 
       // option 3: big sphere
       s = new Sphere(radius); // SIZE_SPHERE_BIG);
 
       // option 4: cube
       //        Box b = new Box(SIZE_CUBE, SIZE_CUBE, SIZE_CUBE, JointAppearance.getInstance());
       Box box = new Box(radius, radius, radius, JointAppearance.getInstance());
//        _switch.addChild(box);
 
       select(SPHERE_BIG); // initial selection
       parent.addChild(s);
                
////        parent.addChild(_switch);
////        _switch.addChild(s);
   }
 
   ////    public void detach() {
   ////        ((TransformGroup)_switch.getParent()).removeChild(_switch);
   ////    }
 
   public void select(int style)
   {
       _switch.setWhichChild(style == NONE ? Switch.CHILD_NONE : style);
   }
 
}