課堂作業1
//week08_1_loadShape_shape
size(400, 400, P3D);//step03 要有 OpenGL 3D功能
PShape gundam = loadShape("Gundam.obj");//step01 讀入3D模型
translate(width / 2, height / 2);
pushMatrix();//輩分矩陣
translate(0, 100);//step05 往下移一點點
scale(10, -10, 10);//step04 (x, y, z) 把模型放大 上下要倒過來
shape(gundam, 0, 0);//step02 畫出3D模型
popMatrix();//還原矩陣
課堂作業2
//week08_2_PShape_gundam_setup_draw_scale_pop
//轉動它,改成互動模式的程式風格
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));//對Y軸旋轉
shape(gundam, 0, 0);
popMatrix();
pushMatrix();
translate(100, 0, 0);
scale(10, -10, 10);
shape(gundam, 0, 0);
popMatrix();
}
課堂作業3
//week08_3_another_obj_large_bad_mtl
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));//對Y軸旋轉
shape(gundam, 0, 0);
popMatrix();
}
課堂作業4
//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(255);
translate(width / 2, height / 2 + 100);
sphere(10);//基準點
scale(10, -10, 10);
pushMatrix();
translate(0.0, +22.5);
rotate(radians(x));//step02 轉動
//translate(x / 10, y / 10);
//println(x / 10, y / 10);//印出數值
translate(0.0, -22.5);//step01 頭的中心
shape(head, 0, 0);
popMatrix();
shape(body, 0, 0);
}
float x = 0, y = 0;
void mouseDragged()
{
x += mouseX - pmouseX;
y -= mouseY - pmouseY;
}
沒有留言:
張貼留言