import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class _3Dprimitive_1a extends BApplet { /*A study on 3d primitives. It's still a work in progress. I used some samples of code by Fry and Reas, in particulary the Handler Class that I modify in a rather rough way. Xnumbers, Ynumbers draw the profile, var q determinates the number of the sides by Alessandro Capozzo 11 August 03 */ float ymag,xmag=0; float newYmag,newXmag=0; int[] Xnumbers = { 100,15,15, 10, 10 , 20, 10, 70, 80, 150 }; int[] Ynumbers = { -190,-170,-50, -20, 0, 20, 60, 100, 120, 190}; int q=8; int Sx,Sx1,Sy,Sy1; Handle[] handles; int num; void setup() { size(600, 400); colorMode(RGB, 255); background(230, 230, 230); num = Xnumbers.length; handles = new Handle[num]; int hsize = 10; for(int i=0; i 0.01f) { xmag -= diff/4.0f; } diff = ymag-newYmag; if (abs(diff) > 0.01f) { ymag -= diff/4.0f; } push(); rotateX(ymag); rotateY(xmag); float d= 0.0f; while(d < TWO_PI) { rotateY(TWO_PI/q); push(); int arraycont=Xnumbers.length-1; int i; for (i=0;i xlimit1 && mouseY < ylimit2 && mouseY >ylimit1 ){ return true; } else { return false; } } int getX(){ return boxx; } int getY(){ return boxy; } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } int lock(int val, int minv, int maxv) { return min(max(val, minv), maxv); } void keyReleased() { if((key=='a'|| key=='A') && q<64){ q++; } else if ((key=='z'|| key=='Z') && q>3) { q--; } } }