bonjour
comment peut on faire des cylindre 3d avec processing?
y a t'il une fonction comme box?
merci
Hors ligne
Bonjour,
Il n'y a pas pour l'instant de fonction dédiées. u peux utiliser ceci :
http://wiki.processing.org/index.php/Cylinder
Hors ligne
merci pour ta réponse j'ai testez le site mais ça ne donne rien il dois manquer quelque chose.
Hors ligne
Etrange cela fonctionne chez moi :
void setup() {
size(800, 800, P3D);
}
void draw() {
translate(400, 400);
rotate(0.5, 0.5, 0, 0.0);
cylinder(100, 200, 30);
}
void cylinder(float w, float h, int sides)
{
float angle;
float[] x = new float[sides+1];
float[] z = new float[sides+1];
//get the x and z position on a circle for all the sides
for(int i=0; i < x.length; i++){
angle = TWO_PI / (sides) * i;
x[i] = sin(angle) * w;
z[i] = cos(angle) * w;
}
//draw the top of the cylinder
beginShape(TRIANGLE_FAN);
vertex(0, -h/2, 0);
for(int i=0; i < x.length; i++){
vertex(x[i], -h/2, z[i]);
}
endShape();
//draw the center of the cylinder
beginShape(QUAD_STRIP);
for(int i=0; i < x.length; i++){
vertex(x[i], -h/2, z[i]);
vertex(x[i], h/2, z[i]);
}
endShape();
//draw the bottom of the cylinder
beginShape(TRIANGLE_FAN);
vertex(0, h/2, 0);
for(int i=0; i < x.length; i++){
vertex(x[i], h/2, z[i]);
}
endShape();
}Processing 2.0.3
Hors ligne
bonjour
ok maintenant cela fonctionne il manquais le début du programme,sinon dans les exemples j'ai trouvez une fonction
thore mais tous ça a l'ai très compliquez juste pour faire des cylindre.
merci encore
fabrice
Hors ligne