TuioBlob* TuioManager::addTuioBlob(float x, float y, float a, float w, float h, float f) { sessionID++; int blobID = (int)blobList.size(); if ((int)(blobList.size())<=maxBlobID) { std::list<TuioBlob*>::iterator closestBlob = freeBlobList.begin(); for(std::list<TuioBlob*>::iterator iter = freeBlobList.begin();iter!= freeBlobList.end(); iter++) { if((*iter)->getDistance(x,y)<(*closestBlob)->getDistance(x,y)) closestBlob = iter; } TuioBlob *freeBlob = (*closestBlob); blobID = (*closestBlob)->getBlobID(); freeBlobList.erase(closestBlob); delete freeBlob; } else maxBlobID = blobID; TuioBlob *tblb = new TuioBlob(currentFrameTime, sessionID, blobID, x, y, a, w, h, f); blobList.push_back(tblb); updateBlob = true; for (std::list<TuioListener*>::iterator listener=listenerList.begin(); listener != listenerList.end(); listener++) (*listener)->addTuioBlob(tblb); if (verbose) std::cout << "add blb " << tblb->getBlobID() << " (" << tblb->getSessionID() << ") " << tblb->getX() << " " << tblb->getY() << tblb->getAngle() << " " << tblb->getWidth() << tblb->getHeight() << " " << tblb->getArea() << std::endl; return tblb; }
void TuioManager::stopUntouchedMovingBlobs() { std::list<TuioBlob*> untouched; for (std::list<TuioBlob*>::iterator tuioBlob = blobList.begin(); tuioBlob!=blobList.end(); tuioBlob++) { TuioBlob *tblb = (*tuioBlob); if ((tblb->getTuioTime()!=currentFrameTime) && (tblb->isMoving())) { tblb->stop(currentFrameTime); updateBlob = true; if (verbose) std::cout << "set blb " << tblb->getSessionID() << tblb->getX() << " " << tblb->getY() << " " << tblb->getWidth() << " " << tblb->getHeight() << " " << tblb->getAngle() << " " << tblb->getXSpeed() << " " << tblb->getYSpeed()<< " " << tblb->getMotionAccel() << " " << std::endl; } } }