-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTile.java
More file actions
30 lines (24 loc) · 864 Bytes
/
Tile.java
File metadata and controls
30 lines (24 loc) · 864 Bytes
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
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.CullFace;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;
/**
* Makes a single square in 3D space of given size
*
* @author KW
*/
public class Tile extends MeshView {
public Tile(float size, PhongMaterial mat) {
TriangleMesh m = new TriangleMesh();
float[] points = { /* v0 */-size / 2, -size / 2, 0, /* v1 */size / 2, -size / 2, 0, /* v2 */size / 2, size / 2,
0, /* v3 */-size / 2, size / 2, 0 };
float[] texCoords = { /* t0 */0, 0, /* t1 */0, 1, /* t2 */1, 1, /* t3 */1, 0 };
int[] faces = { /* f0 */0, 0, 1, 1, 2, 2, /* f1 */0, 0, 2, 2, 3, 3 }; // merged
m.getPoints().setAll(points);
m.getTexCoords().setAll(texCoords);
m.getFaces().setAll(faces);
this.setCullFace(CullFace.FRONT);
this.setMesh(m);
this.setMaterial(mat);
}
}