2025年4月10日 星期四

week08 11160985_林庭毅,

1. 複習:T-R-T 及階層轉動

2. HW2 驗收

3. 考試:T-R-T 如何轉動

4. 主題:讀入3D模型

放入三個鋼蛋模型檔

///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(100, 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("FinalBaseMesh.obj");

}

void draw(){

    background(128);

    lights();

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

    pushMatrix();

      scale(10, -10, 10);

      rotateY(radians(frameCount));

      shape(gundam, 0, 0);

  popMatrix();

}


///week08_4_gundam_body_head

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

拼接鋼蛋的頭和身體

//(1)我們的頭的中心,有放在旋轉中心

//(2)轉動

//(3)再掛回原來的地方

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);//(3)再掛回原來的地方

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

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

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

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

    shape(head, 0, 0);

  popMatrix();

  shape(body, 0, 0);

}

float x=0,y=0;

void mouseDragged(){

    x+=mouseX-pmouseY;

    y-=mouseX-pmouseY;

}



上傳作業week08







沒有留言:

張貼留言