2025年3月27日 星期四

week06-12750441

 week06-1

//week06_1_ellipse_translate_rotate_box_pop

void setup(){

  size(500,500,P3D);

}

void draw(){

  background(142);

  ellipse(width/2,height/2,200,200);

  translate(width/2,height/2);//把東西,放到畫面中因

  pushMatrix();//第五周教過的MATRIX保護

//改一下,要按下mouse才能轉

  if(mousePressed)rotateZ(radians(frameCount));

  box(100,30,30);//橫的棒子

  popMatrix();//第五周教過的MATRIX保護

}
















//week06_2_ellipse_push_rotate_box
void setup(){
  size(500,500,P3D);
}
void draw(){
  background(142);
  ellipse(width/2,height/2,200,200);
  translate(width/2,height/2);//把東西,放到畫面中因
  pushMatrix();//第五周教過的MATRIX保護
  if(mousePressed)rotateZ(radians(frameCount));
  translate(-50,0,0);//把棒子往左移一半,讓右端在正中心
  box(100,30,30);//橫的棒子
  popMatrix();//第五周教過的MATRIX保護
}

//week06_3
void setup(){
  size(500,500,P3D);
}
void draw(){
  background(142);
  ellipse(width/2,height/2,200,200);
  translate(width/2,height/2);//把東西,放到畫面中因
  pushMatrix();//第五周教過的MATRIX保護
  translate(x,y);
  if(mousePressed&& mouseButton==RIGHT){
    rotateZ(radians(frameCount));
  }
  translate(-50,0,0);//把棒子往左移一半,讓右端在正中心
  box(100,30,30);//橫的棒子
  popMatrix();//第五周教過的MATRIX保護
}
float x=0,y=0;
void mouseDragged(){
  x += mouseX-mouseY;
  y += mouseY-mouseX;
}
















//week06_4_sphere_box_push_T_R_T_box_pop
//慢慢組合出機器手臂
void setup(){
  size(500,400,P3D);
}
void draw(){
  background(255);//step00
  translate(width/2,height/2);//step00
  sphere(10);//step04放個圓球,當世界中心的參考
  
  box(200,50,25);//手肘
  fill(252,131,77);
  pushMatrix();//step03
  translate(x,y);
  if(mousePressed) rotateZ(radians(frameCount));//step03
  translate(25,0,0);//step02往右推,讓左端放中心
  
  box(50,25,50);//step01小手腕
  popMatrix();//step03
}
float x=0,y=0;//step06會動的位置
void mouseDragged(){//step06
  x +=mouseX-mouseY;
  y += mouseY-mouseY;
  println("x:"+x+"y:"+y);//step07印出來
}
  
















//week06_5
//慢慢組合出機器手臂
void setup(){
  size(500,400,P3D);
}
void draw(){
  background(255);
  translate(width/2,height/2);
  sphere(10);//step04放個圓球,當世界中心的參考
  

  fill(252,131,77);
  pushMatrix();//step04新的一組
  translate(x,y);//step05新的轉動
   box(200,50,25);//手肘
  //step03把程式往右縮排
    pushMatrix(); //step03把程式往右縮排
    translate(100,0);//step01把前一步發現的100,0放好
    //if(mousePressed) rotateZ(radians(frameCount));//step03
    rotateZ(radians(frameCount));//step02只轉動
    translate(25,0,0);//往右推,讓左端放中心
  
    box(50,25,50);//小手腕
    popMatrix();
  popMatrix();
}
float x=0,y=0;//會動的位置
void mouseDragged(){
  x +=mouseX-mouseY;
  y += mouseY-mouseY;
  println("x:"+x+"y:"+y);
}
  
















//week06_6
//慢慢組合出機器手臂
void setup(){
  size(500,400,P3D);
}
void draw(){
  background(255);
  translate(width/2,height/2);
  sphere(10);

  fill(252,131,77);
  pushMatrix();
    
  box(50,200,25);//step03手臂
  pushMatrix();
    translate(x,y);//step03掛到手臂上,觀察到0,-100
    if(mousePressed) rotateZ(radians(frameCount));//step02把旋轉加入
    translate(100,0);//把手肘量100,0放入
    box(200,50,25);
  
    pushMatrix();
    translate(100,0);
    rotateZ(radians(frameCount));//step02只轉動
    translate(25,0,0);
    box(50,25,50);//小手腕
      popMatrix();
    popMatrix();
  popMatrix();
}
float x=0,y=0;
void mouseDragged(){
  x += mouseX-pmouseY;
  y += mouseY-pmouseY;
  println("x:"+x+"y:"+y);
}
  
















//week06_7_push_RRT_many_inside
void setup(){
  size(500,800,P3D);//step00:把視窗變長一點
}
void draw(){
  background(255);
  translate(width/2,height/2);
  sphere(10);

  fill(252,131,77);
  pushMatrix();
  
  if(mousePressed&&mouseButton==RIGHT) rotateY(radians(frameCount));
  if(mousePressed&&mouseButton==RIGHT) rotateZ(radians(frameCount));
  translate(x,y);
  box(50,200,25);//step03手臂
  pushMatrix();
    translate(0,-100);//step03掛到手臂上,觀察到0,-100
    //if(mousePressed) 
    rotateZ(radians(frameCount));//step02把旋轉加入
    translate(100,0);//把手肘量100,0放入
    box(200,50,25);
  
    pushMatrix();
    translate(100,0);
    rotateZ(radians(frameCount));//step02只轉動
    translate(25,0,0);
    box(50,25,50);//小手腕
      popMatrix();
    popMatrix();
  popMatrix();
}
float x=0,y=0;
void mouseDragged(){
  x += mouseX-pmouseY;
  y += mouseY-pmouseY;
  println("x:"+x+"y:"+y);
}
  



沒有留言:

張貼留言