//week08-1-loadShape-Shape
size(400,400,P3D);//要有P3D的OpenGL 3D功能
PShape gundam=loadShape("Gundam.obj");//讀入3D模型
translate(width/2,height/2);//放到畫面中心
pushMatrix();//備分矩陣
translate(0,100);//下一移
scale(10,-10,10);//把模型放大
shape(gundam,0,0);//畫出3D模型
popMatrix();//還原矩陣
//week08-2
//轉動他,要改成互動模式的程式風格
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();
}
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
//慢慢組合起來
PShape body,head;
void setup(){
size(400,400,P3D);
head=loadShape("head.obj");
body=loadShape("body.obj");
}
void draw(){
background(255);
translate(width/2,height/2+100);
sphere(10);//基準點
scale(10,-10,10);
pushMatrix();
translate(0,21.6);
rotate(radians(X));
translate(0,-21.6);//放在小x,y的座標
//println(x/10,y/10);//印出座標,取代上面的數
shape(head,0,0);
popMatrix();
shape(body,0,0);
}
float x=0,y=0;
void mouseDragged(){
x+=mouseX-pmouseX;
y+=mouseY-pmouseY;
}
沒有留言:
張貼留言