顯示具有 04163056_林書玄 標籤的文章。 顯示所有文章
顯示具有 04163056_林書玄 標籤的文章。 顯示所有文章

2017年5月16日 星期二

Week13 書玄好邊緣

作業一
考題講解 

glPushMatrix();  // 10%
  glTranslatef(0.6,0.4,0); // 20%移動 最後把 " 會照著手肘移動的手" 移動到 真的畫面裡
  glRotatef( -80,0,0,1); // 20% 選轉  ( 注意角度的正負號!!!!!!!!!!)
  glTranslatef(0.3,0.3,0); // 20% 移動  把手肘移到畫面中心
  drawHand(); // 20% 畫手
glPopMatrix(); // 10%



作業二
(1) 安裝 open cv2.1 


(2) 在Code Block 新增專案
 
 
 
 
(3) 輸入程式碼

(4)設定
 

 
 
 
(5) 顯示圖片




 
 
 
 
 
 




2017年3月28日 星期二

week06 邊緣人的日常

Hw01: 在Blog練習期中考題

glPushMatrix( ); // 備份矩陣 10%
  glRotatef(angle, x ,y,z);//旋轉 30%
  glTranslatef(x,y,z);//移動40%
  glScalef(x,y,z);//縮放 50%
  glBegin(GL_POLYGON);//開始畫 60%
     glNormal3f(nx, ny,nz);//打光的法向量90%
     glTexCoord2f(tx,ty);//貼圖座標100%
     glColor3f(r,g,b);//顏色 70%
     glVertex3f(x,y,z);//頂點 80%
   glEnd();//結束畫
glPopMatrix();//還原矩陣 20%
 
 
 
 
 
 
 
 
Hw02:嘗試用Transformation  去變換車子的位子
 
 
選擇 Swap Translate  更改旋轉方式
 
 
 
 
 
 
 
 
 
 
Hw03 : 新增專案  並更改程式碼
#include <GL/glut.h>
float mouseX=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glutSolidTeapot(0.3);
        glPushMatrix();
            glRotatef(mouseX, 0,0,1);
            glTranslatef(0.5, 0,0);
            glutSolidTeapot(0.3);
        glPopMatrix();
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x, int y)
{
    mouseX = x;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("TRT robot");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}



 
 
 
 
 
 
 
 
 
Hw04: 新增第二個茶壺 並且接在茶壺嘴上

           並且更改顏色加上旋轉

程式碼為
#include <GL/glut.h>
float mouseX=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glRotatef(mouseX,0,0,1);
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
        glPushMatrix();
             glTranslatef(0.5,0.14,0);
            glRotatef(mouseX,0,0,1);
            glTranslatef(0.41,-0.05,0);
            glColor3f(1,1,1);
            glutSolidTeapot(0.3);
        glPopMatrix();
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x, int y)
{
    mouseX = x;
    glutPostRedisplay();
}
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("TRT robot");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}
 



2017年3月21日 星期二

Week05 邊緣人的日常

Hw01: 登入IRS.ZVIO.COM.TW  回答上週(04週)問題


Hw02: 輸入網址 jsy.org/3dcg10  
下載 data.zip  //   window.zip  //  glut.32.dll  到桌面並且解壓縮

將解壓縮檔案移動到window 資料夾內並試著開啟Transformation


Hw03
: 

2017年3月14日 星期二

Week04 邊緣人的日常

Hw01:作業互評
 
 
解壓縮檔案 並且打開list.html  觀看上週作業 並且選三張最喜歡的  上傳至MOODEL
 
Hw02:畫正圓
 
開啟CodeBlocks ,開啟新專案 
 
 
 
 
 
打開freeglut 並刪減程式碼
 
 

 
 
 
 
 
更改為
#include <GL/glut.h>
#include <math.h>
void display()
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle +=0.01){glVertex2f( cos(angle),sin(angle));
}
glEnd();
glutSwapBuffers();
}
int main(int argc, char*argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("04163056  good man" );
    glutDisplayFunc(display);
    glutMainLoop() ;
    }
即可跑出正圓

 
 
 
 
 
 
 
 
 
 
Hw03: 加上Mouse 函式
 
將程式碼加上Mouse的函式
結果為
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
void display()
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle +=0.01){glVertex2f( cos(angle),sin(angle));
}
glEnd();
glutSwapBuffers();
}
void mouse (int butten,int state, int x, int y)
{
    printf("%d %d %d %d\n", butten, state, x, y);
    glColor3f(1,x /300.0 ,y/300.0 );
}
int main(int argc, char*argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("04163056  good man" );
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMainLoop() ;
    }
 
 
 
 
 
 
 
Hw04:  加上Motiom函式
拖曳滑鼠  ,變色
 
更改程式碼為
#include <GL/glut.h>
#include <math.h>
#include <stdio.h>
void display()
{
    glBegin(GL_POLYGON);
    for(float angle=0; angle <= 3.1415926 *2; angle +=0.01){glVertex2f( cos(angle),sin(angle));
}
glEnd();
glutSwapBuffers();
}
void mouse (int butten,int state, int x, int y)
{
}
void motion(int x, int y)
{
    glColor3f(1,x /300.0 ,y/300.0 );
    glutPostRedisplay();
}
int main(int argc, char*argv[])
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("04163056  good man" );
    glutDisplayFunc(display);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutMainLoop() ;
    }
 

 
 
 

 
 
 



2017年3月7日 星期二

Week03 邊緣人的日常

今日主題: 點,線,面,色彩

今日目標: 完成三角形的顏色更改



先輸入網址 jsyeh/3dcg10/
下載 dota  /  win32  /  glut32.dll  三個檔案


按照上週進度新增專案   , 打開茶壺 , 簡短程式碼 , 此時為黑白茶壺。


更改茶壺顏色 



將茶壺改為三角形,並且可自行調整顏色



更改程式碼變成
#include <GL/glut.h>
static void display(void)
{
    glBegin(GL_POLYGON);
        glColor3f(1,0,0);
        glVertex3f(0,0,0);
        glColor3f(0,1,0);
        glVertex3f(1,1,0);
        glColor3f(0,0,1);
        glVertex3f(1,-1,0);
    glEnd();
    glutSwapBuffers();
}
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;
}
變為三角形,並且可更改顏色








2017年2月21日 星期二

Week01 _ 邊緣人的日常


電腦圖學    課堂筆記                           老師: 葉正聖

力用



First : Web GL Water


Second: 轉轉 Triangle
建立Glut專案





Third: 簡化code
從180行.減少到20行內   ( 用刪減的   不要減貼)