Normand Briere
2018-07-03 02e145cb923d601395acc7f15ae9e13f85ef2fbb
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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
 
package mocap.scene;
 
import java.util.ArrayList;
 
import javax.media.j3d.Appearance;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.PolygonAttributes;
import javax.media.j3d.QuadArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
 
/**
 *
 * @author Michael Kipp
 */
 
public class Tiles extends Shape3D {
 
        private QuadArray _plane;
 
        public Tiles(ArrayList coords, Color3f col) {
            _plane = new QuadArray(coords.size(), GeometryArray.COORDINATES | GeometryArray.COLOR_3);
            createGeometry(coords, col);
            createAppearance();
        }
 
        private void createGeometry(ArrayList coords, Color3f col) {
            int numPoints = coords.size();
 
            Point3f[] points = new Point3f[numPoints];
            coords.toArray(points);
            _plane.setCoordinates(0, points);
 
            Color3f cols[] = new Color3f[numPoints];
            for (int i = 0; i < numPoints; i++) {
                cols[i] = col;
            }
            _plane.setColors(0, cols);
 
            setGeometry(_plane);
        }
 
        private void createAppearance() {
            Appearance app = new Appearance();
            PolygonAttributes pa = new PolygonAttributes();
            // so can see the Tiles from both sides
            pa.setCullFace(PolygonAttributes.CULL_NONE);
            // render only lines
            pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
            app.setPolygonAttributes(pa);
            setAppearance(app);
        }
    }