Cette page appartient aux archives web de l'EPFL et n'est plus tenue à jour.
This page belongs to EPFL's web archive and is no longer updated.

Berclaz

The Splittower

import oog.*;

import processing.opengl.*;

Oog myScene;

Obj myObj = new Obj();

Obj splitTower = new Obj();

Sliders mySliders;

public void setup(){

size(1200,800,OPENGL);

frameRate(200);

myScene = new Oog(this);

Scene.drawAxis = true;

 

mySliders = new Sliders();

initForm();

}

void initForm(){

//Definition of shape parameters

int numOfSides = 8;

float theta = 2*PI/numOfSides;

//Create a first point with absolute coordinates

Pt a = Pt.create(20,20);

// rotation

RotateZ r = new RotateZ(theta);

//Create a new Face

Face mySquare = new Face();

for (int i=0; i<numOfSides; i++) {

//Create a point from a previous

Pt newPt = Pt.create(a,r);

mySquare.add(newPt);

a = newPt;

}

Obj oriSquare = new Extrude(mySquare,Pt.create(0,0,-4));

//Create a new set of Transformations

Transform myTransform = new Transform();

myTransform.translate(0,0,3);

Transform myTransform2 = new Transform();

myTransform2.apply(myTransform);

myTransform2.scale(.97,.97,1);

//myTransform2.rotateZ(2*PI/72);

Obj mySquare2 = new Obj(oriSquare);

for(int i=0; i<80; i++)

{

Obj tmp = new Obj(mySquare2);

if(i<50)

tmp.apply(myTransform);

else

{

Origine fromHere = new Origine(mySquare2.face(0).pt(0),myTransform2);

tmp.apply(fromHere);

}

myObj.add(tmp);

mySquare2 = tmp;

}

myObj.translate(20,20,0);

 

RotateZ rotZ = new RotateZ(PI/4);

 

Obj oriObj = myObj;

for(int i=0; i<8; i++)

{

Obj rotatedPart = new Obj(oriObj);

rotatedPart.apply(myTransform);

rotatedPart.apply(rotZ);

splitTower.add(rotatedPart);

oriObj = rotatedPart;

}

myScene.sliders(splitTower);

mySliders.add(rotZ);

mySliders.add(myTransform);

mySliders.add(a);

mySliders.add(myTransform2);

}

void draw(){

background(255);

splitTower.draw();

mySliders.draw();

}

Posted by Raphaël Berclaz at 9:18