2025年4月10日 星期四

12750512-林政杰-week08

week08-1

程式碼:

//week08-1

size(400,400,P3D);//3 要有P3D的openGL 3D 功能

PShape gundam=loadShape("Gundam.obj");//1 讀入3D模型

translate(width/2,height/2);

pushMatrix();//備分矩陣

  translate(0,100);//5 往下移

  scale(10,-10,10);//4 把模型放大

  shape(gundam,0,0);//2 畫出3D模型

 popMatrix();


 












week08-2

程式碼:

//week08-2 PShape_gundam_setuo_draws_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(100,0,0);

     scale(10,-10,10);

     shape(gundam,0,0);

    popMatrix();

}

















week08-3

程式碼:

//week08-3 _anther_obj_large_bad_mtl

PShape gundam;//要再把Gundam.obj等檔案,拉進來

void setup(){

  size(400,400,P3D);

  gundam=loadShape("FinalBaseMesh.obj");

}

void draw(){

  background(128);

  translate(width/2,height/2+100);

  pushMatrix();

    scale(10,-10,10);

    rotateY(radians(frameCount));

    shape(gundam,0,0);

   popMatrix();

}














week08-4

程式碼:

//week08-4

//慢慢把「切割開」的模式,逐一組合起來

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


  

  //四個檔案拉進來 body.jpg body.mtl Diffuse.jpg AO.jpg

  //頭的兩個檔案head.obj head.mel

  

  pushMatrix();

   //rotate(x,y);

   //translate(x/10,y/10);//要放在小x,y的座標

   //println(x/10,y/10);//印出座標,等一下要取上面的數

   translate(0.0,+22.5);//3 再掛回原來的地方

   rotate(radians(x));//轉動

   translate(0,-22.5);// 1 我們頭的中心,有放在旋轉中心


   shape(head,0,0);

  popMatrix();

  shape(body,0,0);

}

float x=0,y=0;

void mouseDragged(){

  x+=mouseX-pmouseX;

  y-=mouseY-pmouseY;

}



沒有留言:

張貼留言