-
-
Save Sugeevan/5df6007072dceb5db310e0e7ef9379b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/64980*@* */ | |
/* !do not delete the line above, required for linking your tweak if you upload again */ | |
/** | |
*fait le 18 Avril 2016 | |
*par Jacques Maire | |
*/ | |
float compteur; | |
float nscal=5.2; | |
int dheight, dwidth ,nbp,pas; | |
PVector axe, depart, eye; | |
PVector angleR, angles; | |
PVector[][] tbl; | |
void setup() { | |
size(900, 900, P3D); | |
nbp=90; //increased size | |
pas=40; //increased size | |
dheight=pas*nbp; | |
dwidth=pas*nbp; | |
angleR=new PVector(3.1, 0, 0.3); | |
angles=new PVector(); | |
tbl=new PVector[nbp][nbp]; | |
} | |
void draw() { | |
compteur+=0.01; | |
background(0); | |
lights(); | |
camera(0,0, 200,0,0, 0, -1, 0, 0); | |
stroke(255); | |
//repere(500,50); | |
from0to1(); | |
// repere(500,50); | |
noiseDetail(1); | |
strokeWeight(random(10)); //randomized stroke weight | |
stroke(255, random(100), random(255)); //add colours to lines | |
calculTbl(); | |
PVector vq; | |
for (int j = 0; j < nbp-1; j++) { | |
for (int i =0; i <nbp-1; i++) { | |
ligne(tbl[i][j],tbl[i][j+1]); | |
} | |
} | |
} | |
void ligne(PVector v, PVector w) { | |
line(v.x, v.y, v.z, w.x, w.y, w.z); | |
} | |
void calculTbl() { | |
for (int y = 0; y < nbp; y++) { | |
for (int x =0; x <nbp; x++) { | |
tbl[x][y]=coteTerrain((x-nbp/2)*pas, (y-nbp/2)*pas); | |
} | |
} | |
} | |
PVector coteTerrain(float x,float y){ | |
float nx= map(x, -dwidth, 2*dwidth, 0,1); | |
float ny= map(y, -dheight, 2*dheight, 0, 1); | |
float xfil = noise(compteur+nx , -compteur+nx ); | |
float yfil = noise(-compteur-ny , compteur+ny ); | |
float afil=noise(cos(compteur*nx)*cos(compteur) , sin(compteur*ny)*sin(compteur)); | |
PVector res= olinde(new PVector(xfil,yfil,(xfil+yfil)),afil*10,new PVector(x*0.2,y*0.2,0)); | |
return res; | |
} | |
PVector olinde(PVector ax, float ph, PVector v0) { | |
PVector res=comb(cos(ph), v0, (1-cos(ph))*ax.dot(v0), ax); | |
PVector croix=PVector.mult(ax.cross(v0), sin(ph)); | |
return PVector.add(res, croix); | |
} | |
PVector comb(float a1, PVector v1, float a2, PVector v2) { | |
return PVector.add(PVector.mult(v1, a1), PVector.mult(v2, a2)); | |
} | |
void repere(float ll, float ee) { | |
noStroke(); | |
pushMatrix(); | |
translate(ll, 0, 0); | |
fill(255, 0, random(100)); | |
box(ll*2.0, ee, ee); | |
popMatrix(); | |
pushMatrix(); | |
translate(0, ll, 0); | |
fill(0, 255, 0); | |
box(ee, ll*2.0, ee); | |
popMatrix(); | |
pushMatrix(); | |
translate(0, 0, ll); | |
fill(0, 0, 255); | |
box(ee, ee, ll*2.0); | |
popMatrix(); | |
} | |
void mouseDragged() { | |
if (mouseButton==RIGHT) | |
{ | |
angles.y+=(mouseY-pmouseY)*0.017; | |
angles.x-=(mouseX-pmouseX)*0.017; | |
angleR=comb(0.9, angleR, 0.1, angles); | |
} | |
if (mouseButton==LEFT) { | |
angles.z+=(mouseX-pmouseX)*0.01; | |
angleR=comb(0.9, angleR, 0.1, angles); | |
} | |
} | |
void mouseClicked() { | |
} | |
void from0to1() { | |
// translate(width*0.5, height*0.7, -855); | |
rotateZ(-angleR.z); | |
rotateY(-angleR.y); | |
rotateX(-angleR.x); | |
} | |
void from1to0() { | |
rotateX(angleR.x); | |
rotateY(angleR.y); | |
rotateZ(angleR.z); | |
// translate(-width*0.5, -height*0.7, 855); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment