2025年4月10日 星期四

12751054 Week08

 //week08_1_loadShape_shape_

size(400, 400, P3D);

PShape gundam = loadShape("Gundam.obj");

translate(width/2, height/2);

pushMatrix();

  translate(0, 100);

  scale(10, -10, 10);

  shape(gundam, 0, 0);

popMatrix();

// week08_2_PShape_gundam_setup_draw_push_scale_shape_pop
PShape gundam;
void setup(){
  size(400, 400, P3D);
  gundam = loadShape("Gundam.obj");
}
void draw(){
  background(128);
  translate(width/2,height/2+100);
  pushMatrix();
    scale(10, -10, 10);
    rotateY(radians(frameCount));
    shape(gundam, 0, 0);
   popMatrix();
   pushMatrix();
    translate(10, 0, 0);
    scale(10, -10, 10);
    shape(gundam, 0, 0);
  popMatrix();
}
  
  
// week08_3_another_obj_large_bad_mtl
PShape gundam;
void setup(){
  size(400, 400, P3D);
  gundam = loadShape("Gundam.obj");
}
void draw(){
  background(128);
  translate(width/2,height/2+100);
  pushMatrix();
    scale(10, -10, 10);
    rotateY(radians(frameCount));
    shape(gundam, 0, 0);
   popMatrix();
   pushMatrix();
    translate(10, 0, 0);
    scale(10, -10, 10);
    shape(gundam, 0, 0);
  popMatrix();
}
  
//week08_4_gundam_body_head
PShape body, head;
void setup(){
size(400, 400, P3D);
 body = loadShape("body.obj");
 head = loadShape("head.obj");
}
void draw(){
  background(255);
  translate(width/2, height/2+100);
  sphere(10);
scale(10, -10, 10);
pushMatrix();
translate(0, 0, +22.5);
rotate(radians(x));
  //rotate(radians(frameCount));
  translate(x, y);
  shape(head, 0, 0);
  popMatrix();
  shape(body, 0, 0);
}
float x = 0, y = 0;
void mouseDragged(){
  x += mouseX - pmouseX;
  y -= mouseY - pmouseY;
}


沒有留言:

張貼留言