Normand Briere
2018-05-22 42107f9a01652cb2f47228d20c1148a2a22f6a63
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
package mocap.figure;
 
import javax.media.j3d.Appearance;
import javax.media.j3d.Material;
 
/**
 * Singleton class to give out appearances for "selected" and "normal"
 * nodes.
 * 
 * @author Michael Kipp
 */
public class JointAppearance extends Appearance {
 
    private static final JointAppearance INSTANCE = new JointAppearance();
    private static final JointAppearance SELECTED_INSTANCE = new JointAppearance(true);
    
    private JointAppearance() {
        super();
        setMaterial(makeMaterial(.5f, .5f, .5f));
    }
    
    private JointAppearance(boolean sel) {
        super();
        if (sel) 
            setMaterial(makeMaterial(1f, .5f, .5f));
        else 
            setMaterial(makeMaterial(.5f, .5f, .5f));
    }
    
    public static JointAppearance getInstance() {
        return INSTANCE;
    }
    
    public static JointAppearance getSelectedInstance() {
        return SELECTED_INSTANCE;
    }
    
    private Material makeMaterial(float r, float g, float b) {
        Material mat = new Material();
        mat.setDiffuseColor(r, g, b);
        mat.setSpecularColor(1f,.3f,.3f);
        mat.setShininess(20);
        mat.setLightingEnable(true);
        return mat;
    }
}