//week08_1 loadShape
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();
}
-----------------------------------------------------------------------
//week08_3
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
//新增關節
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);//調整回脖頸處
rotate(radians(x));
//translate(x, y/10);
//println(x/10, y/10); //印出座標 之後要取代上頭的
translate(0.0, -22.5);//
shape(head, 0, 0);
popMatrix();
shape(body, 0, 0);
}
float x = 0, y = 0;
void mouseDragged(){
x += mouseX - pmouseX;
y -= mouseY - pmouseY;
}
//插入四個檔案 body.obj, body.mtl, Diffuse.jpg, AO.jpg
//插入頭部檔案 head.obj, head,mtl
沒有留言:
張貼留言