/* ------------------------------------------------------------ ------------------------------------------------------------ --( KnotStairs Sculture )-- ------------------------------------------------------------ Guillaume LaBelle - 2004 [www.vif.com/users/goo] GRCAO - Architecture - Université de Montréal [UDM] Laboratoire de Recherche Nxi Gestatio-HEXAGRAM [UQAM] Architecture et Robotique - Québec - CANADA [2003] */ float xmag, ymag = 0; float newXmag, newYmag = 0; int count = 0; float scNode, scLine, scAngle, scLabel, scScene, rndMoov; //Scales int Background = 255; String[] Tag = new String[14]; String Tag(String Prfx, String Sufx) { Tag[ 0]=Prfx+" o " +Sufx; Tag[ 1]=Prfx+" oooo oooo oo oo " +Sufx; Tag[ 2]=Prfx+" ooooooo oooo ooooooo oo oo " +Sufx; Tag[ 3]=Prfx+" oo oooo ooooooo oooo ooo ooooo " +Sufx; Tag[ 4]=Prfx+" oo oooooo ooooooo oo oooo " +Sufx; Tag[ 5]=Prfx+" ooo ooooo oooooo ooo ooooo " +Sufx; Tag[ 6]=Prfx+" ooooooooooo ooooooooooo oo oooo " +Sufx; Tag[ 7]=Prfx+" oooooo oooooooo oooo o oo oo " +Sufx; Tag[ 8]=Prfx+" ooo oooo " +Sufx; Tag[ 9]=Prfx+" --( Guillaume ooo LaBelle )-- goo.x@gmx.ch " +Sufx; Tag[10]=Prfx+" oo oo " +Sufx; Tag[11]=Prfx+" ooo ooo " +Sufx; Tag[12]=Prfx+" oooooooo " +Sufx; Tag[13]=Prfx+" oooo " +Sufx; return join(Tag,"\n"); } BFont LogicFont; void setup() { size(500, 550); initSlider(); initButtons(); smooth(); ellipseMode(CENTER_DIAMETER); LogicFont = loadFont("SlideFont.vlw"); initScale(); } int tempMem = 6; void loop() { background(Background); updateButtons(); updateSlider(); push(); updateOrbit(); drawKnot(); pop(); } //------------------------------------------------------------ //------------------------------------------------------------ //--( VUES )-- //------------------------------------------------------------ void updateOrbit(){ translate(width/2, width/2, -30); if(key=='1') { newXmag = mouseX/float(width) * TWO_PI; newYmag = mouseY/float(height) * TWO_PI; key='a'; } float diff = xmag-newXmag; if (abs(diff) > 0.01) { xmag -= diff/4.0; } diff = ymag-newYmag; if (abs(diff) > 0.01) { ymag -= diff/4.0; } rotateX(-ymag); rotateY(-xmag); if(key=='2') { scScene*=0.875+(mouseY/float(height))/4; key='a'; } scale(100*scScene); } void initScale(){ scNode = 1; scLine = 1; scAngle = 3; scLabel = 0.75; scScene = 0.070; rndMoov = 0.01; } //------------------------------------------------------------ //------------------------------------------------------------ //--( Sliders )-- //------------------------------------------------------------ /*Global*/ BFont slideFont; HScrollbar[] GooSlider = new HScrollbar[6]; /////////////////////////////// //Sliders fn /////////////////////////////// void initSlider(){ slideFont = loadFont("SlideFont.vlw"); int co = 200; GooSlider[0] = new HScrollbar(10/*xPos*/, height-10*1/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,0.6/*init*/,0/*MIN*/,10/*MAX*/, "C", color(co,co,co) ); GooSlider[1] = new HScrollbar(10/*xPos*/, height-10*2/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,17/*init*/,1/*MIN*/,60/*MAX*/, "B", color(co,co,co) ); GooSlider[2] = new HScrollbar(10/*xPos*/, height-10*3/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,10/*init*/,1/*MIN*/,30/*MAX*/, "A", color(co,co,co) ); GooSlider[3] = new HScrollbar(10/*xPos*/, height-10*4/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,8.22/*init*/,0/*MIN*/,10/*MAX*/, "LW", color(co,co/2,0) ); GooSlider[4] = new HScrollbar(10/*xPos*/, height-10*5/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,1.28/*init*/,0/*MIN*/,10/*MAX*/, "LH", color(co,co/2,0) ); GooSlider[5] = new HScrollbar(10/*xPos*/, height-10*6/*yPos*/,width-100/*width*/,8/*height*/,05/*friction*/,100/*init*/,1/*MIN*/,200/*MAX*/, "NUM", color(co,co/2,0) ); } void updateSlider(){ for(int i=0;i 1) { spos = spos + (newspos-spos)/loose; } } int constrain(int val, int minv, int maxv) { return min(max(val, minv), maxv); } boolean over() { if(mouseX > xPos && mouseX < xPos+swidth && mouseY > yPos && mouseY < yPos+sheight) { return true; } else { return false; } } void draw() { fill(red(couleur), green(couleur), blue(couleur), 150); stroke(red(couleur), green(couleur), blue(couleur) ); line(xPos, yPos+sheight/2, xPos+swidth, yPos+sheight/2); rect(spos, yPos, sheight, sheight); fill(red(couleur), green(couleur), blue(couleur), 30); noStroke(); rect(xPos, yPos+sheight/4, swidth, sheight/2); fill(red(couleur), green(couleur), blue(couleur)); value = getPos(); textFont(slideFont, 18); text( " "+name+" "+nf(value, 0, 2), xPos+swidth, yPos+sheight/2+6); } float getPos() { return ((valueMAX-valueMIN)*(spos * ratio))/swidth; } } /////////////////////////////// //Buttons fn /////////////////////////////// int Bval=7; RectButton[] Buttons = new RectButton[10]; void initButtons(){ color base = color(255,225,150); color high = color(255,150,50); int w=15; int s=2; for(int i =0;i= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } //------------------------------------------------------------ //------------------------------------------------------------ //--( KNOT )-- //------------------------------------------------------------ //Fonction du noeud Basée sur les Équations Paramétriques gPoint KnotEq(float gPHz){ float A = GooSlider[2].getPos(); //10 float B = GooSlider[1].getPos(); //15 float C = GooSlider[0].getPos(); //2 gPoint Pt=new gPoint(); float scale = 1; Pt.x = (scale*(-A*cos(gPHz) - C*cos(5*gPHz) + B*sin(2*gPHz)) ); Pt.y = (scale*(-B*cos(2*gPHz) + A*sin(gPHz) -C*sin(5*gPHz)) ); Pt.z = (scale*(A*cos(3*gPHz)) ); return Pt; } float cont = 0; float step = 10; void drawKnot(){ float lenW =GooSlider[3].getPos(); float lenH =GooSlider[4].getPos(); float num =GooSlider[5].getPos(); gPoint[][] coo = new gPoint[(int)num+1][4]; cont++; if(cont>step-1) cont=0; float cf = ((cont/step))/num; for(float i=0; i