顯示具有 40447024S_黃筱婷 標籤的文章。 顯示所有文章
顯示具有 40447024S_黃筱婷 標籤的文章。 顯示所有文章

2017年12月28日 星期四

2017年12月14日 星期四

黃筱婷計圖筆記week14

prcoessing
1.
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);vertex(100,500);
endShape();

2.
void setup()
{size(600,600,P3D);
}
void draw()
{
  background(255);
beginShape(TRIANGLE);
beginShape(TRIANGLE);
fill(255,0,0);vertex(100,100,0);
fill(255,0,255);vertex(100,500,100);
fill(255,255,0);vertex(500,500,0);

endShape();
beginShape(TRIANGLE);
fill(0,255,0);vertex(500,100,0);
fill(0,255,255);vertex(500,500,100);
fill(255,255,0);vertex(100,500,0);
endShape();}

3.學姊的馬力歐程式
3D上下左右移動,跳躍

2017年12月7日 星期四

黃筱婷計圖筆記week13

1.色彩系統
(用processing)
size(255,255);
colorMode(HSB,255);
for(int x=0;x<255;x++){
for(int y=0;y<255;y++){
  stroke(x,y,255);
  point(x,y);
}
}

2.多重貼圖
roach專案

不可以在display裡讀圖檔
3.
size(360,360);
colorMode(HSB,360);
for(int i=0;i<360;i++){
for(int j=0;j<360;j++){
  stroke(134,abs(i-180),360);
  point(i,j);
}}


2017年11月30日 星期四

黃筱婷計圖筆記week12

  1.開opengl專案檔,將main改成 myGL_Frustrum221 裡的main,
