2016年3月3日 星期四

week02_02160092

今天第一次上體感互動的課!
首先先設定proxy




















第一步驟是先上網google查leap motion setup下載windows安裝
然後開啟桌面的processing就會出現以下畫面

簡單寫了一個可以利用滑鼠繪畫的程式碼

在右下角把leapmotion按右鍵點Visualizer就有以下畫面


接著把視窗背景改成黑色然後筆的色彩改成綠色
後來把原本用滑鼠控制的改成利用leapmotion來控制筆

以下是最後呈現出來的程式碼!
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector[][]pt=new PVector[5][100];
void setup(){
  size(640,480,P3D);
  for(int f=0;f<5;f++){
    for(int i=0;i<100;i++)pt[f][i]=new PVector(0,0,0);
  }
  leap=new LeapMotion(this);
  colorMode(HSB,100);
}
void draw(){
  background(0);
  for(int f=0;f<5;f++){
    for(int i=99;i>0;i--){pt[f][i].x=pt[f][i-1].x;pt[f][i].y=pt[f][i-1].y;}
  }
  for(Hand hand:leap.getHands()){
    for(Finger finger:hand.getFingers()){
      int f=finger.getType();
      PVector now=finger.getPosition();
      pt[f][0].x=now.x;
      pt[f][0].y=now.y;
      }
  }
  for(int f=0;f<5;f++){
    stroke(f*20,100,100);
    for(int i=1;i<100;i++)
      line(pt[f][i].x,pt[f][i].y,pt[f][i].z,pt[f][i-1].x,pt[f][i-1].y,pt[f][i-1].z);
  }
}


沒有留言:

張貼留言