-
Notifications
You must be signed in to change notification settings - Fork 0
/
WalkAround3D.pde
67 lines (58 loc) · 1.11 KB
/
WalkAround3D.pde
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
67
/*
Emanuel W.
Nov 22, 2018
*/
final int[] gridSize = new int[] { 30, 30 };
final float maxLookY = 45;
final float distScale = .125;
int VISIBLE = 25;
TextureManager tm;
Gallary g;
void setup() {
tm = new TextureManager();
size(800, 640, P3D);
colorMode(RGB, 1);
strokeWeight(1);
g = new Gallary(gridSize);
frustum(-float(width)/height*distScale, float(width)/height*distScale, distScale, -distScale, 2*distScale, VISIBLE);
resetMatrix();
}
void draw() {
background(0, 0, 0.1);
g.updateLook();
g.draw();
}
void mouseMoved() {
g.lookAngle[1] += -(pmouseX - mouseX);
g.lookAngle[0] += -(pmouseY - mouseY);
if (g.lookAngle[0] > maxLookY)
g.lookAngle[0] = maxLookY;
else if (g.lookAngle[0] < -maxLookY)
g.lookAngle[0] = -maxLookY;
}
void keyPressed() {
switch (key) {
case 'w':
g.moveForward();
break;
case 'a':
g.lookRight();
break;
case 's':
g.moveBackward();
break;
case 'd':
g.lookLeft();
break;
}
}
void keyReleased() {
switch (key) {
case 'w':
g.stopForward();
break;
case 's':
g.stopBackward();
break;
}
}