2020年6月20日 星期六

Week 18

Processing

1.會轉的地球


解壓縮老師的earth檔案就好,附上程式碼參考

PImage img;
PShape globe;
void setup(){
  size(300,300,P3D);
  img = loadImage("earth.jpg");
  globe = createShape(SPHERE, 100);
  globe.setStroke(false);
  globe.setTexture(img);
}
void draw(){
  background(128);
  noStroke();
  translate(width/2,height/2);
  rotateY(radians(frameCount));
  shape(globe);
}

2.鋼蛋



PShape gundam;
void setup(){
  size(500,500,P3D);
  gundam = loadShape("Gundam.obj");
}
void draw(){
  background(128);//清背景不會有殘影
  translate(250,400,0);
  scale(10,-10,10); //x,y,z 可調大模型縮放比例 : 放大10倍 y 變負的
  rotateY(radians(frameCount));//先對Y旋轉
  shape(gundam);
}

3.還沒轉的地球
PImage img;
PShape globe;//現在變3行,PShape處理
void setup(){
  size(300,300,P3D);
  img=loadImage("earth.jpg");
  globe= createShape(SPHERE,100);
  globe.setStroke(false);//去掉外框
  globe.setTexture(img);//所有可以設定貼圖
}

void draw(){
  //image(img,0,0);
  //sphere(100);原本只能畫球不能改
  //lights();//打光變立體
  translate(width/2,height/2);
  shape(globe);//它變成可變的shape
}

沒有留言:

張貼留言