顯示具有 40347037S_施宇修 標籤的文章。 顯示所有文章
顯示具有 40347037S_施宇修 標籤的文章。 顯示所有文章

2017年12月14日 星期四

施宇修的學習筆記week14

size(600,600,P3D);
background(255);
beginShape(TRIANGLE);
  fill(255,0,0);vertex(300,100);
  fill(255,255,0);vertex(500,500);
  fill(0,0,255);vertex(100,500);
endShape();
畫三角形,每個頂點填不同顏色



2017年11月23日 星期四

施宇修的學習筆記week11


1.glut project播放mp3格式的音樂
#include <stdio.h>
#include "CMP3_MCI.h" ///使用外掛,可在FB下載
CMP3_MCI mp3;/// int a; 宣告變數
int main()
{
mp3.Load("file.mp3");///讀入 mp3檔
mp3.Play();///Play播放mp3檔
///PlaySoundA("file.wav", NULL, SND_SYNC);//SYNC表示同步//ASYNC表示會繼續執行
printf("現在在待輸入a\n");
int a;
scanf("%d", &a);///等待輸入時,程式還沒結束,為了要音樂
}

音樂檔都放在freeglut/bin
2.processing 播音樂
先新增Minim

import ddf.minim.*;
Minim minim;
AudioPlayer player;
AudioPlayer player2;
void setup(){
  minim = new Minim(this);
  player = minim.loadFile("file.mp3");
  player.play();
}
void draw(){
}

2017年11月16日 星期四

施宇修的學習筆記week10

1.寫app
2.碰撞的球
if(ballX>450||ballX<50){
  ballVX=-ballVX;
}
if(ballY<50||ballY>450){
  ballVY=-ballVY;
}

2017年11月9日 星期四

施宇修的學習筆記week09

1.網址體驗bump mapping

2.processing執行
    貼程式碼過去
3.寫簡單程式
PImage img=loadImage("檔名");
4.錯誤訊息
void draw(){
  image(img,mouseX,mouseY);//滑鼠拖曳
}

2017年11月2日 星期四

施宇修的學習筆記week08

opencv下載安裝
compiler settings

linker settings
下載moodle week08-2
jpg檔放到freeglut/bin


下載moodle week08-3


2017年10月19日 星期四

施宇修的學習筆記week06


#include <GL/glut.h>
#include<stdio.h>
#include "glm.h"
GLMmodel* pmodel = NULL;
int rotateX=0,rotateY=0,rotateZ=0;///旋轉軸
int oldX=0,oldY=0;///舊的座標
void keyboard(unsigned char key,int x,int y){
    printf("now : %c , (%d ,%d)\n",key,x,y);
    if(key=='1')rotateX++;///控制旋轉的方向
    else if(key=='2')rotateY++;
    else if(key=='3')rotateZ++;
    glutPostRedisplay();///立即更新畫面

}
void motion(int x,int y){
    rotateY+=-(x-oldX);///Y軸方向旋轉
    rotateX+=-(y-oldY);///X軸方向旋轉
    oldX=x;oldY=y;///更新座標
    glutPostRedisplay();
}
void mouse(int button,int state,int x,int y){
    printf("button: %d state: %d (%d %d)\n",button,state,x,y);
    if(state==GLUT_DOWN){///點下滑鼠
        oldX=x,oldY=y;
    }
}
drawmodel(void)
{
    if (!pmodel) {
pmodel = glmReadOBJ("data/al.obj");
if (!pmodel) exit(0);
glmUnitize(pmodel);
glmFacetNormals(pmodel);
glmVertexNormals(pmodel, 90.0);
    }

    glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);
}
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();
}
GLfloat pos[] = { 0.0, 0.0, -1.0, 0.0 };
int main(int argc, char**argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);

    glutCreateWindow("week06");
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);///註冊mouse
    glutMotionFunc(motion);///註冊motion

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glLightfv(GL_LIGHT0, GL_POSITION, pos);
    glEnable(GL_DEPTH_TEST);




    glutMainLoop();
}

施宇修的學習筆記week05


gluPerspective(fovy,aspect,zNear,zFar)
fovy視野
aspect y/x比例
glOrtho(左,右,下,上,近,遠)
glFrustum(...)
gluLookAt(eyex,eyey,eyez,
centerx,centery,centerz,
upx,upy,upz)



2017年10月5日 星期四

施宇修的學習筆記week04

移動的函式
glTranslatef(x,y,z);//float
glTranslated(x,y,z);//double

不同的形狀和大小
glutSolidDodecahedron
glutSolidCube(2);
glutSolidTeapot(3);

旋轉的函式
glRotatef(..,x,y,z);//..代表角度,x,y,z選軸
glRotated(..,x,y,z);

x軸>>>>右
y軸>>>>上
z軸>>>>前
p.s.負的表示反方向
glRotated(30,1,0,0);表示先沿著x軸轉30度

調整大小的函式
glScalef(x,y,z);對應的軸大小

2017年9月28日 星期四

施宇修的學習筆記 week03

minion.txt放在freeglut/bin











project內的main.cpp內容改成minion程式碼











編譯執行











3d exploration下載安裝













































2017年9月21日 星期四

施宇修學習筆記 week02




include 引入表頭檔(外掛)
main主程式
display是顯示函式
glClearColor(1,0,0,0);用來清的顏色
glutSolidTeapot(0.3);使用glut外掛
glutSwapBuffers();交換繪圖buffer
glBegin開始畫
GL_POLYGON多邊形
glVertex3f頂點,3f表示x,y,z
glEnd結束畫

2017年9月14日 星期四

施宇修的學習筆記 week01

查電腦IP
建專案

選OPENGL


完成


觀看結果

改檔名為libglut32
選glut


改glut路徑


觀看執行結果