//week04_01_atan2_dy_dx_cos_sin
void setup(){
size(600, 300);
}
void draw(){
background(#C0FFEE);
ellipse(150, 150, 100, 100);
//ellipse(150+25, 150, 50, 50);
float dx = mouseX-150, dy = mouseY-150;
float a = atan2(dy, dx);
ellipse(150+cos(a)*25, 150+sin(a)*25, 50, 50);
}
//week04-2_atan2_for_x_dx_dy_cos_sinvoid setup(){size(600, 300);}void draw(){background(#C0FFEE);for(int x = 150; x<=450; x+=300){ellipse(x, 150, 100, 100);//ellipse(150+25, 150, 50, 50);float dx = mouseX-x, dy = mouseY-150;float a = atan2(dy, dx);ellipse(x+cos(a)*25, 150+sin(a)*25, 50, 50);}}// week04_03_rotateX__radians_mouseYvoid setup(){size(400, 400, P3D);}void draw(){background(128);translate(width/2, height/2);//rotateY(radians(mouseX));//上週左右轉rotateX(radians(-mouseY)); //本週上下轉box(200);}//week04_04_rotateZ_void setup(){size(400, 400, P3D);}void draw(){background(128);translate(width/2, height/2);//rotateY(radians(mouseX));//上週左右轉rotateZ(radians(-mouseY)); //本週上下轉ellipse(0, 0, 100, 150);}// week04_05_robot_arm_pushMatrix_T_R_T_box_popMatrix
void setup(){
size(400, 400, P3D);
}
void draw(){
background(128);
translate(width/2, height/2);
pushMatrix();
translate(0, 100);
box(50);
pushMatrix();
translate(0,-25);
rotateZ(radians(mouseX));
translate(0,-50);
box(10, 100, 10);
popMatrix();
popMatrix();
}
//week04_05a_rotateZ_box
void setup(){
size(400, 400, P3D);
}
void draw(){
background(128);
translate(width/2, height/2);//移到畫面中心
//以下2行,分別註解,排列組合觀察
rotateZ(radians(frameCount));
translate(0,-50);
box(10, 100, 10);
}
//week04_05b_mouseX,mouseY_rotateZ_translate
void setup(){
size(400, 400, P3D);
}
void draw(){
background(128);
//translate(width/2, height/2);//移到畫面中心
translate(mouseX,mouseY);
rotateZ(radians(frameCount));
translate(0,-50);
box(10, 100, 10);
}
// week04_06_push_translate_rotate_sphere_pop
void setup(){
size(400, 400,P3D);
}
void draw(){
background(128);
pushMatrix();
translate(mouseX, mouseY);
rotateY(radians(frameCount));
sphere(100);
popMatrix();
}
// week04_07_
void setup(){
size(400, 400,P3D);
}
void draw(){
background(128);
translate(width/2, height/2);
sphere(50);
rotateY(radians(frameCount));
pushMatrix();
translate(150,0);
rotateY(radians(frameCount));
sphere(30);
popMatrix();
}
//week04_08_sun_earth_mon
void setup(){
size(400, 400,P3D);
}
void draw(){
background(128);
translate(width/2, height/2);
sphere(50);
rotateY(radians(frameCount));
pushMatrix();
translate(150,0);
rotateY(radians(frameCount));
sphere(30);
pushMatrix();
translate(50, 0);
rotateY(radians(frameCount));
sphere(10);
popMatrix();
popMatrix();
}
// week04_09_earth_texture_
// google: earth map texture
// 把圖檔拉到程式裡面
PImage img = loadImage("2k_earth_daymap.jpg");
size(600,300);
image(img, 0, 0, 600, 300);
//week04_10_earth_createShape_earth.seTexture(img);//google: processing sphere texturesize(400,400,P3D);PShape earth = createShape(SPHERE, 100);PImage img = loadImage("2k_earth_daymap.jpg");earth.seTexture(img);shape(earth);//week04_11_earthPShape earth;void setup(){size(400,400,P3D);earth = createShape(SPHERE, 100);PImage img = loadImage("2k_earth_daymap.jpg");earth.setTexture(img);}void draw(){background(0);translate(width/2, height/2);rotateY(radians(frameCount));shape(earth);}//week04_12_moonPShape moon;void setup(){size(400,400,P3D);moon = createShape(SPHERE, 100);PImage img = loadImage("moon.jpg");moon.setTexture(img);}void draw(){background(0);translate(width/2, height/2);rotateY(radians(frameCount));shape(moon);}//week04_13_sun_setTexture_translate_rotatePShape sun;void setup(){size(400,400,P3D);sun = createShape(SPHERE, 100);PImage img = loadImage("sun.jpg");sun.setTexture(img);}void draw(){background(0);translate(width/2, height/2);rotateY(radians(frameCount));shape(sun);}//week04_14_sun_earth_moon_setTexturePShape sun, earth, moonvoid setup(){size(400, 400,P3D);sun = createShape(SPHERE, 100);PImage img = loafImage("sun. jpg");sun.setTexture(img);earth = createShape(SPHERE, 100);PImage img = loafImage(" earth. jpg");earth.setTexture(img);moon = createShape(SPHERE, 100);PImage img = loafImage("moon. jpg");moon.setTexture(img);}void draw(){background(128);translate(width/2, height/2);sphere(sun);rotateY(radians(frameCount));pushMatrix();translate(150,0);rotateY(radians(frameCount));sphere(30);pushMatrix();translate(50, 0);rotateY(radians(frameCount));sphere(10);popMatrix();popMatrix();}
2024電腦圖學 Computer Graphics 人智二甲 授課教師: 葉正聖 銘傳大學人工智慧應用學系 每週主題: 程式環境、點線面顏色、移動/旋轉/縮放與矩陣(Matrix)、階層性關節轉動(T-R-T)、做出機器人、打光、貼圖、glu/glut函式、鍵盤、滑鼠、計時器(timer)、讀入3D模型、粒子系統、聲音、特效、投影矩陣、攝影機與運鏡、機器人2.0、期末作品
2025年3月20日 星期四
week04
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言