//week08-1_loadshape_shape
size(400,400,P3D);//要有P3D的OpenGL 3D功能 PShape gundam = loadShape("Gundam.obj");//(1)讀入3D模型 translate(width/2,height/2); pushMatrix(); translate(0,100); scale(10,-10,10); shape(gundam, 0,0);//(2)畫出3D模型 popMatrix();
//week08_2_PShape_gundam_void setup_draw_push_ scale_translate_pop //轉動他,改成互動模式的風格 PShape gundam;//要把Gundam.obj拉進來 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); translate(width/2,height/2+100); pushMatrix(); scale(10,-10,10); rotateY(radians(frameCount)); 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(128); 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 - pmouseX; y -= mouseY - pmouseY; }
沒有留言:
張貼留言