2015年4月26日 星期日

第八周 期中作業進度

第八周 小進度報告

哇....距離繳交期中作業越來越接近了...覺得壓力無限龐大@@好害怕無法如期做完...

繼續研究上星期的抓取物件問題,發現真的卡關卡很大...= =

終於讓我想到了一個方法!!!

既然模型物件的座標位置是我設定的,那麼其實一切就好處理了~

只要利用距離,就可以有辦法成功抓取

我的抓取是利用按按鍵的模式去抓取的

==========以下為程式碼==========

再加入這段指令,即可用按鍵抓取物模型~

float x1=350,y1=500,x2=350,y2=410,x3=260,y3=500,x4=260,y4=410,x5=160,y5=500;

if (keyPressed == true) {
     if(key == 'z'){
       if( abs(pos.x-x1)<=20 && abs(pos.y-y1)<=20 )
         {
           x1=pos.x;
           y1=pos.y;
           if( abs(x1-r1_x)<=5 && abs(y1-r1_y)<=5)
           {
             need=need-1;
           }
         }
        else if(abs(pos.x-x2)<=20 && abs(pos.y-y2)<=20)
        {
          x2=pos.x;
          y2=pos.y;
          if( abs(x2-r2_x)<=5 && abs(y2-r2_y)<=5)
           {
             need=need-1;
           }
        }
        else if(abs(pos.x-x3)<=20 && abs(pos.y-y3)<=20)
        {
          x3=pos.x;
          y3=pos.y;
          if( abs(x3-r3_x)<=5 && abs(y3-r3_y)<=5)
           {
             need=need-1;
           }
        }
        else if(abs(pos.x-x4)<=20 && abs(pos.y-y4)<=20)
        {
          x4=pos.x;
          y4=pos.y;
          if( abs(x4-r4_x)<=5 && abs(y4-r4_y)<=5)
           {
             need=need-1;
             text(need,20,30);
           }
        }
        else if(abs(pos.x-x5)<=20 && abs(pos.y-y5)<=20)
        {
          x5=pos.x;
          y5=pos.y;
          if( abs(x5-r5_x)<=5 && abs(y5-r5_y)<=5)
           {
             need=need-1;
           }
        }
       }
      }

沒有留言:

張貼留言