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

2015年4月26日 星期日

期中作品 飛機吃硬幣

飛機吃硬幣
                                                   組員:
01160723 邱詠縉
01160431 劉冠逸




第七周 期中作業進度

這七周 小進度報告

對於這周進度有點卡關...想和圖片作互動,就是想要讓爪子成功將圖片抓取起來,結果這一點想了好久...

一直在想我要怎麼取得圖片的位置,然後就卡在這裡

一開始是想取得圖片位置後再看和爪子的距離,如果距離小於多少的話就可以被爪子吸住。

==========我是分隔線============

之後想說如果是抓圖片的話也太奇怪了一點,所以決定來放maya的模型進去


成功的放入模型之後,覺得開心,因為有讀取到檔案,而且檔案也有顏色,並沒有跑掉,但是在高興之餘,發現了一個小缺失,就是模型沒有眼睛= ='''

這樣看起來就超級奇怪的...
所以立馬請梁馨心再重新修改一次

======以下為圖片檔和程式碼======


import processing.opengl.*;
import saito.objloader.*;
import ddf.minim.*;

OBJModel model; //claws
OBJModel model_1; //bear
OBJModel model_2; //rabbit
OBJModel model_3; //cat
OBJModel model_4; //frog
OBJModel model_5; //blond bear

BoundingBox bbox;
import de.voidplus.leapmotion.*;
LeapMotion leap;

void setup(){
  size(600, 600, P3D);
  leap= new LeapMotion(this);
model = new OBJModel(this, "claws.obj","relative", QUADS);
  model.enableDebug();
  model.scale(30);
 
  model_1 = new OBJModel(this, "doll_1.obj","relative", QUADS);
  model_1.enableDebug();
  model_1.scale(6);
 
  model_2 = new OBJModel(this, "doll_2.obj","relative", QUADS);
  model_2.enableDebug();
  model_2.scale(7);
 
  model_3 = new OBJModel(this, "doll_3.obj","relative", QUADS);
  model_3.enableDebug();
  model_3.scale(7);
 
  model_4 = new OBJModel(this, "doll_4.obj","relative", QUADS);
  model_4.enableDebug();
  model_4.scale(7);
 
  model_5 = new OBJModel(this, "doll_5.obj","relative", QUADS);
  model_5.enableDebug();
  model_5.scale(7);
}
float angle=0; //hand's angle
float a=0,b=0,c=0;
void draw(){
  background(165,222,237); //background redraw
  noStroke();
  pushMatrix();
    translate(300,350,350);
    rotateY(radians(45));
    model_1.draw();
  popMatrix();
 
  pushMatrix();
    translate(260,350,260);
    rotateZ(radians(55));
    rotateY(radians(-30));
    model_2.draw();
  popMatrix();

  pushMatrix();
    translate(260,350,380);
    rotateY(radians(40));
    model_3.draw();
  popMatrix();
 
  pushMatrix();
    translate(200,350,300);
    rotateY(radians(20));
    model_4.draw();
  popMatrix();
 
  pushMatrix();
    translate(200,350,180);
    rotateX(radians(10));
    model_5.draw();
  popMatrix();
 
  for(Hand hand: leap.getHands()){
    if(hand.isRight()){
    PVector pos= hand.getPosition();
    angle = hand.getYaw();
    translate(pos.x, pos.y, pos.z);
    rotateY(-radians(angle));
    model.draw();
    }
  }
}

==========下周小目標===========
繼續研究如何讓爪子夾起娃娃@@

2015年4月25日 星期六

Week07

Week 07 期中作業進度:



空中漫步-平衡跳跳球


1. 讓球滾

2. 手舉高, 球能跳更遠(前後)

3.4 fingers, Live+2

4.out of cloud, Live-2

--------------------------------------------------



photo



1. 讓球滾

3.4 fingers, Live+2



















2. 手舉高, 球能跳更遠(前後)


  中






  後





  前








4.out of cloud, Live-2










2015年4月13日 星期一

week08

import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage imgAcc;
PImage imgBG;
void setup()
{
  size(800,600, P3D);
  imgBG = loadImage("bg.jpg");
  imgBG.resize(800,600);

  imgAcc = loadImage("accurate.png");
  leap = new LeapMotion(this);
}
int countDown = 30;

void draw()
{
  background(imgBG);
  if(countDown==0) background(255,0,0);
  fill(0);textSize(30);text("Time:"+countDown,600,50);
  if(frameCount%60==0 && countDown>0) countDown--;
  for(Hand hand : leap.getHands() ){
    hand.draw();
    myDraw(hand.getIndexFinger().getPosition());
  }
}
void myDraw(PVector pos){
  pushMatrix();
//  fill(255,0,0); sphere(20);
  image(imgAcc,pos.x-50,pos.y-50,100,100);
  popMatrix();
}

00160530_吳坤曄, Week07

import de.voidplus.leapmotion.*;

LeapMotion leap;
PVector []pos=new PVector[1000];
void setup() {
  size(800, 500, P3D);
 
  for(int i=0;i<10;i++) pos[i]=new PVector(60*i, -random(600));

  leap = new LeapMotion(this);
}
float grabX=0,grabY=0;
void draw() {
  background(255);
  background(128);
  for(int i=0;i<10;i++){
    ellipse(pos[i].x,pos[i].y,50,50);
    pos[i].y+=3;
    if(pos[i].y>600) pos[i].y=-random(300);
    if(dist(grabX,grabY,pos[i].x,pos[i].y)<50){fill(255,0,0);pos[i].y=-random(300);}
    else fill(255);
  }
  int fps = leap.getFrameRate();


  // ========= HANDS =========

  for (Hand hand : leap.getHands ()) {
    PVector pos;
    pos = hand.getIndexFinger().getPosition();
    grabX=(pos.x);
    grabY=(pos.y);

    // ----- BASICS -----

    int     hand_id          = hand.getId();
    PVector hand_position    = hand.getPosition();
    PVector hand_stabilized  = hand.getStabilizedPosition();
    PVector hand_direction   = hand.getDirection();
    PVector hand_dynamics    = hand.getDynamics();
    float   hand_roll        = hand.getRoll();
    float   hand_pitch       = hand.getPitch();
    float   hand_yaw         = hand.getYaw();
    boolean hand_is_left     = hand.isLeft();
    boolean hand_is_right    = hand.isRight();
    float   hand_grab        = hand.getGrabStrength();
    float   hand_pinch       = hand.getPinchStrength();
    float   hand_time        = hand.getTimeVisible();
    PVector sphere_position  = hand.getSpherePosition();
    float   sphere_radius    = hand.getSphereRadius();


    // ----- SPECIFIC FINGER -----

    Finger  finger_thumb     = hand.getThumb();
    // or                      hand.getFinger("thumb");
    // or                      hand.getFinger(0);

    Finger  finger_index     = hand.getIndexFinger();
    // or                      hand.getFinger("index");
    // or                      hand.getFinger(1);

    Finger  finger_middle    = hand.getMiddleFinger();
    // or                      hand.getFinger("middle");
    // or                      hand.getFinger(2);

    Finger  finger_ring      = hand.getRingFinger();
    // or                      hand.getFinger("ring");
    // or                      hand.getFinger(3);

    Finger  finger_pink      = hand.getPinkyFinger();
    // or                      hand.getFinger("pinky");
    // or                      hand.getFinger(4);      


    // ----- DRAWING -----

    hand.draw();
    // hand.drawSphere();


    // ========= ARM =========

    if (hand.hasArm()) {
      Arm     arm               = hand.getArm();
      float   arm_width         = arm.getWidth();
      PVector arm_wrist_pos     = arm.getWristPosition();
      PVector arm_elbow_pos     = arm.getElbowPosition();
    }


    // ========= FINGERS =========

    for (Finger finger : hand.getFingers()) {
      // Alternatives:
      // hand.getOutstrechtedFingers();
      // hand.getOutstrechtedFingersByAngle();

      // ----- BASICS -----

      int     finger_id         = finger.getId();
      PVector finger_position   = finger.getPosition();
      PVector finger_stabilized = finger.getStabilizedPosition();
      PVector finger_velocity   = finger.getVelocity();
      PVector finger_direction  = finger.getDirection();
      float   finger_time       = finger.getTimeVisible();
   

      // ----- SPECIFIC FINGER -----

      switch(finger.getType()) {
      case 0:
        // System.out.println("thumb");
        break;
      case 1:
        // System.out.println("index");
        break;
      case 2:
        // System.out.println("middle");
        break;
      case 3:
        // System.out.println("ring");
        break;
      case 4:
        // System.out.println("pinky");
        break;
      }


      // ----- SPECIFIC BONE -----

      Bone    bone_distal       = finger.getDistalBone();
      // or                       finger.get("distal");
      // or                       finger.getBone(0);

      Bone    bone_intermediate = finger.getIntermediateBone();
      // or                       finger.get("intermediate");
      // or                       finger.getBone(1);

      Bone    bone_proximal     = finger.getProximalBone();
      // or                       finger.get("proximal");
      // or                       finger.getBone(2);

      Bone    bone_metacarpal   = finger.getMetacarpalBone();
      // or                       finger.get("metacarpal");
      // or                       finger.getBone(3);


      // ----- DRAWING -----

      // finger.draw(); // = drawLines()+drawJoints()
      // finger.drawLines();
      // finger.drawJoints();


      // ----- TOUCH EMULATION -----

      int     touch_zone        = finger.getTouchZone();
      float   touch_distance    = finger.getTouchDistance();

      switch(touch_zone) {
      case -1: // None
        break;
      case 0: // Hovering
        // println("Hovering (#"+finger_id+"): "+touch_distance);
        break;
      case 1: // Touching
        // println("Touching (#"+finger_id+")");
        break;
      }
    }


    // ========= TOOLS =========

    for (Tool tool : hand.getTools ()) {


      // ----- BASICS -----

      int     tool_id           = tool.getId();
      PVector tool_position     = tool.getPosition();
      PVector tool_stabilized   = tool.getStabilizedPosition();
      PVector tool_velocity     = tool.getVelocity();
      PVector tool_direction    = tool.getDirection();
      float   tool_time         = tool.getTimeVisible();


      // ----- DRAWING -----

      // tool.draw();


      // ----- TOUCH EMULATION -----

      int     touch_zone        = tool.getTouchZone();
      float   touch_distance    = tool.getTouchDistance();

      switch(touch_zone) {
      case -1: // None
        break;
      case 0: // Hovering
        // println("Hovering (#"+tool_id+"): "+touch_distance);
        break;
      case 1: // Touching
        // println("Touching (#"+tool_id+")");
        break;
      }
    }
  }


  // ========= DEVICES =========

  for (Device device : leap.getDevices ()) {
    float device_horizontal_view_angle = device.getHorizontalViewAngle();
    float device_verical_view_angle = device.getVerticalViewAngle();
    float device_range = device.getRange();
  }
}

// ========= CALLBACKS =========

void leapOnInit() {
  // println("Leap Motion Init");
}
void leapOnConnect() {
  // println("Leap Motion Connect");
}
void leapOnFrame() {
  // println("Leap Motion Frame");
}
void leapOnDisconnect() {
  // println("Leap Motion Disconnect");
}
void leapOnExit() {
  // println("Leap Motion Exit");
}

week07




import de.voidplus.leapmotion.*;
LeapMotion leap;

void setup() {
  size(800, 500, P3D);

  leap = new LeapMotion(this);
}


float nowX=0, nowY, nowA=0;

void draw() {
  background(255);
  for (Hand hand : leap.getHands ()) {
    switch(hand.getOutstrechtedFingers().size()) {
    case 0:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(50);
        box(100);
        popMatrix();
      }
      break;
    case 1:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(100);
        box(100);
        popMatrix();
      }
      break;
    case 2:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(150);
        box(100);
        popMatrix();
      }
      break;
    case 3:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(200);
        box(100);
        popMatrix();
      }
      break;
    case 4:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(0);
        box(100);
        popMatrix();
      }
      break;

    case 5:
      {
        pushMatrix();
        translate(hand.getPosition().x, hand.getPosition().y);
        rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        rotateY(-radians(hand.getYaw()));
        stroke(0);
        fill(255,0,0);
        sphere(50);
        popMatrix();
      }
      break;
    }
    hand.draw();
  }
}


下面為讀圖用
import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage img;
void setup() {
  size(800, 500, P3D);
  img=loadImage("1.jpg");
  leap = new LeapMotion(this);
}


float nowX=0, nowY, nowA=0;
void draw() {
  background(255);
  for (Hand hand : leap.getHands ()) {
    switch(hand.getOutstrechtedFingers().size()) {
    case 0:
      {
        pushMatrix();
        translate(hand.getPosition().x-50, hand.getPosition().y-50);
        //rotateZ(radians(hand.getPitch()));
        //rotateZ(-radians(hand.getRoll()));
        //rotateY(-radians(hand.getYaw()));
        //stroke(0);
        //fill(50);
        image(img,0,0);
        popMatrix();
      }
      break;
    case 1:
      {
        pushMatrix();..................................................

Week 07

期中作品進度


void draw() {

background(255);
for (Hand hand : leap.getHands ()) {
//hand.draw();
PVector pos = hand.getPosition();
//pushMatrix(); fill(0);
//popMatrix();
ellipse(pos.x, pos.y, 100, 100); } fill(0);
rect(0, 0, 20, 200);
rect(0, 580, 1200, 20); rect(0, 0, 1200, 20);
rect(1180, 400, 20, 200);
rect(0, 400, 20, 200); rect(1180, 0, 20, 200);
}
ellipse(ballX, ballY, 60, 60);


Week 07

期中作品:爆氣飛碟球

本週進度先把背景以及小圓盤畫好,再加上leap motion的程式碼先寫好


void draw() {
  background(255);
  for (Hand hand : leap.getHands ()) {
    //hand.draw(); 

    //pushMatrix();
    PVector pos = hand.getPosition();
    fill(0);
    ellipse(pos.x, pos.y, 100, 100);
    //popMatrix();
  }
    fill(0);
    rect(0, 580, 1200, 20);
     rect(0, 0, 1200, 20);
     rect(0, 0, 20, 200);
     rect(0, 400, 20, 200);
     rect(1180, 0, 20, 200);
     rect(1180, 400, 20, 200);
    ellipse(ballX, ballY, 60, 60);
     
}

期中報告進度

遊戲名稱:快速變幻球
這是一個考你反應的遊戲
用你最快的速度去碰到畫面上隨機出現的球

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

week07



期中作品:特訓99

目前進度:飛船可以自由移動,只差原點的遊戲判定








.進度更新:已完成起始點跟著飛船移動,並且完成期中作業進度

01160873_林瑋真

期中作品名稱:水果保衛戰
進度:
       6個水果、2種蟲、背景等...以放入。

期中進度

圖片的完成