2016年3月31日 星期四

week06_期中作品構思_紙飛機_呂登祐 & 鄧安倫

期中作品:  紙飛機

靈感來源:

  在網路上看到這部紙飛機的片段(10:44的時候),覺得很有趣,於是想說試試看我們能不能做出這樣的效果,於是我們決定要做紙飛機了!

作品構思:
 我們大概把他分成兩大部分,分別是有背景的天空部分跟紙飛機本身部分。

    1.背景: 天空包貼圖
    2.使用者: 使用的操作紙飛機

開發環境: 運用Processing 寫程式碼,再套用到Leap Motion Controller去做控制。










Week06_期中作品製作進度

我們的期中作品要做貓狗大戰
啟發點是這款遊戲

我們想說用Leapmotion去做控制,結合AngryBird用拉的方式丟出物件

於是我把以前用Unity作的AngryBird拿出來改
我們想要在兩端各做一座城堡(貓/狗),上方有血條,前面擺彈弓,射出物件打到城堡
看誰的城堡先垮就誰輸。

不過我們要先把LeapMotion匯入到Unity

然後結合之前做的AngryBird,不過目前沒有打入任何的程式,所以還不能用LeapMotion去做射出的動作

不過我們有加入Collider,當兩物件接觸時能做出......什麼什麼事情

Week06_期中作品製作_02160421黃志楷

第六週課程:努力製作期中作品

week06: Hard to make mid project


第一節課(unity處理)


1.期中作品想要做像這樣的遊戲,貓狗大戰



但會做些小改變

後方有城堡,當丟出東西 打到城堡就會扣血量。

底下是貓咪



底下是狗


2.UNITY 因為帳號密碼忘記,所以重新辦了一個帳號,並登入。

















3.會確認你使用的版本


4.會有一個快速survey,把選項填一下

5.都填完就可以,開始了


6.正式進入unity,開心使用。



第二節課(unity與leap motion的配合)

1.下載leap motion 與unity的相關檔案

2.將leap motion 接unity 的 packet 匯入專案裡


3.將手放入專案裡


4.持續測試中~~~








第三節課(持續測試中)


1.將食指的第一個指節加入燈光




2.討論後面製作細節。










02163042_王冠閔_week06




製作期中作品



Week 06 02160430 陳繁鑫

期中作品製作


這次期中作品要使用Unity做為開發環境
要透過Unity操作LeapMotion必須先做好環境設置
先到 : https://developer.leapmotion.com/unity 安裝必要軟體

先安裝完上面3個SDK

最後在下載Unity Assets


 第一個程式我們要安裝左邊的(Orion Beta)裡面也會包含V2Desktop的內容

 環境準備完成後,我們就可以使用Assets了

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

匯入Assets,我們到LeapMotion -> Scenes -> Leap_Hand_Demo_Desktop

開啟桌面板的操作 



WEEK06_02160136_陳威志

進度暫存

LeapMotion leap;
PVector pos =null;
PImage ball;
void setup(){
  size(800,600,P3D);
  ball = loadImage("ball.jpeg");
  leap = new LeapMotion(this);
}
void draw(){
  background(255);
  for(Hand hand : leap.getHands()){
    if( hand.isRight() ){
      Finger finger_1=hand.getIndexFinger();
      pos = finger_1.getPosition();
      image(ball, pos.x, pos.y, 50, 50);
    }
  }
}

期中作品_class_02160323_02160615

import de.voidplus.leapmotion.*;
LeapMotion leap;
PImage imgBoard;
PVector old, right,left,up,down;
void setup()
{
  size(400, 600);
  leap=new LeapMotion(this);
  old=new PVector(0, 0, 0);
  right = new PVector(1, 0, 0);
  left =new PVector(-1, 0, 0);
  up= new PVector(0, -1, 0);
  down=new PVector(0, 1, 0);
  //imgBoard=loadImage("board.png");
}
int [] ans= {1,1,1,0 };
void draw() {
  background(0);
  for (Hand hand : leap.getHands ())
  {
    background(255);
    PVector now =hand.getPosition();
    if (old.x==0 && old.y==0 && old.z==0) {
      old.x=now.x;
      old.y=now.y;
      old.z=now.z;
    }
    if (iGood) {
      image(imgGood, 0, 0);
      iGood--;
    } else if ((PVector.dist(old, now)>10))
    {
      PVector dir =PVector.sub(now, old);
      if (dir.angleBetween(dir, right)<radians(30) && ans[score]==1) {
        score++;
        iGood=60;
      }
      if (dir.angleBetween(dir, left)<radians(30) && ans[score]==2) {
        score++;
        iGood=60;
      }
      if (dir.angleBetween(dir, up)<radians(30) && ans[score]==3) {
        score++;
        iGood=60;
      }
      if (dir.angleBetween(dir, down)<radians(30) && ans[score]==4) {
        score++;
        iGood=60;
      }
    }

    old.x=now.x;
    old.y=now.y;
    old.z=now.z;
  }
  text("score"+score,50,60);
  PVector direction= g.getDirection();
}



