- Leap Motion的使用與安裝
-Leap Motion App Store
-Leap Motion Play
- Leap Motion的設計
- 手機紅外線照相機
本日上課小記
- Leap Motion使用與安裝
找到Leap Motion的官網並且下載驅動程式
之後再啟動,
啟動後即可使用Leap Motion App Home,
從AppHome內可以找到許多的程式來玩
PopPop:
- Leap Motion程式設計
下載好函式庫後,
開啟範例程式測試是否成功:
接下來再進行程式碼的編寫
=======================================================================
import de.voidplus.leapmotion.*; 抓出函式
LeapMotion leap;
void setup(){
size(640,480);
leap=new LeapMotion(this);
}
void draw(){
background(200);
for(Hand hand : leap.getHands()){ 這個for的寫法是以gethand的次數來進行for迴圈
hand.draw();
}
}
從文件檔案中的reference可以用來查指令
=======================================
import de.voidplus.leapmotion.*; 畫手指頭
LeapMotion leap;
void setup(){
size(640,480);
leap=new LeapMotion(this);
}
void draw(){
background(200);
for(Hand hand : leap.getHands()){
hand.draw();
for(Finger finger : hand.getFingers()){
finger.drawJoints();
}
}
}
=======================================
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(640,480);
leap=new LeapMotion(this);
}
void draw(){
background(200);
coinY += coinVY; 讓金幣可以有一個速度改變Y座標(往下掉)
for(Hand hand : leap.getHands()){
hand.draw();
PVector pos = hand.getPosition(); 抓取座標位置
//println(pos);
fill(200,0,0); 弄顆球
ellipse(pos.x,pos.y,50,50); 球的位子在手上 (posx posy)
for(Finger finger : hand.getFingers()){
finger.drawJoints();
}
}
}
=====================================================================
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
size(640,480);
leap=new LeapMotion(this);
}
float coinX=320,coinY=0,coinVX=0,coinVY=3,colorX=255,colorY=255,colorZ=0;
int score=0;
void draw(){
background(255);
coinY += coinVY;
fill(colorX,colorY,colorZ);
ellipse(coinX,coinY,60,60);
if(coinY>480){
coinY=0;
coinX=random(640);
}
for(Hand hand : leap.getHands()){
//hand.draw();
Finger finger= hand.getIndexFinger();
finger.drawBones();
PVector pos = hand.getPosition();
//println(pos);
if(dist(pos.x,pos.y,coinX,coinY)<100){
score += 10;
coinY=0;
coinX=random(640);
colorX=random(255); 彩球
colorY=random(255);
colorZ=random(255);
fill(colorX,colorY,colorZ);
}
}
fill(0,200,20);
textSize(50);
text("Score:" + score,400,100);
}
===================================================================
沒有留言:
張貼留言