//week08_1_loadShape
size(400,400,P3D);//要有P3D的
PShape gundam = loadShape("Gundam.obj");
translate(width/2,height/2);
pushMatrix();//備份矩陣
translate(0,100);
scale(10,-10,10);
shape(gundam,0,0);//(2)畫出3D模型
popMatrix();
課堂作業2
PShape gundam;
void setup(){
size(400,400,P3D);
gundam = loadShape("Gundam.obj");
}
void draw(){
translate(width/2,height/2);
pushMatrix();
scale(10,-10,10);
shape(gundam,0,0);
popMatrix();
pushMatrix();
translate(100,0,10);
scale(10,-10,10);
shape(gundam,0,0);
popMatrix();
}
課堂作業3
//week08_3_PShape_gundam_setup_draw_push_scale_shape_pop
//轉動他,要改成互動模式的城市風格
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();
pushMatrix();
translate(100,0,10);
scale(10,-10,10);
shape(gundam,0,0);
popMatrix();
}
//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);
pushMatrix();
//rotate(radians(frameCount));
translate(x/10,y/10);//要放在小x,y的座標
shape(head,0,0);
popMatrix();
shape(body,0,0);
}
float x=0,y=0;
void mouseDragged(){
x += mouseX-pmouseX;
y += mouseX-pmouseY;
}


沒有留言:
張貼留言