////未完待續

02160120 week06

數據封包的陣列會爆炸 尚未改善
已經改善真實座標和虛擬座標的誤差

Client

//Client's code computer"1"
int myComputer=1;
import de.voidplus.leapmotion.*;
import processing.net.*;

Client client;
PImage ht;
int x=0, y=0, myX=395, myY=295,pX=395,pY=295;
int vx=1, vy=1;
int UDP[][] = new int[10][5];
int data[];
int delayTime=0;

void setup() {
  size(800, 600);
  ht = loadImage("ht.jpg");
  for(int i=0;i<10;i++)for(int j=1;j<5;j++)UDP[i][j]=0;
  client = new Client(this,"127.0.0.1",0124);
}

void draw() {
  background(0);
  image(ht, x, y, 1000, 800);
  mousePosition();
  myInformation();
  clientInformation();
  for(int i=0;i<10;i++)if(i!=myComputer)ellipse(UDP[i][1]+x, UDP[i][2]+y,10,10);
  text((UDP[0][1]+x) + " " + (UDP[0][2]+y),UDP[0][1]+x,UDP[0][2]+y);
}
void mousePosition() {

  fill(255, 0, 0);
  line(myX, myY, mouseX, mouseY);
  ellipse(mouseX, mouseY, 5, 5);

  fill(255);
  ellipse(myX, myY, 10, 10);

  text((myX-x) + " " + (myY-y), myX, myY);

  if (mouseY>myY+20)if (y>-200&&myY==295)y-=10;
  else if (myY<590)myY+=10;
  if (mouseY<myY-20)if (y<0&&myY==295)y+=10;
  else if (myY>10)myY-=10;
  if (mouseX<myX-20)if (x<0&&myX==395)x+=10;
  else if (myX>10)myX-=10;
  if (mouseX>myX+20)if (x>-200&&myX==395)x-=10;
  else if (myX<790)myX+=10;
}
void myInformation() {
  if(millis()-delayTime>50){
    client.write(myComputer + "," + (myX-x) + "," + (myY-y) + "\n");
    delayTime=millis();
  }
    pX=(myX-x);
    pY=(myY-y);
}

void clientInformation() {
  if (client.available()>0) {
    String input;
    input = client.readString();
//    input = input.substring(0, input.indexOf("\n"));  // Only up to the newline
    println(input);
    data = int(split(input, ','));  // Split values into an array
    for(int i=1;i<3;i++)UDP[data[0]][i]=data[i];
    // Draw line using received coords
    stroke(0);
  }
}

server
//Server's code computer"0"
int myComputer=0;
import de.voidplus.leapmotion.*;
import processing.net.*;
PVector []userPosition;
int UDP[][] = new int[10][5];
int data[];
String input;
PImage ht;
int x=0, y=0, myX=395, myY=295,pX=395,pY=395;
int vx=1, vy=1;
int delayTime=0;

Server server;
Client client;
void setup() {
  size(800, 600);
  ht = loadImage("ht.jpg");
  server = new Server(this, 0124);
  for(int i=0;i<10;i++)for(int j=1;j<5;j++)UDP[i][j]=0;
}
void draw() {
  image(ht, x, y, 1000, 800);
  myInformation();
  clientInformation();
  mousePosition();
  for(int i=0;i<10;i++)if(i!=myComputer)ellipse(UDP[i][1]+x, UDP[i][2]+y,10,10);
  text((UDP[1][1]+x) + " " + (UDP[1][2]+y),UDP[1][1]+x,UDP[1][2]+y);
}
void mousePosition() {

  fill(255, 0, 0);
  line(myX, myY, mouseX, mouseY);
  ellipse(mouseX, mouseY, 5, 5);

  fill(255);
  ellipse(myX, myY, 10, 10);

  text((myX-x) + " " + (myY-y), myX, myY);

  if (mouseY>myY+20)if (y>-200&&myY==295)y-=10;
  else if (myY<590)myY+=10;
  if (mouseY<myY-20)if (y<0&&myY==295)y+=10;
  else if (myY>10)myY-=10;
  if (mouseX<myX-20)if (x<0&&myX==395)x+=10;
  else if (myX>10)myX-=10;
  if (mouseX>myX+20)if (x>-200&&myX==395)x-=10;
  else if (myX<790)myX+=10;
}

void myInformation() {

    if(millis()-delayTime>50){
      server.write(myComputer + "," + (myX-x) + "," + (myY-y) + "\n");
      delayTime=millis();
    }
    pX=(myX-x);
    pY=(myY-y);
}

