2016體感互動
2016年7月3日 星期日
01160235_謝采玲, Week16
W16 期末作品製作
遇到的問題:
Q1
如何讓 Kinect 和 Unity 結合使用
不使用 FAAST
(此方法需要抓手的點,雖然精準,但非常費時)
Q2
Collider不會跟隨手移動
是跟著整個身體的座標
Q3
當左手碰到Sensor時
依右手和左的高度差去控制地板翻轉
但是發現左手太累了
Q4
在Maya製作場地模型
匯入Unity之後
加入Mesh Collider
球無法掉進洞裡
最後決定用 FAAST 來當控制的工具
前置作業:
參考其他相同遊戲
2016年6月27日 星期一
week11
首先是載Kinect SDK和Toolkit接下來是載MeshLab再來是做利用kinect scan 然後做踢足球的概念,
所以圖中會出現圓圈
利用Toolkit, Kinect fusion color basics-D2D
踢球
程式碼:
import SimpleOpenNI.*;
SimpleOpenNI openni;
void setup(){
size(600,400);
openni = new SimpleOpenNI(this);
openni.enableRGB();
openni.enableDepth();
openni.enableUser();
}
float Xpos(PVector pos){
return width/2 + pos.x*500/pos.z;
}
float Ypos(PVector pos){
return height/2 - pos.y*500/pos.z;
}
void draw(){
openni.update();
image(openni.userImage(),0,0, 600,400);
for(int userId : openni.getUsers()){
PVector pos = new PVector(0,0,0);
float cofidence;
cofidence = openni.getJointPositionSkeleton(
userId,SimpleOpenNI.SKEL_LEFT_FOOT,pos);
ellipse(Xpos(pos),Ypos(pos), 50,50);
println(pos);
}
}
void onNewUser(SimpleOpenNI openni,int userId){
openni.startTrackingSkeleton(userId);
}
week05
畫會動的眼睛眼球
程式碼:
void setup(){
size(120,120);
}
void draw(){
float t =frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50, 33,33);
ellipse(120-40,50,33,33);
fill(0);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
ellipse(123-40+15*cos(t),50+15*sin(t),5,5);
}
用滑鼠控制眼球 做出鬥雞眼
程式碼:
void setup(){
size(120,120);
}
void draw(){
//float t =frameCount/180.0*PI;
background(0);
fill(255);
ellipse(40,50, 33,33);
ellipse(120-40,50,33,33);
fill(0);
float t=atan2(mouseY-50,mouseX-45);
ellipse(40+15*cos(t),50+15*sin(t),5,5);
t=atan2(mouseY-50,mouseX-(120-40));
ellipse(123-40+15*cos(t),50+15*sin(t),5,5);
}
雙螺旋轉動
程式碼:
void setup(){
size(600,600);
}
void draw(){
//float t =frameCount/180.0*PI;
background(0);
float t=frameCount/100.0;
for(float f=0; f<PI; f+=0.1){
rect(200+150*cos(f+t),f*100,30,30);
rect(200+150*cos(f+t+PI),f*100,30,30);
}
}
01160351 游承諭 04
發射子彈的砲台
程式碼如下:
PVector []bullet_dir=new PVector[10];
int bulletNow=0;
LeapMotion leap;
void setup(){
size(600,400,P3D);
leap=new LeapMotion(this);
for(int i=0;i<10;i++){
bullet[i]=new PVector(0,0,0);
bullet_dir[i]=new PVector(0,0,0);
}
}
void draw(){
background(255);
for(Hand hand:leap.getHands()){
Finger finger_index=hand.getIndexFinger();
finger_index.draw();
pos=finger_index.getPosition();
dir=finger_index.getDirection();
}
lights();
fill(255,0,0);
translate(width/2,height/2);
pushMatrix();
for(int i=0;i<10;i++){
if(dir!=null) translate(dir.x*10*i,dir.y*10*i,dir.z*10*i);
sphere(40);
}
popMatrix();
pushMatrix();
fill(0,0,255);
for(int i=0;i<10;i++){
pushMatrix();
translate(bullet[i].x,bullet[i].y,bullet[i].z);
sphere(41);
bullet[i].x+=bullet_dir[i].x;
bullet[i].y+=bullet_dir[i].y;
bullet[i].z+=bullet_dir[i].z;
popMatrix();
}
popMatrix();
}
void keyPressed(){
bullet[bulletNow].x=0; bullet[bulletNow].y=0; bullet[bulletNow].z=0;
bullet_dir[bulletNow].x=dir.x*5;
bullet_dir[bulletNow].y=dir.y*5;
bullet_dir[bulletNow].z=dir.z*5;
bulletNow++;
if(bulletNow>=10){
bulletNow=0;
}
}
打擊遊戲 當物體跟物體碰撞後會加分etc.
程式碼如下:
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年6月20日 星期一
訂閱:
文章 (Atom)