//week13-1_processing_video
import processing.video.*; Capture video; Movie movie; void setup(){ size(640,960); video = new Capture(this, 640,480); video.start(); movie = new Movie(this, "street.mov"); movie.loop(); } void draw(){ if(video.available()) video.read(); image(video,0,480); if(movie.available()) movie.read(); image(movie,0,0); }//week13-2_camra_movie_eye_center_up //電腦圖學在繪圖時,會設定camra的相關係數 import processing.video.*;//要使用影片外掛 Movie movie;//要放影片的變數 void setup(){ size(720,480,P3D);//要記得加上P3D才能有OpenGL 3D功能 movie = new Movie(this, "street.mov"); movie.loop();//回圈播放 影片解析度720x480 } void draw(){ background(128); camera(mouseX,mouseY,500,360,240,0,0,1,0); if(movie.available()) movie.read();//有新畫面,就讀入 image(movie,0,0);//放影片,放在0, 0 }//week13_3_texture_textureMode_beginShape_vertex_endShape //先教(貼圖), 之後再加進去 PImage img; void setup(){ size(400,400,P3D);//要P3D才有OpenGL 3D功能 img = loadImage("chessboard.png");//把圖檔(拉進來) textureMode(NORMAL);//有很多種(貼圖的模式) } void draw(){ background(128);//灰背景 beginShape();//開始畫 texture(img);//把貼圖,當貼圖 vertex(40,80,0,0);//4個頂點vertex的四邊形,會裁出2個三角形 vertex(320,20,1,0); vertex(380,360,1,1); vertex(160,380,0,1); endShape(); }//week13-4_camera_chessboard_texture_front_left //把貼圖跟camra整合 PImage img; void setup(){ size(400,400,P3D); img = loadImage("chessboard.png"); textureMode(NORMAL); } void draw(){ camera(mouseX,200,mouseY, mouseX, 200,mouseY-10,0,1,0); background(128); beginShape();//front正前方,z座標都放0 texture(img); vertex(0,0,0,0,0);//x,y,z,u,v vertex(400,0,0,1,0); vertex(400,400,0,1,1); vertex(0,400,0,0,1); endShape(); beginShape();//left左方,x座標都放0 texture(img); vertex(0,0,0,0,0); vertex(0,400,0,1,0); vertex(0,400,400,1,1); vertex(0,0,400,0,1); endShape(); }//week13-5-camera-keyPressed-keyCode-x-y-z-angle-cos-sin //修改自week13-4 PImage img; void setup(){ size(400,400,P3D); img = loadImage("chessboard.png");//要拉入圖檔 textureMode(NORMAL); } float x=200,y=200,z=200,angle=180; void keyPressed(){ if(keyCode==LEFT) angle--; if(keyCode==RIGHT) angle++; if(keyCode==UP){ x+=cos(radians(angle)); z+=sin(radians(angle));//是Z不是Y } if(keyCode==DOWN){ x-=cos(radians(angle)); z-=sin(radians(angle)); } } void draw(){//攝影機往前方看 左右前後移動 if(keyPressed) keyPressed();//補強 按鍵按下去不斷更新 //camera(mouseX,200,mouseY,mouseX,200,mouseY-10,0,1,0); camera(x,y,z,x+cos(radians(angle)),y,z+sin(radians(angle)),0,1,0); background(128); beginShape();//front 正前方 texture(img); vertex(0,0,0,0,0); vertex(400,0,0,1,0); vertex(400,400,1,1); vertex(0,400,0,0,1); endShape(); beginShape();//left左方 texture(img); vertex(0,0,0,0,0);//x y z u v vertex(0,400,0,1,0); vertex(0,400,400,1,1); vertex(0,0,400,0,1); endShape(); }//week13-6 //把今天教的加進來 //圖檔影片檔拉進來 import processing.video.*;//要使用影片外掛 Movie movie;//要放影片變數 PImage img; void setup() { size(400, 400, P3D); img = loadImage("chessboard.png"); movie = new Movie(this, "street.mov"); movie.loop(); textureMode(NORMAL); video = new Capture(this,640,480); video.start(); } Capture video; void draw() { camera(200,200,200,200+cos(radians(frameCount)),200,200+sin(radians(frameCount)),0,1,0); background(128); if (movie.available()) movie.read();//有新畫面 就讀入 beginShape();//front 正前方 texture(img); vertex(0,0,0,0,0); vertex(400,0,0,1,0); vertex(400,400,1,1); vertex(0,400,0,0,1); endShape(); translate(0,0,1); image(movie,0,0,360,240); if (video.available()) video.read();//有新畫面 就讀入 beginShape();//left左方 texture(video); vertex(0,0,0,0,0);//x y z u v vertex(0,400,0,1,0); vertex(0,400,400,1,1); vertex(0,0,400,0,1); endShape(); beginShape(); texture(video); }

沒有留言:
張貼留言