-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTable.pde
83 lines (63 loc) · 1.93 KB
/
Table.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class TableF {
PImage tableImg;
float tableSizeX, tableSizeY, tableSizeZ;
float legWidth, legHeight;
PShape backLeftLeg, backRightLeg, frontLeftLeg, frontRightLeg, tableShape;
Collider cl1;
TableF() {
tableImg = loadImage("table.jpg");
tableSizeX = 1;
tableSizeY = 0.25;
tableSizeZ = 2;
legWidth = 0.25;
legHeight = 1.5;
noStroke();
backLeftLeg = createShape(BOX, legWidth, legHeight, legWidth);
backLeftLeg.setTexture(tableImg);
backRightLeg = createShape(BOX, legWidth, legHeight, legWidth);
backRightLeg.setTexture(tableImg);
frontLeftLeg = createShape(BOX, legWidth, legHeight, legWidth);
frontLeftLeg.setTexture(tableImg);
frontRightLeg = createShape(BOX, legWidth, legHeight, legWidth);
frontRightLeg.setTexture(tableImg);
tableShape = createShape(BOX, 2 * tableSizeX, tableSizeY, 2 * tableSizeZ);
tableShape.setTexture(tableImg);
cl1 = new Collider("Table", -HOUSE_WIDTH + tableSizeX, 0, tableSizeX + 0.25, 1, tableSizeZ + 0.25);
colliderMng.addCollider(cl1);
}
void drawTable() {
pushMatrix();
translate(-HOUSE_WIDTH + tableSizeX + 0.001, 0, 0);
getTable();
popMatrix();
}
void getTable() {
float legOffsetX = tableSizeX - legWidth;
float legOffsetZ = tableSizeZ - legWidth;
//back left leg
pushMatrix();
translate(-legOffsetX, -legHeight / 2, legOffsetZ);
shape(backLeftLeg);
popMatrix();
//back right leg
pushMatrix();
translate(legOffsetX, -legHeight / 2, legOffsetZ);
shape(backLeftLeg);
popMatrix();
//front right leg
pushMatrix();
translate(legOffsetX, -legHeight / 2, -legOffsetZ);
shape(backLeftLeg);
popMatrix();
//front left leg
pushMatrix();
translate(-legOffsetX, -legHeight / 2, -legOffsetZ);
shape(backLeftLeg);
popMatrix();
//table
pushMatrix();
translate(0, -legHeight, 0);
shape(tableShape);
popMatrix();
}
}