2016年3月14日 星期一

野比大雄的翻花繩教室week04

課堂作業1:

欣賞上週全班同學的作品
挑出5張覺得不錯的

1. 鄭棕寶
能精準的把minecraft從特定角度呈現,且陰影面的顏色也一並呈現
頗具3D立體感


2. 陳奕中
多曲折跟多色的展現,與原圖極相似


3. 莊昀笙
除了顏色少了些,其他與原圖相似


4. 李耀民
可愛可愛還是可愛


5. 自己
當然是要給自己一些鼓勵哈哈

課堂作業2:

操作Transformation程式
使汽車或其他內建圖形變形
glTranslatef 為平行移動有3個方向
glRotatef 為繞軸轉動
glScale 為放大縮小也具有3個方向


課堂作業3:

增加程式,使得能用滑鼠點圖得知像素位置
使圖像展示更為快速


------------------------------------今日程式1------------------------------------

#include <GL/glut.h>
#include <stdio.h>
void mouse(int button,int state,int x,int y)  //今日新增 滑鼠函式
{
    if(state==GLUT_DOWN)
        printf("  glVertex2f((%d-150)/150.0,-(%d-150)/150.0);\n",x,y); //印出至黑窗方便複製
}
void display()
{
    glClearColor(150/255.0,170/255.0,55/255.0,1);  //背景色
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3ub(175,193,81);

    glBegin(GL_POLYGON);
      //過長省略//
    glEnd();
 
    glutSwapBuffers();
}
int main(int argc,char**argv)
{
        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
        glutCreateWindow("hello");
        glutDisplayFunc(display);
        glutMouseFunc(mouse); //今日新增滑鼠函式
        glutMainLoop();
}

-------------------------------------------------------------------------------------


課堂作業4:

畫出3個圓,且位置不重疊
而紅框部分為上一part所講的滑鼠取點,方便作圖

------------------------------------今日程式2------------------------------------

#include <GL/glut.h>
#include <stdio.h>
#include <math.h>  //增加數學運算標頭檔
void mouse(int button,int state,int x,int y)
{
    if(state==GLUT_DOWN)
        printf("  glVertex2f((%d-150)/150.0,-(%d-150)/150.0);\n",x,y);
}
void display()
{
    glClearColor(150/255.0,170/255.0,55/255.0,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3ub(175,193,81);

    glPushMatrix();  //重複以下程式產生多個圓
    glTranslatef(0,0.5,0);  //中心點位置移動
    glBegin(GL_POLYGON);
        for(float angle=0;angle<3.14159*2;angle+=0.1)  //迴圈以cos sin數學繞圓
        {
            glVertex2f(0.2*cos(angle),0.2*sin(angle));
        }
    glEnd();
    glPopMatrix();  //重複以上程式產生多個圓
    
    glutSwapBuffers();
}
int main(int argc,char**argv)
{
        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
        glutCreateWindow("hello");
        glutDisplayFunc(display);
        glutMouseFunc(mouse);
        glutMainLoop();
}

-------------------------------------------------------------------------------------


沒有留言:

張貼留言