2020年6月20日 星期六

week 18

鋼彈模型



























PShape gundam;
void setup()
{
  size(500,500,P3D);//3D模型
  gundam=loadShape("Gundam.obj");
}
void draw()
{
   background(128);
   translate(250,400,0);//3D移動到中間 
   scale(10,-10,10);//調整大小(x,y,z) //把模型上下顛倒回來
   rotateY(radians(frameCount)); /// rotate(1);//旋轉單位為弧度 //以Y為中心原地旋轉
   shape(gundam);
}

旋轉地球

接續鋼彈的方法

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);
}



PImage img;
PShape globe;
void setup()
{
  size(300,300,P3D);
  img=loadImage("earth.jpg");
 globe=createShape(SPHERE,100);
 globe.setTexture(img);//設成貼圖 讓世界地圖 可以貼在球體上
 globe.setStroke(false);//讓線消失
}
void draw()
{
  background(128);
  //image(img,0,0);//匯入地球圖案
  //sphere(100);
  translate(width/2,height/2);//這樣地球才不容易變形
 rotateY(radians(frameCount));
  shape(globe);
}

沒有留言:

張貼留言