Transform shapes so part of wall appears to be decaying

Hi, I’m working in a project. I did some code, but which is not done. I’m very new in processing. I don’t understand properly how everything works. I’ll share the project idea and code below. Can someone help me with the code please please ?
Thanks for your time and kind help

Project Idea

The project model of the bridge is to create semi-circular and circular shapes on the exterior of the wall in a regular pattern using Bezier cubic curves which will be used in computer graphics which will create smooth curves at all scales.

An algorithm is required that will transform the shapes in such a way that some part of wall appears to be decaying or decompose. The algorithm will also show the rate of parameterizable, so that decay can be observed at certain level of when the sunlight reflects the wall.

Code

void setup() {
  size(600, 600, P3D);
}

void draw() {
  background (0);
  lights();
  drawFloor();
   drawSun(width/10+60, 100, 40);
drawWall();
 
}

void drawSun(float x, float y, float z) {
  fill(255, 201, 34);//red fill
  circle(56, 46, 55);
}//func 

// ---------------------------------------------------------------------------

void drawFloor() {

  pushMatrix();

  //stroke(111);  // gray 
  noStroke(); 
  fill(65,152,10); // blue
  float factor1=80.0; // dist between boxes

  translate(width/2, height/2, 0); 

  for (int x=-55; x<55; x++) {
    for (int z=-55; z<55; z++) {

      pushMatrix(); 
      translate(x*factor1 - (4*factor1/2), 
        height-111, 
        z*factor1 - (4*factor1/2) );
      box(80);  // size of 40 (width, height and depth) 
      popMatrix();
    }
  }
  popMatrix();
}

void drawWall(){
   fill(250, 0, 0);
   rotateY(PI/6);
    rect(150, 350, 600, 200);
}
2 Likes

Interesting project! My first thought for creating a physical artifact is toxiclibs. It enables you to generate STL files that work with many fabrication devices; I 3D printed the output of a Processing sketch last week. You can install the library like so.

2 Likes

and just for you code, when you post it at the forum
please use in processing IDE [ctrl][t] and in forum editor header menu </> looks like

void setup() {
  size(600, 600, P3D);
}

void draw() {
  background (0,0,100);
  lights();
  drawFloor();
  drawSun(width/10+60, 100, 40);
  drawWall();
}

void drawSun(float x, float y, float z) {
  fill(255, 201, 34);
  circle(x, y, z);
}

void drawFloor() {
  push();
  noStroke();
  fill(65, 152, 10); 
  translate(width/2, height/2, -500);
  float factor=5.0; // dist between boxes 80
  for (int x=-55; x<55; x+=factor) {
    for (int z=-55; z<55; z+=factor) {
      pushMatrix();
      float posx = x*factor + (4*factor/2);
      float posy = height/2+100;
      float posz = z*factor + (4*factor/2);
      translate(posx, posy , posz );
      box(20); //80
      popMatrix();
    }
  }
  pop();
}

void drawWall() {
  fill(250, 0, 0);
  rotateY(PI/6);
  rect(150, 350, 600, 200);
}


with this small changes i see

if you draw 3D better also see 3D ( PTZ mouse keyboard operation )

void setup() {
  size(600, 600, P3D);
  info_print();
}

void draw() {
  background (0, 0, 100);
  lights();
  PTZ();
}

void draw_object() { //_________________called by / from inside PTZ
  drawSun(width/10+60, 100, 40);
  drawFloor();
  drawWall();
}

void drawSun(float x, float y, float z) {
  push();
  noStroke();
  translate(x,y,z);
  fill(255, 201, 34);
  sphere(20);
  pop();
}

void drawFloor() {
  push();
  noStroke();
  fill(65, 152, 10); 
  translate(width/2, height/2, -500);
  float factor=5.0; // dist between boxes 80
  for (int x=-55; x<55; x+=factor) {
    for (int z=-55; z<55; z+=factor) {
      pushMatrix();
      float posx = x*factor + (4*factor/2);
      float posy = height/2+100;
      float posz = z*factor + (4*factor/2);
      translate(posx, posy, posz );
      box(20); //80
      popMatrix();
    }
  }
  pop();
}

void drawWall() {
  push();
  fill(250, 0, 0);
  rotateY(PI/6);
  rect(150, 350, 600, 200);
  pop();
}





//___________________________________________PTZ ( other TAB )
int mode = 0;
float Zmag = 1;
int Zaxis=-100;                                                       
float Xmag, Ymag = 0;
float newXmag, newYmag = 0; 
int newZmag = 0;
int zoomf = 3;
float newxpos, newypos = 0;       // for PAN
float xposd, yposd = 0;           // for PAN
boolean diag = false;

//_________________________________________________________________ ROTATE / TILDE and MOVE / PAN
void mousePressed() {
  if      (mouseButton == LEFT)   mode=1;  // ORBIT
  else if (mouseButton == RIGHT)  mode=2;  // PAN
  // else if (mouseButton == CENTER) { mode=3; }  // zoom mouse wheel
}

