-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlane.java
More file actions
60 lines (49 loc) · 2.1 KB
/
Plane.java
File metadata and controls
60 lines (49 loc) · 2.1 KB
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
import gmaths.*;
import com.jogamp.opengl.*;
public final class Plane {
private Model plane;
public Model initPlane(GL3 gl, Camera camera, Light light){
Mesh m = new Mesh(gl, vertices, indices);
Shader shader = new Shader(gl, "./shaders/vs_plane.txt", "./shaders/fs_plane.txt");
Material material = new Material(new Vec3(0.1f, 0.5f, 0.91f), new Vec3(0.0f, 0.5f, 0.91f), new Vec3(0.3f, 0.3f, 0.3f), 1.0f);
plane = new Model(gl, camera, light, shader, material, new Mat4(1), m);
return plane;
}
public Mat4 getMfloor(){
float size = 4f;
Mat4 modelMatrix = new Mat4(1);
modelMatrix = Mat4.multiply(Mat4Transform.scale(size,1f,size), modelMatrix);
return modelMatrix;
}
public Mat4 getMnorthWall(){
float size = 4f;
Mat4 modelMatrix = new Mat4(1);
modelMatrix = Mat4.multiply(Mat4Transform.scale(size,1f,size), modelMatrix);
modelMatrix = Mat4.multiply(Mat4Transform.rotateAroundX(90), modelMatrix);
modelMatrix = Mat4.multiply(Mat4Transform.translate(0,size*0.5f,-size*0.5f), modelMatrix);
return modelMatrix;
}
public Mat4 getMwestWall(){
float size = 4f;
Mat4 modelMatrix = new Mat4(1);
modelMatrix = Mat4.multiply(Mat4Transform.scale(size,1f,size), modelMatrix);
modelMatrix = Mat4.multiply(Mat4Transform.rotateAroundY(90), modelMatrix);
modelMatrix = Mat4.multiply(Mat4Transform.rotateAroundZ(-90), modelMatrix);
modelMatrix = Mat4.multiply(Mat4Transform.translate(-size*0.5f,size*0.5f,0), modelMatrix);
return modelMatrix;
}
// ***************************************************
/* THE DATA
*/
// anticlockwise/counterclockwise ordering
public static final float[] vertices = { // position, colour, tex coords
-0.5f, 0.0f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // top left
-0.5f, 0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, // bottom left
0.5f, 0.0f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom right
0.5f, 0.0f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f // top right
};
public static final int[] indices = { // Note that we start from 0!
0, 1, 2,
0, 2, 3
};
}