コード例 #1
0
ファイル: MyTuioServer.cpp プロジェクト: Anixxx/KinectGrid
void MyTuioServer::send_blobs(std::vector<cBlob>& blobs, std::vector<Area>& areas, cv::Rect& roi){

	currentTime = TuioTime::getSessionTime();
	initFrame(currentTime);

	cBlob *pb;
	Area *pa;
//	printf("Area size: %i\n", areas.size());
	float lx,ly;
	for (int i = 0; i < blobs.size(); i++) {
		pb = &blobs[i];
		pa = &areas[pb->areaid-1];
		switch( pb->event ){
			case BLOB_UP:
				{
					printf("Remove cursor\n");
					//assert( pb->cursor != NULL );
					if( pb->cursor == NULL ) break;
					removeTuioCursor(pb->cursor);
				}
				break;
			case BLOB_DOWN:
				{
					//assert( pb->cursor == NULL );
					localCoords(pb,pa,&roi,&lx,&ly);
					if( pb->cursor == NULL ){
						pb->cursor = addTuioCursor(lx,ly,tuioSessionId(pb));
						printf("Add cursor %i \n", (int)tuioSessionId(pb));
					}else{
						updateTuioCursor(pb->cursor,lx,ly);
					}
				}
				break;
			case BLOB_MOVE:
			default:
				{
					localCoords(pb,pa,&roi,&lx,&ly);
					//assert( pb->cursor != NULL );
					if( pb->cursor == NULL ){
						pb->cursor = addTuioCursor(lx,ly,tuioSessionId(pb));
					}else{
						printf("Move cursor %i to %f %f \n", (int)tuioSessionId(pb),lx,ly );
						updateTuioCursor(pb->cursor,lx,ly);
					}
				}
				break;
		}
	}
	//processEvents();
	stopUntouchedMovingCursors();//?
	commitFrame();

/*
	if (cursor->getTuioTime()==currentTime) return;
	tuioServer->updateTuioCursor(cursor,x,y);
			cursor = tuioServer->addTuioCursor(x,y);
		tuioServer->removeTuioCursor(cursor);
	std::list<TuioCursor*> cursorList = tuioServer->getTuioCursors();
	*/
}
コード例 #2
0
ファイル: CrdTransf3d.cpp プロジェクト: lcpt/xc
//! @brief Returns the vector expressed in global coordinates.
const XC::Vector &XC::CrdTransf3d::getVectorGlobalCoordFromLocal(const Vector &localCoords) const
  {
    computeLocalAxis(); //Actualiza la matrix R.
    // vectorCoo = Rlj'*localCoords (Multiplica el vector por R traspuesta).
    vectorCoo(0)= R(0,0)*localCoords(0) + R(1,0)*localCoords(1) + R(2,0)*localCoords(2);
    vectorCoo(1)= R(0,1)*localCoords(0) + R(1,1)*localCoords(1) + R(2,1)*localCoords(2);
    vectorCoo(2)= R(0,2)*localCoords(0) + R(1,2)*localCoords(1) + R(2,2)*localCoords(2);
    return vectorCoo;
  }
コード例 #3
0
ファイル: CrdTransf3d.cpp プロジェクト: lcpt/xc
//! @brief Returns the vectors on the matrix rows
//! expressed in global coordinates and placed in the rows of the
//! returned matrix.
const XC::Matrix &XC::CrdTransf3d::getVectorGlobalCoordFromLocal(const Matrix &localCoords) const
  {
    computeLocalAxis(); //Actualiza la matrix R.
    static Matrix retval;
    const size_t numPts= localCoords.noRows(); //Number of vectors to transform
    retval.resize(numPts,3);
    for(size_t i= 0;i<numPts;i++)
      {
        // retval = Rlj'*localCoords (Multiplica el vector por R traspuesta).
        retval(i,0)= R(0,0)*localCoords(i,0) + R(1,0)*localCoords(i,1) + R(2,0)*localCoords(i,2);
        retval(i,1)= R(0,1)*localCoords(i,0) + R(1,1)*localCoords(i,1) + R(2,1)*localCoords(i,2);
        retval(i,2)= R(0,2)*localCoords(i,0) + R(1,2)*localCoords(i,1) + R(2,2)*localCoords(i,2);
      }
    return retval;
  }