You need to sign in or sign up before continuing.
Newer
Older
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
class Projecteur extends QShape {
private float largeur, hauteur, profondeur;
private PShape boitier, lentille, fixation;
private PImage textureBoitier, textureLentille;
Projecteur(float x, float y, float z, PImage textureBoitier, PImage textureLentille) {
super(x, y, z);
this.textureBoitier = textureBoitier;
this.textureLentille = textureLentille;
this.largeur = 150;
this.hauteur = 60;
this.profondeur = 80;
}
// Créer le projecteur
void creerProjecteur() {
boitier = createShape();
boitier.beginShape(QUADS);
boitier.texture(textureBoitier);
boitier.noStroke();
// Face avant
boitier.vertex(-largeur / 2, -hauteur / 2, profondeur / 2, 0, 0);
boitier.vertex(largeur / 2, -hauteur / 2, profondeur / 2, textureBoitier.width, 0);
boitier.vertex(largeur / 2, hauteur / 2, profondeur / 2, textureBoitier.width, textureBoitier.height);
boitier.vertex(-largeur / 2, hauteur / 2, profondeur / 2, 0, textureBoitier.height);
// Face arrière
boitier.vertex(-largeur / 2, -hauteur / 2, -profondeur / 2, 0, 0);
boitier.vertex(largeur / 2, -hauteur / 2, -profondeur / 2, textureBoitier.width, 0);
boitier.vertex(largeur / 2, hauteur / 2, -profondeur / 2, textureBoitier.width, textureBoitier.height);
boitier.vertex(-largeur / 2, hauteur / 2, -profondeur / 2, 0, textureBoitier.height);
// Côtés
boitier.vertex(-largeur / 2, -hauteur / 2, -profondeur / 2, 0, 0);
boitier.vertex(-largeur / 2, -hauteur / 2, profondeur / 2, textureBoitier.width, 0);
boitier.vertex(-largeur / 2, hauteur / 2, profondeur / 2, textureBoitier.width, textureBoitier.height);
boitier.vertex(-largeur / 2, hauteur / 2, -profondeur / 2, 0, textureBoitier.height);
boitier.vertex(largeur / 2, -hauteur / 2, -profondeur / 2, 0, 0);
boitier.vertex(largeur / 2, -hauteur / 2, profondeur / 2, textureBoitier.width, 0);
boitier.vertex(largeur / 2, hauteur / 2, profondeur / 2, textureBoitier.width, textureBoitier.height);
boitier.vertex(largeur / 2, hauteur / 2, -profondeur / 2, 0, textureBoitier.height);
boitier.endShape(CLOSE);
// Créer la lentille du projecteur
lentille = createShape();
lentille.beginShape(QUADS);
lentille.texture(textureLentille);
lentille.noStroke();
// Lentille circulaire (avant du projecteur)
float rayonLentille = 30;
lentille.vertex(-rayonLentille, -rayonLentille, profondeur / 2, 0, 0);
lentille.vertex(rayonLentille, -rayonLentille, profondeur / 2, textureLentille.width, 0);
lentille.vertex(rayonLentille, rayonLentille, profondeur / 2, textureLentille.width, textureLentille.height);
lentille.vertex(-rayonLentille, rayonLentille, profondeur / 2, 0, textureLentille.height);
lentille.endShape(CLOSE);
// Créer la fixation (supports) du projecteur
fixation = createShape();
fixation.beginShape(QUADS);
fixation.fill(0);
fixation.noStroke();
float fixationHeight = 80; // Nouvelle hauteur de la fixation
// Support supérieur
fixation.vertex(-largeur / 4, -hauteur / 2 - 10, -profondeur / 2, 0, 0);
fixation.vertex(largeur / 4, -hauteur / 2 - 10, -profondeur / 2, 10, 0);
fixation.vertex(largeur / 4, -hauteur / 2 - 10, profondeur / 2, 10, 10);
fixation.vertex(-largeur / 4, -hauteur / 2 - 10, profondeur / 2, 0, 10);
// Partie verticale de la fixation (augmente la hauteur ici)
fixation.vertex(-largeur / 4, -hauteur / 2 - 10, -profondeur / 2, 0, 0);
fixation.vertex(largeur / 4, -hauteur / 2 - 10, -profondeur / 2, 10, 0);
fixation.vertex(largeur / 4, -hauteur / 2 - fixationHeight, -profondeur / 2, 10, 10);
fixation.vertex(-largeur / 4, -hauteur / 2 - fixationHeight, -profondeur / 2, 0, 10);
fixation.endShape(CLOSE);
// Grouper les parties du projecteur
shape = createShape(GROUP);
shape.addChild(boitier);
shape.addChild(lentille);
shape.addChild(fixation);
}
void dessiner() {
shape(shape);
}
void positionnerProjecteur() {
// Positionner le projecteur sous le plafond, de manière fixe
translate(x, y, z);
rotateX(HALF_PI);
}
}