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
|
//visualisation
trackball.onEnterFrame = function() {
_root.zone_montage.clear();
_root.clear();
_root.zone_montage.redraw(true);
//application des paramètres aux pièces
for (j=1; j<_global.tableau.length; j++) {
var_nom = "elt"+j+"_";
nom_fg = "filg"+j+"_";
nom_fd = "fild"+j+"_";
switch (_global.tableau[j][0]) {
case "viewer_rotx" :
const_cyli(_global.tableau[j], var_nom, "0x999999", nom_fg, nom_fd, param);
break;
case "viewer_roty" :
const_cyli(_global.tableau[j], var_nom, "0x999999", nom_fg, nom_fd, param);
break;
}
gotoAndPlay(2); //2 c'est la frame où il y a ce code
}
};
const_cyli = function (tab, nom, couleur, nom_fg, nom_fd, param) {
// construction des faces à partir des points
for (i=0; i<nb_faces-1; i++) {
with (_root.zone_montage[nom+i]) {
clear();
lineStyle(1, couleur);
beginFill(couleur);
moveTo(tab[1][i].x, tab[1][i].y);
lineTo(tab[1][i+1].x, tab[1][i+1].y);
lineTo(tab[1][nb_faces+i+1].x, tab[1][nb_faces+i+1].y);
lineTo(tab[1][nb_faces+i].x, tab[1][nb_faces+i].y);
lineTo(tab[1][i].x, tab[1][i].y);
endFill();
}
}
// dessin derniere face
with (_root.zone_montage[nom+(nb_faces-1)]) {
clear();
lineStyle(1, couleur);
beginFill(couleur);
moveTo(tab[1][nb_faces-1].x, tab[1][nb_faces-1].y);
lineTo(tab[1][0].x, tab[1][0].y);
lineTo(tab[1][nb_faces].x, tab[1][nb_faces].y);
lineTo(tab[1][2*nb_faces-1].x, tab[1][2*nb_faces-1].y);
lineTo(tab[1][nb_faces-1].x, tab[1][nb_faces-1].y);
endFill();
}
// dessin du dessus et du dessous
with (_root.zone_montage[nom+(nb_faces)]) {
clear();
lineStyle(1, 0x000000);
beginFill(couleur);
moveTo(tab[1][0].x, tab[1][0].y);
for (k=0; k<nb_faces; k++) {
lineTo(tab[1][k].x, tab[1][k].y);
}
lineTo(tab[1][0].x, tab[1][0].y);
endFill();
}
with (_root.zone_montage[nom+(nb_faces+1)]) {
clear();
lineStyle(1, 0x000000);
beginFill(couleur);
moveTo(tab[1][nb_faces].x, tab[1][nb_faces].y);
for (k=0; k<nb_faces; k++) {
lineTo(tab[1][nb_faces+k].x, tab[1][nb_faces+k].y);
}
lineTo(tab[1][nb_faces].x, tab[1][nb_faces].y);
endFill();
}
// gestion des profondeurs en fonction de la position en Z
for (i=0; i<nb_faces+2; i++) {
_root.zone_montage[nom+i].swapDepths(100000-tab[2][i].z*100);
}
}; |
Partager