当前位置: 首页>>代码示例>>C++>>正文


C++ TuioCursor::getPosition方法代码示例

本文整理汇总了C++中TuioCursor::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ TuioCursor::getPosition方法的具体用法?C++ TuioCursor::getPosition怎么用?C++ TuioCursor::getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TuioCursor的用法示例。


在下文中一共展示了TuioCursor::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleEvents

void HTTUIOServer::handleEvents(const std::vector<HTBlobInterpreter::TrackRecord>& events)
{
	const unsigned len = events.size();
	if (len == 0)
		return;

	if (!tuioServer || !tuioServer->isConnected())
	{
		printf("HTTUIOServer::handleEvents : Connection not set up, skipping...\n");
		return;
	}

	TuioCursor* cursor = 0;
	std::map<unsigned int, TuioOutput>::iterator curIter;

	tuioServer->initFrame(TUIO::TuioTime::getSessionTime());


	for (unsigned i = 0; i < len; i++)
	{
		const HTBlobInterpreter::TrackRecord* rec = &(events[i]);
		//for now, skip person events
		//float cX = (float)((int)((lMargin + (rec->curX * (rMargin - lMargin))) * 1000.f)) / 1000.f;
		//float cY = (float)((int)(rec->curY * 1000.f) / 1000.f);
		float cX = (lMargin + (rec->curXsmooth * (rMargin - lMargin)));
		float cY = 0.f;

		if (rec->brtype == HTIBlobResultTarget::BRT_HAND)
			cY = rec->curYsmooth;
//		else
//			printf("PERSON!\n");

		switch (rec->type)
		{
		case HTBlobInterpreter::HTET_DRAG_NEW:
			cursor = tuioServer->addTuioCursor(cX, cY);
			printf("Adding   Cursor... BlobID: %i SID: %li (X: %f, Y: %f)\n", rec->blobID, cursor->getSessionID(), cursor->getPosition().getX(), cursor->getPosition().getY());
			TuioOutput to;
			to.cursor = cursor;
			//to.filter = new HTKalmanFilter(cX, cY);
			cursorMap.insert(std::pair<unsigned int, TuioOutput>(rec->blobID, to));
			break;

		case HTBlobInterpreter::HTET_DRAG_CONT:
			curIter = cursorMap.find(rec->blobID);
			if (curIter == cursorMap.end())
			{
				printf("(HTTUIOServer::handleEvents) WARNING: DRAG_CONT: Cursor (ID: %i) not found which should be in the list. Continuing...\n", rec->blobID);
				break;
			}
			//curIter->second.filter->updateMeasurement(cX, cY, &cX, &cY);
			//            if (cX > .98f || cX < 0.02f || cY > .98f || cY < .02f)
			//            {

			//            }
			if (cX > .999f)
				cX = .999f;
			if (cX < 0.f)
				cX = 0.f;

			if (cY > .999f)
				cY = .999f;
			if (cY < 0.f)
				cY = 0.f;

			printf("CUR %f, %f\n", cX, cY);

			tuioServer->updateTuioCursor(curIter->second.cursor, cX, cY);
			break;

		case HTBlobInterpreter::HTET_DRAG_OFF:
			curIter = cursorMap.find(rec->blobID);
			if (curIter == cursorMap.end())
			{
				printf("(HTTUIOServer::handleEvents) WARNING: DRAG_OFF: Cursor (ID: %i) not found which should be in the list. Continuing...\n", rec->blobID);
				break;
			}
			//delete curIter->second.filter;
			printf("Removing Cursor... BlobID: %i SID: %li (mapsize: %lu)\n", rec->blobID, curIter->second.cursor->getSessionID(), cursorMap.size() - 1);
			tuioServer->removeTuioCursor(curIter->second.cursor);
			cursorMap.erase(curIter);
			break;

		default:
			break;
		}
	}

	tuioServer->commitFrame();
}
开发者ID:cadet,项目名称:libHecato,代码行数:90,代码来源:HTTUIOServer.cpp


注:本文中的TuioCursor::getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。