(1)專題進度: Q&A
(2)主題: Antialias
Antialias:
反鋸齒、柔邊
2017年12月14日 星期四
筆記 week 14
(1) 期末作品QA
(2) Rasterization (光柵) - OpenGL
- WebGL
1. triangle (stroke)
size(600,600,P3D);
background(255);
beginShape(TRIANGLE);
stroke(255 , 0 ,0); vertex(300 ,100);
stroke(0 ,255 ,0); vertex(500 ,500);
stroke(0 ,0 ,255); vertex(100 ,500);
endShape();
2. triangle (fill)
(2) Rasterization (光柵) - OpenGL
- WebGL
1. triangle (stroke)
size(600,600,P3D);
background(255);
beginShape(TRIANGLE);
stroke(255 , 0 ,0); vertex(300 ,100);
stroke(0 ,255 ,0); vertex(500 ,500);
stroke(0 ,0 ,255); vertex(100 ,500);
endShape();
2. triangle (fill)
size(600,600,P3D);
background(255);
beginShape(TRIANGLE);
fill(255 ,0 ,0); vertex(300 ,100);
fill(0 ,255 ,0); vertex(500 ,500);
fill(0 ,0 ,255); vertex(100 ,500);
endShape();
3. double triangle with z-axis
void setup(){
size(600,600,P3D);
}
void draw(){
background(255);
beginShape(TRIANGLE);
fill(255,0,0); vertex(100 , 100 ,0);
fill(0,255,0); vertex(100 , 500 ,100);
fill(0,0,255); vertex(500 , 500 ,0);
endShape();
beginShape(TRIANGLE);
fill(0,255,0); vertex(500 , 100 ,0);
fill(255,255,0); vertex(500 , 500 ,100);
fill(0,255,255); vertex(100 , 500 ,0);
endShape();
}
2017年11月30日 星期四
week12 筆記
(1) 主題: Scene 場景
(2) 主題: Mocap, Skeleton , Model
(3) 期末作品分析 & 協助
1. myGL_frustrum221_MultiView
glutInit(&argc,argv);
2. processing scene
add library : collada
open example : 2dViewer
(2) 主題: Mocap, Skeleton , Model
(3) 期末作品分析 & 協助
1. myGL_frustrum221_MultiView
glutInit(&argc,argv);
2. processing scene
add library : collada
open example : 2dViewer
3. testBVH
2017年11月9日 星期四
week09
1.
2.
PImage img = loadImage("download.jpg");
size(600,600);
image(img, 0,0,600,600);
2.
PImage img = loadImage("download.jpg");
size(600,600);
image(img, 0,0,600,600);
3.
PImage img;
void setup(){
size(1280,800);
img = loadImage("download.jpg");
}
void draw(){
image(img, mouseX,mouseY);
}
4.
2017年10月19日 星期四
Note week06
(1) 複習上周進度
(2) 編譯上周 Transformation 程式
(4) 打光 Lighting
GLfloat pos[] = {0.0,0.0,-1.0,0.0};
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
(5) mouse & keyboard
.
.
.
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
.
.
.
glutMainLoop();
}
(6) 旋轉 with keyboard
void keyboard(unsigned char key, int x, int y)
{
printf("now: %c (%d %d)\n", key, x, y);
if(key=='1') rotateX ++;
if(key=='2') rotateY ++;
if(key=='3') rotateZ ++;
glutPostRedisplay(); //發出更新畫面要求
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rotateX, 1, 0, 0);
glRotatef(rotateY, 0, 1, 0);
glRotatef(rotateZ, 0, 0, 1);
drawmodel();
glPopMatrix();
glutSwapBuffers();
}
(7) 旋轉 with mouse
(2) 編譯上周 Transformation 程式
(4) 打光 Lighting
GLfloat pos[] = {0.0,0.0,-1.0,0.0};
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
(5) mouse & keyboard
void keyboard(unsigned char key, int x, int y)
{
printf("now: %c (%d %d)\n", key, x, y);
}
void mouse(int button, int state, int x, int y)
{
}
int main(...)
{.
.
.
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
.
.
.
glutMainLoop();
}
(6) 旋轉 with keyboard
void keyboard(unsigned char key, int x, int y)
{
printf("now: %c (%d %d)\n", key, x, y);
if(key=='1') rotateX ++;
if(key=='2') rotateY ++;
if(key=='3') rotateZ ++;
glutPostRedisplay(); //發出更新畫面要求
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(rotateX, 1, 0, 0);
glRotatef(rotateY, 0, 1, 0);
glRotatef(rotateZ, 0, 0, 1);
drawmodel();
glPopMatrix();
glutSwapBuffers();
}
(7) 旋轉 with mouse
int oldX= 0, oldY= 0;
void mouse(int button, int state, int x, int y)
{
//ya
printf("%d %d [%d %d]\n",button, state, x, y);
if(state== GLUT_DOWN)
{
oldX= x;
oldY= y;
}
}
void motion(int x, int y)
{
rotateY += -(x-oldX);
rotateX += -(y-oldY);
oldX= x;
oldY= y;
glutPostRedisplay();
}
int main()
{
.
.
.
glutMotionFunc(motion);
.
.
.
}
2017年10月12日 星期四
筆記 Week05
(1) 複習上週主題(旋轉 etc.)
(2) 主題: Viewing
(3) 範例: jsyeh.org/3dcg10
(4) Viewing 相關函式&介紹
(5) 作業:利用 mouse/keyboard 實作
1. Transformation.exe 移動 旋轉 縮放
data.zip --->桌面\windows\data\
windows.zip --->桌面\windows\
glut32.dll --->桌面\windows\glut32.dll
2. Projection.exe 投影
-gluPerspective (fovy, aspect, zNear, zFar);
-glOrtho (左, 右, 上, 下, 近, 遠);
glFrustum ( ... );
-gluLookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
(2) 主題: Viewing
(3) 範例: jsyeh.org/3dcg10
(4) Viewing 相關函式&介紹
(5) 作業:利用 mouse/keyboard 實作
1. Transformation.exe 移動 旋轉 縮放
data.zip --->桌面\windows\data\
windows.zip --->桌面\windows\
glut32.dll --->桌面\windows\glut32.dll
2. Projection.exe 投影
-gluPerspective (fovy, aspect, zNear, zFar);
-glOrtho (左, 右, 上, 下, 近, 遠);
glFrustum ( ... );
-gluLookAt (eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
2017年10月5日 星期四
筆記 Week04
(1) 主題: 移動、旋轉、縮放
(2) 實作: Translate、Rotate、Scale
(3) 觀念: 矩陣 Matrix、Push、Pop
(4) 作業: 加入移動、旋轉等
*更改display()函式,+三角錐
glPushMatrix()
glTranslated(0,1.2,-6); // 物件位置
glRotated(60,1,0,0); // 旋轉
glRotated(a,0,0,1);
glColor3f(1,1,0); // Yellow
glutSolidTetrahedron(); //三小錐
glColor3f(1,0,0); // Red
glPopMatrix();
*glScalef() 縮放
glScalef(2,2,2); // x y z 各放大兩倍
(2) 實作: Translate、Rotate、Scale
(3) 觀念: 矩陣 Matrix、Push、Pop
(4) 作業: 加入移動、旋轉等
*更改display()函式,+三角錐
glPushMatrix()
glTranslated(0,1.2,-6); // 物件位置
glRotated(60,1,0,0); // 旋轉
glRotated(a,0,0,1);
glColor3f(1,1,0); // Yellow
glutSolidTetrahedron(); //三小錐
glColor3f(1,0,0); // Red
glPopMatrix();
*glScalef() 縮放
glScalef(2,2,2); // x y z 各放大兩倍
2017年9月28日 星期四
筆記 Week03
1 主題 : Vertex Buffer / Array / Shader
2 上周作業互評 / 票選
3 程式技巧講解
4 描點好累..... 3D model!
1) 小小兵描點作業 by 學姊
A) lib/libfreeglut.a -> lib/libglut32.a
B) 把小小兵 minion.txt 放到 freeglut\bin裡
C) 結果
2) 足球
A) 安裝3D Exploration
B) 另存新檔為 .cpp
C) 開新Opengl 專案 貼code
E) 刪除有問題 Code
2 上周作業互評 / 票選
3 程式技巧講解
4 描點好累..... 3D model!
1) 小小兵描點作業 by 學姊
A) lib/libfreeglut.a -> lib/libglut32.a
B) 把小小兵 minion.txt 放到 freeglut\bin裡
C) 結果
2) 足球
A) 安裝3D Exploration
B) 另存新檔為 .cpp
C) 開新Opengl 專案 貼code
E) 刪除有問題 Code
2017年9月21日 星期四
吳祖銘上課筆記 Week 02
(1) 主題:點,線,面,色彩
(2) 實作:OpenGL , GLUT WebGL
(3) 親手打造第一個圖學程式
1. 程式碼
#include<GL/glut.h> //include glut 外掛函式
void display()
{
glClearColor(1,0,0,0); //清理背景顏色,(R,G,B,透明度);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0); //顯示物件為綠色;
glutSolidTeapot(0.3); //顯示茶壺;
glutSwapBuffers(); //切換buffer,避免畫面閃爍;
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}
2. 執行結果
3. 倒三角形
void display()
{
glClearColor(0,0,1,0); // 清理背景顏色為藍色
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0); //物件顏色為綠色
glBegin(GL_POLYGON); //開始畫多邊形
glVertex3f(1,1,0); // vertex(頂點) (x,y,z) = (1,1,0)
glVertex3f(-1,1,0);
glVertex3f(0,-1,0);
glEnd(); // 繪圖結束
glutSwapBuffers();
}
4. 結果
(2) 實作:OpenGL , GLUT WebGL
(3) 親手打造第一個圖學程式
1. 程式碼
#include<GL/glut.h> //include glut 外掛函式
void display()
{
glClearColor(1,0,0,0); //清理背景顏色,(R,G,B,透明度);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0); //顯示物件為綠色;
glutSolidTeapot(0.3); //顯示茶壺;
glutSwapBuffers(); //切換buffer,避免畫面閃爍;
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}
2. 執行結果
3. 倒三角形
void display()
{
glClearColor(0,0,1,0); // 清理背景顏色為藍色
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0); //物件顏色為綠色
glBegin(GL_POLYGON); //開始畫多邊形
glVertex3f(1,1,0); // vertex(頂點) (x,y,z) = (1,1,0)
glVertex3f(-1,1,0);
glVertex3f(0,-1,0);
glEnd(); // 繪圖結束
glutSwapBuffers();
}
訂閱:
文章 (Atom)























