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


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

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


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

示例1: appendNewInputEventsSinceLastCall

void VRTUIODevice::appendNewInputEventsSinceLastCall(VRDataQueue *inputEvents)
{

	// Send out events for TUIO "cursors" by polling the TuioClient for the current state
	std::list<TuioCursor*> cursorList = _tuioClient->getTuioCursors();
	_tuioClient->lockCursorList();

	// Send "button" up events for cursors that were down last frame, but are now up.
	std::vector<int> downLast;
	for (std::set<int>::iterator downLast_it = _cursorsDown.begin(); downLast_it!= _cursorsDown.end(); ++downLast_it ) {
		downLast.push_back(*downLast_it);
	}

	for (int i=0;i<downLast.size();i++) {
		bool stillDown = false;
		for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) {
			TuioCursor *tcur = (*iter);
			if (tcur->getCursorID() == downLast[i]) {
				stillDown = true;
			}
		}
		if (!stillDown) {
			std::string event = "Touch_Cursor_Up";
			_dataIndex.addData(event + "/Id", downLast[i]);
			inputEvents->push(_dataIndex.serialize(event));
			_cursorsDown.erase(downLast[i]);
		}
	}

	// Send "button" down events for cursors that are new and updated positions for all cursors
	for (std::list<TuioCursor*>::iterator iter = cursorList.begin(); iter!=cursorList.end(); iter++) {
		TuioCursor *tcur = (*iter);

		if (_cursorsDown.find(tcur->getCursorID()) == _cursorsDown.end()) {
			std::string event = "Touch_Cursor_Down";
			_dataIndex.addData(event + "/Id", tcur->getCursorID());
			_dataIndex.addData(event + "/XPos", _xScale*tcur->getX());
			_dataIndex.addData(event + "/YPos", _yScale*tcur->getY());
			inputEvents->push(_dataIndex.serialize(event));
			_cursorsDown.insert(tcur->getCursorID());
		}

		if (tcur->getMotionSpeed() > 0.0) {
			std::string event = "Touch_Cursor_Move";
			_dataIndex.addData(event + "/Id", tcur->getCursorID());
			_dataIndex.addData(event + "/XPos", _xScale*tcur->getX());
			_dataIndex.addData(event + "/YPos", _yScale*tcur->getY());
			inputEvents->push(_dataIndex.serialize(event));
		}

		// Can also access several other properties of cursors (speed, acceleration, path followed, etc.)
		//std::cout << "cur " << tcur->getCursorID() << " (" <<  tcur->getSessionID() << ") " << tcur->getX() << " " << tcur->getY()
		// << " " << tcur->getMotionSpeed() << " " << tcur->getMotionAccel() << " " << std::endl;

		// This is how to access all the points in the path that a cursor follows:
		//std::list<TuioPoint> path = tuioCursor->getPath();
		//if (path.size() > 0) {
		//  TuioPoint last_point = path.front();
		//  for (std::list<TuioPoint>::iterator point = path.begin(); point!=path.end(); point++) {
		//    last_point.update(point->getX(),point->getY());
		//  }
		//}
	}

	_tuioClient->unlockCursorList();
}
开发者ID:ivlab,项目名称:MinVR,代码行数:66,代码来源:VRTUIODevice.cpp


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