Image processing tuio处理

Image processing tuio处理,image-processing,processing,Image Processing,Processing,嗨,我是新来的处理,我试图找出如何使球体从左向右移动使用标记,而不是鼠标。你能帮我吗?我可以用记号笔来拍摄,但我不能通过拍摄来移动球体 import TUIO.*; TuioProcessing tuioClient; HashMap symbols=new HashMap(); PFont fontA; int sphereDiameter = 50; boolean shoot = false; float obj_size = 60; int randx() { return

嗨,我是新来的处理,我试图找出如何使球体从左向右移动使用标记,而不是鼠标。你能帮我吗?我可以用记号笔来拍摄,但我不能通过拍摄来移动球体

import TUIO.*;
TuioProcessing tuioClient;
HashMap symbols=new HashMap();

PFont fontA;
int sphereDiameter = 50;
boolean shoot = false;

 float obj_size = 60;


 int randx()
 {
return int(random(600));
 }

 int[] sphereXCoords = { randx(), randx(), randx(), randx(), randx() };
 int[] sphereYCoords = { 0, 0, 0, 0, 0 };

 void setup()
{
size(1000,700);

tuioClient  = new TuioProcessing(this);
}

void draw()
{ 
Vector<TuioObject> tuioObjectList =tuioClient.getTuioObjects();
 Collections.sort(tuioObjectList, comp);

  for (TuioObject tobj:tuioObjectList) {
  fill(50, 50, 100);

  int id = tobj.getSymbolID();
  int x = tobj.getScreenX(width);
  int y = tobj.getScreenY(height);
  rect(x, y, obj_size, obj_size);

  String txt="?";
  if (symbols.containsKey(id)) {// if it's one in symbols, then look it up
  txt = (String)symbols.get(id);
  } 
  fill(255);
  text(txt, x, y);
  }   

 int[] sphereXCoords = { randx(), randx(), randx(), randx(), randx() };
      fill(100, 0, 0);
      // draw the answer box
    //  ellipse(answerX, answerY, obj_size, obj_size);
      fill(255);
      // write the answer text
    // text(""+answer, answerX, answerY);



  background(1);
  fill(color(255,255,0));
  stroke(color(0,255,0));
  triangle(mouseX-8, 580, mouseX+8, 580, mouseX, 565);
  fill(color(255,0,0));
  stroke(color(255,0,0));

if(shoot==true)
{
  sphereKiller( mouseX);
  shoot = false;
  }

  sphereDropper();
  //gameEnder();  
 }

   Comparator<TuioObject> comp = new Comparator<TuioObject>() {
   // Comparator object to compare two TuioObjects on the basis of their x position
 // Returns -1 if o1 left of o2; 0 if they have same x pos; 1 if o1 right of o2
 public int compare(TuioObject o1, TuioObject o2) {
  if (o1.getX()<o2.getX()) { 
    return -1;
    }  
  else if (o1.getX()>o2.getX()) { 
  return 1;
  }  
    else { 
  return 0;
  }
  }
  };

    void mousePressed()
   {
  shoot = true;
  }




  void sphereDropper()
  {  
  stroke(255);
  fill(255);

   for (int i=0; i<5; i++)
  {
  ellipse(sphereXCoords[i], sphereYCoords[i]++,
          sphereDiameter, sphereDiameter);

   }
  }

  void sphereKiller(int shotX)
  {
   boolean hit = false;
   for (int i = 0; i < 5; i++)
    {
     if((shotX >= (sphereXCoords[i]-sphereDiameter/2)) && 
        (shotX <= (sphereXCoords[i]+sphereDiameter/2)))
     {
      hit = true;
    line(mouseX, 565, mouseX, sphereYCoords[i]);
    ellipse(sphereXCoords[i], sphereYCoords[i],
            sphereDiameter+25, sphereDiameter+25);
    sphereXCoords[i] = randx();
    sphereYCoords[i] = 0;
  }    
  }

  if(hit == false)
  {
    line(mouseX, 565, mouseX, 0);
   }  

   }

     /* void gameEnder()
  {
   for (int i=0; i< 5; i++)
    {
    if(sphereYCoords[i]==600)
  {
    fill(color(255,0,0));
    noLoop();
    }
   }
     }*/

  void addTuioObject(TuioObject tobj) {


    }

 // called when an object is removed from the scene
     void removeTuioObject(TuioObject tobj) {
     }

/    / called when an object is moved
    void updateTuioObject (TuioObject tobj) {

  if(tobj.getSymbolID() == 32)
   {
    shoot = true;
   }
   }

   // called when a cursor is added to the scene
   void addTuioCursor(TuioCursor tcur) {
   }

  // called when a cursor is moved
  void updateTuioCursor (TuioCursor tcur) {


   }

   // called when a cursor is removed from the scene
  void removeTuioCursor(TuioCursor tcur) {
   }

   // called after each message bundle
   // representing the end of an image frame
   void refresh(TuioTime bundleTime) { 

  //redraw();
   }
导入TUIO.*;
TuioProcessing tuioClient;
HashMap符号=新的HashMap();
普丰丰塔;
int SpheredAmeter=50;
布尔射=假;
浮动对象大小=60;
int randx()
{
返回int(随机(600));
}
int[]sphereXCoords={randx(),randx(),randx(),randx(),randx()};
int[]SphereCoords={0,0,0,0,0};
无效设置()
{
规模(1000700);
tuioClient=新的TuioProcessing(this);
}
作废提款()
{ 
Vector tuioObjectList=tuioClient.getTuioObjects();
Collections.sort(tuioObjectList,comp);
for(TuioObject tobj:tuioObjectList){
填充(50、50、100);
int id=tobj.getSymbolID();
intx=tobj.getScreenX(宽度);
int y=tobj.getScreenY(高度);
rect(x,y,对象大小,对象大小);
字符串txt=“?”;
if(symbols.containsKey(id)){//如果它是symbols中的一个,则查找它
txt=(字符串)符号.get(id);
} 
填充(255);
文本(txt、x、y);
}   
int[]sphereXCoords={randx(),randx(),randx(),randx(),randx()};
填充(100,0,0);
//画答案框
//椭圆(answerX、answerY、obj_尺寸、obj_尺寸);
填充(255);
//写下答案
//文本(“+回答,回答,回答);
背景(1);
填充(颜色(255255,0));
笔画(颜色(0255,0));
三角形(mouseX-8580,mouseX+8580,mouseX,565);
填充(颜色(255,0,0));
笔画(颜色(255,0,0));
如果(shot==true)
{
sphereKiller(mouseX);
射击=假;
}
sphereDropper();
//Gamender();
}
比较器comp=新比较器(){
//比较器对象根据两个对象的x位置比较它们
//如果o2的左侧为o1,则返回-1;如果x位置相同,则返回0;如果o2的右侧为o1,则返回1
公共整数比较(TuioObject o1,TuioObject o2){
如果(o1.getX()o2.getX()){
返回1;
}  
否则{
返回0;
}
}
};
void mousePressed()
{
射击=真;
}
void sphereDropper()
{  
中风(255);
填充(255);
对于(int i=0;i=(SphereExcoords[i]-sphereDiameter/2))&&
(shotX你说的“射击”是什么意思

因此,您有了tuioClient,并在setup()中对其进行了初始化。这很好,因为无论何时草图收到TUIO消息,都会触发回调方法(addTuioObject、RemoveTuiObject、UpdateTuiObject、addTuioCursor、updateTuioCursor、removeTuioCursor、refresh)

请记住,TUIO是基于OSC的,OSC通过UDP传输。这意味着跟踪器(Reactivition&co)必须发送到草图正在侦听的IP和端口。如果两者都在同一台机器上,请使用127.0.0.1和端口3333(默认)。 请查看示例。您将在处理“IDE”中找到它们,单击: “文件->示例” 并导航到
“贡献库->TUIO”

此编程语言的名称是什么?+1用于介绍一种新语言。有人能帮我吗?你可能想在@user1907665中提出这个问题。我不确定我是否理解“更多的是使用标记而不是鼠标的球体。”你能再描述一下吗,或者展示一下你想做的事情的屏幕截图?