顯示具有 01160226_陳亮瑜 標籤的文章。 顯示所有文章
顯示具有 01160226_陳亮瑜 標籤的文章。 顯示所有文章

2016年5月5日 星期四

01160226_陳亮瑜_week11

今天用了新的設備,kinect toolkit
所以就下載來試試看

再來就是玩kinect Fusion Explore可儲存影像,並在MeshLab中開啟

踢足球:
import SimpleOpenNI.*;
SimpleOpenNI openni;
void setup(){
 size=(600,400);
openni=new SimpleOpenNI(this);
openni.enableRGB();
openni.enableDepth();
openni.enableUser();
}
void draw(){
   openni.update();
   image(openni.userImage(),0,0,600,400);
   for(int userId:openni.getUsers()){
   PVector pos=new Pvector(0,0,0);
   float confidence=openni.getJointPositionSkeleton(userId.SimpleOpenNI.SKEL_HEAD.pos);
   ellipse(pos.x,pos.y,50,50);
   printIn(pos);
}

}
void onNewUser(SimpleOpenNI openni,int userId){
openni.startTrackingSkeleton(userId);
}


以上這兩張圖是腳踢到球的時候,螢幕出現紅線閃爍畫面,代表偵測到了。

2016年3月17日 星期四

01160226_陳亮瑜, week04


今天老師所教的是射擊遊戲跟打棒球,
一開始先用基本的小方塊來,後面讓子彈可以發射出去。
最後教我們的是棒子打球,
最後那張圖就是我們所看到的球,棒子則是用方塊代替。
剛好其中作品也是要做棒子打球的遊戲,原本毫無頭續,
但經過了這門課,讓我了解了不少,作品也更有頭緒。






棒子打球程式碼:
import de.voidplus.leapmotion.*;
LeapMotion leap;
PVector pos, dir, ball;
void setup(){
  size(600,400, P3D);
  leap = new LeapMotion(this);
  pos = new PVector(300,200,0); ball=new PVector(0,0,0);
}
void draw(){
  ball.x +=2; ball.y += 2;
  for(Hand hand : leap.getHands()){
    pos = hand.getPosition();
  }
  background(255);
  fill(255,0,0);
  pushMatrix();
     translate(pos.x, pos.y, pos.z);
     box(30,30,30);
     popMatrix();
  pushMatrix();
      translate(ball.x, ball.y);
      sphere(30);
      if(dist(ball.x, ball.y, pos.x, pos.y)<30)  background(255,0,0);
  popMatrix();
}

2016年3月10日 星期四

01160226_陳亮瑜, week03


import de.voidplus.leapmotion.*;//LeapMotion標頭檔
LeapMotion leap;
PVector [][] pt = new PVector[5][50];
//PVector pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10;
void setup(){
  size(640,480,P3D);
  colorMode(HSB, 100);
  for(int f=0;f<5;f++)
    for(int i=0;i<50;i++)
      pt[f][i] = new PVector(0,0,0);
  leap = new LeapMotion(this);//LeapMotion起始值

}
void draw(){
  background(0);
  //stroke(48,191,153);
  stroke(#30BF99);
  for(int f=0;f<5;f++)
    for(int i=49;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<10;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);
  }
}


















2016年3月3日 星期四

01160226_陳亮瑜, week02

這是今天第二周老師所交的
圖中是我所畫的黑線
後來這些現就有顏色了