void clientInformation() {
  client = server.available();
  if (client != null) {
    String input;
    input = client.readString();
//    input = input.substring(0, input.indexOf("\n"));  // Only up to the newline
    println(input);
    data = int(split(input, ','));  // Split values into an array
    for(int i=1;i<3;i++)UDP[data[0]][i]=data[i];
    // Draw line using received coords
    stroke(0);

  }
}

其中作品製作

期中作品製作
目前進度:
PImage img; int imgY=0; float x; int s=0; int z=1; void setup() { background(255); size(600, 600, P3D); img=loadImage("01.jpg"); } void draw() { switch(s) { case 0: pushMatrix(); background(255); translate(100, imgY); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); break; case 1://s=0 switch(z) { case 1: pushMatrix(); background(255); translate(100, imgY++); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY>=250) { z=2; } break; case 2: pushMatrix(); background(255); translate(100, imgY--); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY<=0) { z=3; } break; case 3: z=1; break; } break;//s=0 case 2: switch(z) { case 1: pushMatrix(); background(255); translate(100, imgY=imgY+5); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY>=250) { z=2; } break; case 2: pushMatrix(); background(255); translate(100, imgY=imgY-5); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY<=0) { z=3; } break; case 3: z=1; break; } break; case 3: switch(z) { case 1: pushMatrix(); background(255); translate(100, imgY=imgY+10); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY>=250) { z=2; } break; case 2: pushMatrix(); background(255); translate(100, imgY=imgY-10); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY<=0) { z=3; } break; case 3:
}
z=1; break; } break; case 4: switch(z) { case 1: pushMatrix(); background(255); translate(100, imgY=imgY+15); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY>=250) { z=2; } break; case 2: pushMatrix(); background(255); translate(100, imgY=imgY-15); image(img, 100, imgY, 100, 100); println(imgY); popMatrix(); if (imgY<=0) { z=3; } break; case 3: z=1; break; } break; } } void keyPressed() { s++; if(s>4){ s=0; }
斷頭台程式

Week 06 葉正聖老師示範

Week 06 葉正聖老師示範

2016年3月24日 星期四

Week05_酷東西_02160421黃志楷

第五週課程:酷東西

Week05:Cool Example

第一節課(多視窗)

1. 多視窗

參考網址

https://forum.processing.org/one/topic/multiple-windows-2-4-2011.html

但是因為是舊版的,所以要加入import java.awt.Frame;


import java.awt.Frame; //一定要加

PFrame f;

secondApplet s;

void setup()
{
 size(320, 240);

 PFrame f = new PFrame();

}

void draw()
 {
  background(255,0,0);
   fill(255);
   rect(10,10,frameCount%100,10);
   s.background(0, 0, 255);
   s.fill(100);
   s.rect(10,20,frameCount%120,10);
   s.redraw();
}

public class secondApplet extends PApplet
 {
    public void setup()
{
        size(400, 300);
        noLoop();
   }

public class PFrame extends Frame
 {
    public PFrame()
 {
        setBounds(100,100,400,300);
        s = new secondApplet();
        add(s);
        s.init();
        show();
    }
}





                                   第二節課(轉動的眼珠)

1. 轉動眼珠

void setup() 
{
 size(120,100);
}

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(120-40+15*cos(t),50+15*sin(t),5,5);




                                     第三節課(酷範例)

1. 眼珠跟著滑鼠

void setup() 
{
 size(120,100);
}

void draw()
 {
  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(120-40+15*cos(t),50+15*sin(t),5,5);
}





2. 雙螺旋

void setup()
{
  size(800,800);
}

void draw()
{
  background(255);
  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);
  }
}



Week05 02160995_何杰璋


一.眼珠轉動
void setup(){
  size(120,100);
}
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(120-40+15*cos(t),50+15*sin(t),5,5);
}



二.眼珠跟著滑鼠動,會有鬥雞眼
void setup(){
  size(320,300);
}
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(120-40+15*cos(t),50+15*sin(t),5,5);
}


三.雙螺旋
void setup(){
  size(600,600);
}
void draw(){
  background(255);
  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);
  }
}

02160040_周子伍, 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);
  }
}  



week05

今天先做一個眼珠會動的感覺



2.滑鼠可以控制眼珠的動作

3.螺旋(2條)


Week05_02160642_蔡宗霖_帥哥


一.眼珠轉動

void setup(){
  size(120,100);
}
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(120-40+15*cos(t),50+15*sin(t), 5,5);
}




二.眼珠跟著游標移動

void setup(){
  size(320,300);
}
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(120-40+15*cos(t),50+15*sin(t), 5,5);
}



三.螺旋狀方框

void setup(){
  size(600,600);
}
void draw(){
  background(255);
  float t=frameCount/100.0;
  for(float f=0; f<PI; f+=0.1){
    //rect(200+150*cos(f), 200+150*sin(f), 30,30);
    rect(200+150*cos(f+t), f*100, 30, 30);
    rect(200+150*cos(f+t+PI), f*100, 30, 30);
  }
}