//_________________________________________________________________ mouse PT end
void mouseReleased() { 
  mode = 0;
}

//_________________________________________________________________ mouseWheel ZOOM
void mouseWheel(MouseEvent event) {
  int newZmag = event.getCount();                                     // +- 1
  Zmag += newZmag*0.05; 
}

void keyPressed() {
  if ( keyCode == UP   )   Ymag -= 0.1 ;
  if ( keyCode == DOWN )   Ymag += 0.1 ;
  if ( keyCode == RIGHT)   Xmag -= 0.1 ;
  if ( keyCode == LEFT )   Xmag += 0.1 ;
  if ( keyCode == 16 )     Zmag -= 0.05 ;
  if ( keyCode == 11 )     Zmag += 0.05 ;
  //println("key: "+key+" keyCode: "+keyCode);
}
//_________________________________________________________________ Pan Tilde Zoom
void PTZ() {
  pushMatrix(); 
  translate(width/2, height/2, Zaxis);
  // get new mouse operation  
  if ( mode == 2 ) {                              // PAN ( right mouse button pressed)
    xposd = (mouseX-float(width/2));
    yposd = (mouseY-float(height/2));
  }  
  newxpos = xposd;// xposd=0;
  newypos = yposd;// yposd = 0; 
  translate(newxpos, newypos, 0);          // move object
  if ( mode == 1 ) {  // ORBIT ( left mouse button pressed)
    newXmag = mouseX/float(width) * TWO_PI;
    newYmag = mouseY/float(height) * TWO_PI;

    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);   
  scale(Zmag);

  draw_object();                                // THE OBJECT
  if (diag) println(" Xmag "+nf(Xmag,0,1)+" Ymag "+nf(Ymag,0,1)+" Zmag "+nf(Zmag,0,1));
  popMatrix();
}

//_______________________________________________ SETUP PRINT INFO
void info_print() {
  println("PTZ info:");
  println("key UP DOWN RIGHT LEFT -> rotate // key PAGE UP DOWN -> zoom");
  println("mouse LEFT press drag up down right left -> rotate");
  println("mouse RIGHT press -> move ");
  println("mouse WHEEL turn -> zoom");
}

@helpMe – is this project / is the instruction sheet a homework assignment?

1 Like

what is your status?
could you test both my code versions?

@kll yes I did both 2D and 3D, I’m trying to make circles in the wall. Do you have any idea how to make circles ?

actually i am not so good with 3D,
but when i play 3D sketchup i could make a wall, and cut out windows (push pull).


( my house left / right the sketchup planning )
but in processing you can paint windows on a wall ( like rectangles on a big rectangle or slim cube )
but i worry you could not LOOK THROUGH ( but not tested transparency that much… )

so actually when CUT OUT not works must work other way, construct wall shape with arcs…
and only fill OUTside of the arcs?
that could be your next step learn createshape…

https://processing.org/reference/PShape.html
https://processing.org/reference/createShape_.html

i just try a arc the shape vertex way:

PShape s;  // The PShape object
int xs   = 120, off  = 10;  // arc design
int posx = 20, posy = 20;   // arc position

void my_arc(int  xs, int off) { // my_arc( width (outside ) , width beam );
  //  int xs = 100;
  int ys = xs/2;
  //  int off = 10;
  int r = (xs - 2* off )/2;
  int mx = xs/2;
  int my = ys;  
  s = createShape();
  s.beginShape();
  s.fill(0, 0, 200);
  s.noStroke();
  s.vertex(0, 0);
  s.vertex(0, ys);
  s.vertex(off, ys);
  for ( int i =0; i<180; i++ ) {
    int x = mx+ int(r * cos(radians(i)-PI));
    int y = my+ int(r * sin(radians(i)-PI));
    s.vertex(x, y);
  }
  s.vertex(xs-off, ys);
  s.vertex(xs, ys);
  s.vertex(xs, 0);
  s.vertex(0, 0);
  s.endShape();
}

void measurement() {
  line(posx, posy+xs/2, posx, posy+xs/2+60);
  line(posx, posy + xs/2+10, posx + xs, posy + xs/2+10);
  line(posx + xs, posy+xs/2, posx + xs, posy+xs/2+60);
  text("xs="+xs, posx + xs/2-20, posy + xs/2+22);
  line(posx, posy + xs/2+30, posx + off, posy + xs/2+30);
  line(posx + off, posy+xs/2, posx + off, posy+xs/2+60);
  text("off="+off, posx+2, posy + xs/2+50);
}

void setup() {
  size(200, 200);
  my_arc(xs, off);
}

void draw() {
  background(200, 200, 0);
  shape(s, posx, posy);
  measurement();
}

hope you can use?

Also see this : CSG (Constructive Solid Geometry)

CSG can cut out of existing blocks

1 Like