2015年6月29日 星期一
2015年5月25日 星期一
2015年5月18日 星期一
2015年5月11日 星期一
week12
import SimpleOpenNI.*;
SimpleOpenNI openni;
void setup(){
size(640,480);
openni = new SimpleOpenNI(this);
openni.enableRGB();
openni.enableDepth();
openni.enableUser();
}
void draw(){
background(255);
openni.update();
image(openni.userImage(), 0, 0, 640, 480);
int[] userList = openni.getUsers();
for(int i=0;i<userList.length;i++)
{
PVector pos = new PVector();
openni.getJointPositionSkeleton( userList[i], SimpleOpenNI.SKEL_LEFT_HIP, pos);
println(pos);
}
}
SimpleOpenNI openni;
void setup(){
size(640,480);
openni = new SimpleOpenNI(this);
openni.enableRGB();
openni.enableDepth();
openni.enableUser();
}
void draw(){
background(255);
openni.update();
image(openni.userImage(), 0, 0, 640, 480);
int[] userList = openni.getUsers();
for(int i=0;i<userList.length;i++)
{
PVector pos = new PVector();
openni.getJointPositionSkeleton( userList[i], SimpleOpenNI.SKEL_LEFT_HIP, pos);
println(pos);
}
}
2015年5月4日 星期一
week11
import SimpleOpenNI.*;
SimpleOpenNI context;
void setup()
{
size(640*2, 480);
context = new SimpleOpenNI(this);
if (context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
// mirror is by default enabled
context.setMirror(true);
// enable depthMap generation
context.enableDepth();
// enable ir generation
context.enableRGB();
}
void draw()
{
// update the cam
context.update();
background(200, 0, 0);
// draw depthImageMap
image(context.depthImage(), 0, 0);
// draw irImageMap
image(context.rgbImage(), context.depthWidth() + 10, 0);
}
------------------------------------------------------------
import SimpleOpenNI.*;
SimpleOpenNI context;
float zoomF =0.3f;
float rotX = radians(180); // by default rotate the hole scene 180deg around the x-axis,
// the data from openni comes upside down
float rotY = radians(0);
void setup()
{
size(1024,768,P3D);
context = new SimpleOpenNI(this);
if(context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}
// disable mirror
context.setMirror(false);
// enable depthMap generation
context.enableDepth();
stroke(255,255,255);
smooth();
perspective(radians(45),
float(width)/float(height),
10,150000);
}
void draw()
{
// update the cam
context.update();
background(0,0,0);
translate(width/2, height/2, 0);
rotateX(rotX);
rotateY(rotY);
scale(zoomF);
int[] depthMap = context.depthMap();
int steps = 3; // to speed up the drawing, draw every third point
int index;
PVector realWorldPoint;
translate(0,0,-1000); // set the rotation center of the scene 1000 infront of the camera
stroke(255);
PVector[] realWorldMap = context.depthMapRealWorld();
// draw pointcloud
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=steps)
{
for(int x=0;x < context.depthWidth();x+=steps)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
// realWorldPoint = context.depthMapRealWorld()[index];
realWorldPoint = realWorldMap[index];
vertex(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z); // make realworld z negative, in the 3d drawing coordsystem +z points in the direction of the eye
}
//println("x: " + x + " y: " + y);
}
}
endShape();
// draw the kinect cam
context.drawCamFrustum();
}
void keyPressed()
{
switch(key)
{
case ' ':
context.setMirror(!context.mirror());
break;
}
switch(keyCode)
{
case LEFT:
rotY += 0.1f;
break;
case RIGHT:
// zoom out
rotY -= 0.1f;
break;
case UP:
if(keyEvent.isShiftDown())
zoomF += 0.02f;
else
rotX += 0.1f;
break;
case DOWN:
if(keyEvent.isShiftDown())
{
zoomF -= 0.02f;
if(zoomF < 0.01)
zoomF = 0.01;
}
else
rotX -= 0.1f;
break;
}
}
2015年4月27日 星期一
2015年4月13日 星期一
期中報告進度
遊戲名稱:快速變幻球
這是一個考你反應的遊戲
用你最快的速度去碰到畫面上隨機出現的球
import de.voidplus.leapmotion.*;
PImage img;
LeapMotion leap;
void setup() {
size(1600, 850, P3D);
leap=new LeapMotion(this);
}
void draw() {
img = loadImage("123.jpg");
background(255);
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(0, 50, 100);
stroke(0);
image(img,0,0);
}
}
這是一個考你反應的遊戲
用你最快的速度去碰到畫面上隨機出現的球
import de.voidplus.leapmotion.*;
PImage img;
LeapMotion leap;
void setup() {
size(1600, 850, P3D);
leap=new LeapMotion(this);
}
void draw() {
img = loadImage("123.jpg");
background(255);
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(0, 50, 100);
stroke(0);
image(img,0,0);
}
}
2015年3月16日 星期一
week04
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
float nowX=0,nowY=0,nowA=0;
void draw() {
nowY+=cos(nowA);nowX+=sin(nowA);
background(255);
for (int i=-10; i<=10; i++) {
for (int j=-10; j<=10; j++) {
pushMatrix();
translate(300, 300);
rotateX(radians(70));
rotateZ(nowA);
translate(i*200+nowX, j*200+nowY,0);
fill(255);box(200);
popMatrix();
}
}
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
nowA+=radians(-angle/40);
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
}
}
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
float nowX=0,nowY=0,nowA=0;
void draw() {
nowY+=cos(nowA);nowX+=sin(nowA);
background(255);
for (int i=-10; i<=10; i++) {
for (int j=-10; j<=10; j++) {
pushMatrix();
translate(300, 300);
rotateX(radians(70));
rotateZ(nowA);
translate(i*200+nowX, j*200+nowY,0);
fill(255);box(200);
popMatrix();
}
}
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
nowA+=radians(-angle/40);
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
}
}
week04
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
float groundDir=0;
void draw() {
background(255);
for (int i=-10; i<=10; i++) {
for (int j=-10; j<=10; j++) {
pushMatrix();
translate(300, 300);
rotateX(radians(70));
rotateZ(radians(groundDir));
translate(i*30, j*30);
box(30);
popMatrix();
}
}
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
groundDir=-angle;
}
}
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
float groundDir=0;
void draw() {
background(255);
for (int i=-10; i<=10; i++) {
for (int j=-10; j<=10; j++) {
pushMatrix();
translate(300, 300);
rotateX(radians(70));
rotateZ(radians(groundDir));
translate(i*30, j*30);
box(30);
popMatrix();
}
}
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
groundDir=-angle;
}
}
week4
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
void draw() {
background(255);
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
}
}
LeapMotion leap;
void setup() {
size(600, 600, P3D);
leap=new LeapMotion(this);
}
void draw() {
background(255);
for (Hand hand : leap.getHands ()) {
hand.draw();
float angle=hand.getYaw();
PVector pos=hand.getPosition();
translate(pos.x, pos.y, pos.z);
rotateY(-radians(angle));
fill(128);
stroke(0);
box(100);
}
}
訂閱:
文章 (Atom)