改!
int main(int argc,char**argv)
{
    glutInit(&argc,argv);

還有setting 裡compiler第2個不要勾


2.下載processing
安裝Picking Pick an object in a 3D scene easily.Collada Loader for SketchUp and Blender 3.1


文件 ,範例程式,contributed Librarise ,viewer2D


文件 ,範例程式,picking,simple

3.解壓縮testBVH.zip
執行

2017年11月23日 星期四

黃筱婷的計圖筆記week11

Playsound() 一行發聲
1.開glut檔
  在main.cpp裡加入
  #include<mmsystem.h>//使用Multimedia System多媒體系統
int main(int argc, char *argv[])
{
    PlaySoundA("file.wav",NULL, SND_SYNC);
  //要讓他有聲音,檔名;在哪裡:如何播(SND_SYNC SND_ASYNC)
                                                                        等同步           不等 下一行繼續
 (將聲音檔放進C:\Users\user\Desktop\freeglut\bin)
2.播音樂檔
#include<stdio.h>
#include"CMP3_MCI.h"//老師給的檔案
CMP3_MCI mp3;//int a ;宣告變數
int main()
{
    mp3.Load("file.mp3");//讀入 mp3檔
    mp3.Play();//Play播放mp3檔
    printf("等輸入\n");
    int a;
    scanf("%d",&a);
}
(CMP3_MCI.h放進專案檔案)
3.下載processing
   到速寫本->引用庫文件->添加
   搜尋sound,install Minim~~~
import ddf.minim.*;//use dff ' minim music library
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.下載processing
   將java addMode改成Android模式
2.自動安裝Android SDK
3.
void setup()
{
 fullScreen();
}
void draw()
{
 if(mousePressed)background(255,0,0);
 else background(0,255,0);
}

2017年11月9日 星期四

黃筱婷week09計圖筆記

BUMP Mappingl 凹凸貼圖
1.https://www.openprocessing.org/sketch/249457

2.moddle下載processing-3.3.6-windows64.zip解壓縮

random()參數隨便設
3.執行

4.上網找圖案,存檔再拖進程式禮
PImage img=loadImage("labi.png");
size(600,600);
image(img,0,0,600,600);
執行:

5.
PImage img;
void setup()
{
 size(1280,800);
 img=loadImage("error.png");
}
void draw()
{
 //rect(mouseX,mouseY,50,50);
 image(img,mouseX,mouseY);
}

6.

PImage imgMario,imgBrick;

void setup()
{
  size(800,600);
 imgMario=loadImage("mario.png");
 imgBrick=loadImage("brick.png");
}
void draw()
{
 background(255);
 for(int x=0;x<18;x++)image(imgBrick,x*50,500,50,50);
 image(imgMario,mouseX,mouseY,100,100);
}
7.
int [][]map={{0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,1,1,2,2,1,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
              {1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
PImage imgMario,imgBrick,imgBrick2;

void setup()
{
  size(800,600);
 imgMario=loadImage("mario.png");
 imgBrick=loadImage("brick.png");
 imgBrick=loadImage("brick2.png");
}
float marioX=200,marioY=100,marioVX=0,marioVY=0;
boolean marioOnFloor=false;
void draw()
{
 background(255);
 //for(int x=0;x<18;x++)image(imgBrick,x*50,500,50,50);
 for(int x=0;x<14;x++){
   for(int y=0;y<14;y++){
     if(map[y][x]==1) image(imgBrick,x*50,y*50,50,50);
     if(map[y][x]==2) image(imgBrick2,x*50,y*50,50,50);
   }
 }
 image(imgMario,mouseX,mouseY,100,100);
 marioY += marioVY;marioX += marioVX;
 marioVY +=0.98;
 if(marioY>=500-80){marioY=500-80;marioVY=0;marioOnFloor=true;}
}
void keyPressed(){
 if(keyCode==UP && marioOnFloor){ marioVY=-15;marioOnFloor=false;}
  if(keyCode==RIGHT) marioVX=5;
  if(keyCode==LEFT) marioVX=-5;
}
void keyReleased(){
  if(keyCode==RIGHT|| keyCode==LEFT) marioVX=0;
}

2017年11月2日 星期四

黃筱婷計圖筆記week08

1.jsyeh.org/3dcg10下載source、data、win32、glut32.dll,
  windows資料夾加入data資料夾、glut32.dll

2.下載OpenCV
點第3個
存C槽

3.project->console application

#include<opencv/highgui.h>
int main()
{
    IplImage * img=cvLoadImage("earth.jpg");
    cvNamedWindow("hello opencv");
    cvShowImage("hello opencv",img);
    cvWaitKey(0);
}

找地圖圖片earth.jpg

點week08 project的built options
(1)project build options->search directories->Compiler->add->C:\OpenCV2.1\include

(2)project build options->search directories->Linker->add->C:\OpenCV2.1\lib

(3)project build options->Linker setting->add->cv210、cxcore210、highgui210

4.開glut專案week08-2
重複project的built options

earth.jpg放入freeglut->bin

#include <opencv/highgui.h>///
int main(int argc, char *argv[])
{
    IplImage * img=cvLoadImage("earth.jpg");
    cvNamedWindow("OpenCV");
    cvShowImage("OpenCV", img);
    ///cvWaitKey(0);


5.執行老師的程式~~~
地球就會轉~~~



2017年10月26日 星期四

黃筱婷計圖筆記week07

1.開glut專案

GLfloat light_position[] = { 2.0f, 5.0f, 5.0f, 0.0f };///const刪掉
加入
void motion(int x,int y)
{
    light_position[0]=(x-150)/150.0*2;
    light_position[1]=-(y-150)/150.0*2;
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glutPostRedisplay();
}
main函式多
glutMotionFunc(motion);
2.
打光(左)

打光(右)

2017年10月19日 星期四

黃筱婷計圖筆記week06

1.在week05檔案中加入
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);///3D深度測試,清depth buffer才能正確繪圖
    drawmodel();
    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);///3D深度測試,有準備好depth buffer記憶體
    glutCreateWindow("week05");

    glutDisplayFunc(display);
    glEnable(GL_DEPTH_TEST);3D深度測試,打開Enable
    glEnable(GL_LIGHTING);///打光,打開Enable
    glEnable(GL_LIGHT0);///打光,打開Enable
    glLightfv(GL_LIGHT0,GL_POSITION,pos);
    glutMainLoop();
}


2.可以在視窗按按鍵、增加滑鼠功能
加入
   #include<stdio.h>
  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)
{

}

glutMouseFunc(mouse);///41
glutKeyboardFunc(keyboard);///42


3.keyboard讓他轉動
int rotateX=0,rotateY=0,rotateZ=0;
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 mouse(int button,int state,int x,int y)
{
    printf("button:%d state:%d(%d %d)\n",button,state,x,y);
}
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glRotatef(rotateX,1,0,0);
    glRotatef(rotateY,0,1,0);
    drawmodel();
    glutSwapBuffers();
}

4.用mouse讓他轉
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;
    }
}
void motion(int x,int y)
{
    rotateY += -(x-oldX);
    rotateX += -(y-oldY);
    oldX=x;
    oldY=y;
    glutPostRedisplay();
}
main裡
glutKeyboardFunc(keyboard);///有mouse motion (dragging)


