TutorialProcessing3D,translate,box,sphere,,,theninvokesafunctionthatcalculatesanewpositionfortheballoon(asphere),:floatxd=2;floatyd=-1;floatzd=1;floatleftwall=300;floattopwall=250;floatbackwall=0;floatxwidth=410;floatywidth=310;floatzwidth=210;floatxpos=0;floatypos=0;floatzpos=0;Allbutthelastthree(xpos,ypos,andzpos),drawandtheprogrammer-,:callsoncedrawProcessing:callsforeveryframeballoondrawmoveballoonballoonvoidsetup(){size(800,600,P3D);frameRate(15);}voiddraw(){lights();background(250);stroke(0,0,255);translate(leftwall,topwall,backwall);noFill();box(xwidth,ywidth,zwidth);balloon();}voidballoon(){moveballoon();translate(xpos,ypos,zpos);fill(0);stroke(255,0,0);sphere(10);}voidmoveballoon(){xpos+=xd;ypos+=yd;zpos+=zd;if(xpos<-.5*xwidth)xd=-xd;if(xpos>.5*xwidth)xd=-xd;if(ypos<-.5*ywidth)yd=-yd;if(ypos>.5*ywidth)yd=-yd;if(zpos<-.5*zwidth)zd=-zd;i
tutorial processing 3d, translate, box, sphere, draw 来自淘豆网www.taodocs.com转载请标明出处.