顯示具有 Week04 標籤的文章。 顯示所有文章
顯示具有 Week04 標籤的文章。 顯示所有文章

2015年5月18日 星期一

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);
  }
}

===

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600,600,P3D);
  leap = new LeapMotion(this);
}
float groundDir=0; //ground direction地板的方向
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;
  }
}

2015年3月16日 星期一

我會跟
陳奕安 同一組
題目
節奏遊戲

week04 許佳欣 _期中初做


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/40;
  }
}

移動前進
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);
  }
}





01160873_林瑋真


                                       手控制左右旋轉
                                       


week3

邱詠縉、劉冠逸 同一組



劃出模擬直升機

畫出跟著手旋轉的地板

可以隨著手的高度旋轉上下移動,模擬出上下飛的感覺



import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup() {
  size(800, 500, P3D);
   leap = new LeapMotion(this);
 }
 float nowX=0,nowY=0,nowA=0,nowZ=0;  
void draw() {  
  nowY+=10*cos(nowA); nowX+=10*sin(nowA);nowZ+=5*tan(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,nowZ);
          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




HW04,week04,00160530_吳坤曄

飛機的地板

飛機在綠地上自由飛行~

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600,600,P3D);
  leap=new LeapMotion(this);
}
float nowX=0,nowY,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

1. 追蹤手
2. 飛行模擬

/* 飛機的上下左右移動 */

float angleYaw = hand.getYaw();
float anglePitch = hand.getPitch();
float angleRoll = hand.getRoll();

rotateX(-radians(angleRoll));
rotateY(-radians(angleYaw));
rotateZ(radians(anglePitch));

/* -------------------------------------------------------------- */ 

/*  讓地板移動的秘訣  */

float nowX, nowY, nowA;

nowX += sin(nowA); nowY += cos(nowA);
for ( int i=-10; .........){
for ( int j=-10...........){
...
...
translate(i*200 + nowX, j*200 + nowY, -200);
...
...
}
}

for (Hand hand : leap.getHands()){
...
...

nowA += radians ( -angleYaw / 100 );
}


/*------------------------------------------------------------------*/

/* 本周最終程式碼 */
import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap = new LeapMotion(this);
}
float nowX, nowY, nowA;
void draw(){
  nowX += sin(nowA); nowY += cos(nowA);
  background(255);
  for (int i=-10; i<=10; i++){
    for (int j=-10; j<=10; j++){
      pushMatrix();
      translate(300, 300);
      rotateX(radians(80));
      rotateZ(nowA);
      translate(i*200 + nowX, j*200 + nowY, -200);
      fill(255); box(200);
      popMatrix();
    }
  }
  for (Hand hand : leap.getHands()){
    hand.draw();
    float angleYaw = hand.getYaw();
    float anglePitch = hand.getPitch();
    float angleRoll = hand.getRoll();
    PVector pos = hand.getPosition();
    translate(pos.x, pos.y, pos.z);
    rotateX(-radians(angleRoll));
    rotateY(-radians(angleYaw));
    rotateZ(radians(anglePitch));
    fill(128); stroke(0); box(80);
    nowA += radians( -angleYaw/100 );
  }
}
/*------------------------------------------------------------------------*/

第四周




Week04

Dropbox螢幕截圖:







Draw a box on your hand's center:

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap= new LeapMotion(this);
}
void draw(){
  background(255); //background redraw
  for(Hand hand: leap.getHands()){
    hand.draw();
    float angle= hand.getYaw(); //hand's angle
    PVector pos= hand.getPosition(); //hand's position
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(0, 100, 150);
    stroke(0);
    box(100);
  }
}




Fly to right, ground translate to left:

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600, 600, P3D);
  leap= new LeapMotion(this);
}
float groundDir=0;
void draw(){
  background(255); //background redraw
  //draw ground's box
  for(int i=-10;i<=10;i++){
    for(int j=-10;j<=10;j++){
      pushMatrix(); //matrix
      translate(300, 400); //ground's original x&y
      rotateX(radians(70));
      rotateZ(radians(groundDir));
      translate(i*30, j*30);
      fill(0, 150, 100);
      box(30);
      popMatrix(); //matrix
    }
  }
  for(Hand hand: leap.getHands()){
    hand.draw();
    float angle= hand.getYaw(); //hand's angle
    PVector pos= hand.getPosition(); //hand's position
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(0, 100, 150);
    stroke(0);
    box(100);
    
    groundDir= -angle;
  }
}




plane's motion:
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(0, 150, 200, 100); //background redraw
  //draw ground's box
  for(int i=-10;i<=10;i++){
    for(int j=-10;j<=10;j++){
      pushMatrix(); //matrix
      translate(300, 500); //ground's original x&y
      rotateX(radians(70));
      rotateZ(radians(nowA));
      translate(i*200+nowX, j*200+nowY, -50);
      fill(0, 150, 100); box(200); //ground's color and box's size
      popMatrix(); //matrix
    }
  }
  for(Hand hand: leap.getHands()){
    hand.draw();
    float angle= hand.getYaw(); //hand's angle
    PVector pos= hand.getPosition(); //hand's position
    nowA+= radians(-angle/40);
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    fill(181, 181, 181); stroke(0); box(100);
  }
}





期中作業討論:
彈鋼琴
彈力球
貪吃蛇
賽車
下棋
停車
1010!

01162412_葉興宇




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() {
  background(255);
  nowY+=cos(nowA);nowX+=sin(nowA);
  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);
  }
}
















設定旋轉視角和移動速度


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() {
  background(255);
  nowY+=cos(nowA);nowX+=sin(nowA);
  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);
  }
}




判斷左右手與手指數:

void draw(){
  background(255);
  println(leap.getHands().size());
  fill(255, 0, 0);
  textSize(40);
  for(Hand hand: leap.getHands()){
    if(hand.isRight()){
      text("right:"+hand.getOutstrechtedFingers().size(), 300, 300);
    }
    else text("left:"+hand.getOutstrechtedFingers().size(), 150, 300);
  }
}





第4周課堂作業


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);
  }
}
****************************************

import de.voidplus.leapmotion.*;
LeapMotion leap;
void setup(){
  size(600,600,P3D);
  leap = new LeapMotion(this);
}
float groundDir=0; //ground direction地板的方向
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;
  }
}
****************************************

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(){
  nowX+=sin(nowA); nowY+=cos(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);
  }
}
****************************************