2017年10月12日 星期四

黃筱婷計圖筆記week05

1.到jsyeh/3dcg10下載data和win32和glut32.dll放到week05資料夾,
    解壓縮後將glut32,dll和data複 製windows的資料夾
    
2.執行Transformation.exe
    (用滑鼠移動,r = reset)
    
3.執行Projection.exe(投影)
  (1) gluPerspective(fovy,aspect,zNear,zFar)
                            視野   y/x比例
   
 (2)glOrtho(左、右、下、上、近、遠)
      glFrustum(                                        )
 (3)gluLookAt(eyeX,eyeY,eyeZ
                         centerX,centerY,centerZ
                         upX,upY,upZ)
4.
  
     

2017年10月5日 星期四

黃筱婷的計圖筆記4

1.下載codeblocks
2.  freeglut解壓縮,
    再把桌面\freeglut\lib\libfreeglut.a
                                 複製libglut32.a
3.file-new-project   GLUT專案
--------------------
1.改display()函式
加入53,61,69行glColor3f(1,0,1);glutSolidTeapot(1);
                                改顏色          加茶壺

2.旋轉

3.glRotatef(角度,x,y,z)
                浮點數     
   glRotatef(60,1,0,0);對x軸旋轉60度
   glRotatef(a,0,0,1);
4.把glRotatef註解掉 不旋轉

5.只看第二個圖旋轉(右手座標系統)
       glPushMatrix();
        glTranslatef(0,1.2,-6);
        ///glRotatef(60,1,0,0);
        glRotatef(a,1,1,0);   /
        glColor3f(1,1,1);glutSolidTeapot(1);///
        glutSolidCone(1,1,slices,stacks);
        glPopMatrix();
6.加入glScalef(0.2,0.2,0.2);縮放0.2倍
-------
程式碼:
        glPushMatrix();備份矩陣
        glTranslatef(0,1.2,-6);移動
        ///glRotatef(60,1,0,0);旋轉
        glRotatef(a,1,1,0);
        glScalef(0.2,0.2,0.2);放大縮小
        glColor3f(1,1,1);glutSolidTeapot(1);///
        glutSolidCone(1,1,slices,stacks);
        glPopMatrix();還原矩陣
----------

7.滑鼠拖曳

2017年9月28日 星期四

黃筱婷的計圖筆記3

1.將minion.txt放進bin資料夾裡
2.開glut專案檔,把學姐的hw1.c複製到專案的main中,執行
( glPointSize(10.0f);把點放大10倍)
/////////////
1.到jsyeh/3dcg10的data按右鍵另存連結到桌面,解壓縮data

2.到3d exploration download

3.將data裡的3D檔拉到3d exploration選soccerball save as cpp檔

4.開一個openGL的專案

5.將soccerball.cpp以notepad開啟,複製到專案裡的main,把main.c改成main.cpp
6.3280~3306註解

7.f9