程式碼:
//week09-1
PShape body=loadShape("body.obj");
PShape head=loadShape("head.obj");
size(400,400,P3D);
translate(200,300);
sphere(10);//原點的球
scale(10,-10,10);//y要上下再反過來
shape(body,0,0);
shape(head,0,0);
week09-2
程式碼:
//week09-2_gundam_head_body_push_trt_pop
PShape body ,head;
void setup(){
size(400,400,P3D);
body=loadShape("body.obj");
head=loadShape("head.obj");
}
void draw(){
background(204);
translate(200,300);
sphere(10);//原點的球
scale(10,-10,10);//y要上下再反過來
shape(body,0,0);
pushMatrix();
translate(0,22,5);
rotateY(radians(mouseX-200));
rotateX(radians(mouseY-70));
translate(0,-22.5);
shape(head,0,0);
popMatrix();
}
week09-3
程式碼:
//week09-3_gundam_uparm_upuparm
PShape uparml,upuparml;
void setup(){
size(400,400,P3D);
uparml=loadShape("uparm1.obj");
upuparml=loadShape("upuparm1.obj");
}
void draw(){
background(204);
translate(200,300);
sphere(3);
scale(10,-10,10);
shape(upuparml,0,0);//上手臂
pushMatrix();
//translate(mouseX/10.0,-mouseY/10.0);//一邊移動、一邊找到數值
//println(mouseX/10.0,-mouse/10.0);//印出適合的數值ex:4.1,-19.9
translate(-4.1,19.9);//再掛回去原本的位置
rotate(radians(mouseY));
translate(4.1,-19.9);//把物體的旋轉中心,放到座標中心
shape(uparml,0,0);///上手臂
popMatrix();
}
week09-4
程式碼:
//week09-4_gundam_uparm_upuparm_head_
PShape uparm1,upuparm1,hand1;
void setup(){
size(400,400,P3D);
uparm1=loadShape("uparm1.obj");
upuparm1=loadShape("upuparm1.obj");
hand1=loadShape("hand1.obj");
}
void draw(){
background(204);
translate(200,300);
sphere(3);
scale(10,-10,10);
shape(upuparm1,0,0);//上上手臂
pushMatrix();
translate(-4.1,19.9);//再掛回去原本的位置
rotateZ(radians(mouseX));
translate(4.1,-19.9);//把物體的旋轉中心,放到座標中心
shape(uparm1,0,0);///上手臂
pushMatrix();
translate(-4.5,16.9);
rotateX(radians(mouseY));
translate(4.5,-16.9);
//translate(mouseX/10.0,-mouseY/10.0);//一邊移動、一邊找到數值
//println(mouseX/10.0,-mouseY/10.0);//印出適合的數值ex:4.1,-19.9
shape(hand1,0,0);
popMatrix();
popMatrix();
}
沒有留言:
張貼留言