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


C++ Marker::setPosition方法代码示例

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


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

示例1: DataHandler

// DataHandler receives data from the server
void __cdecl DataHandler(sFrameOfMocapData* data, void* pUserData) {
	// Cast user data as ClientHandler
	ClientHandler* pClient = (ClientHandler*) pUserData;

	// Lock the ClientHandler so data isn't changed
	// by another thread.
	if (!pClient->lock())
		return;

	// Unlock the ClientHandler
	pClient->unlock();

	// Rigid Bodies
	for(int i = 0; i < data->nRigidBodies; i++) {
		// Get pointer to Rigid Body
		RigidBody* body = pClient->getRigidBody(data->RigidBodies[i].ID);

		// Check if Rigid Body with the given ID exists
		if ( body ) {
			// Lock the ClientHandler so data isn't changed
			// by another thread.
			if (!pClient->lock())
				continue;

			// Update the Position and Orientation of the Rigid Body
			float x, y, z;
			float qx, qy, qz, qw;

			if (pClient->coordinateSystem()) {
				x = data->RigidBodies[i].x;
				y = data->RigidBodies[i].y;
				z = data->RigidBodies[i].z;

				qx = data->RigidBodies[i].qx;
				qy = data->RigidBodies[i].qy;
				qz = data->RigidBodies[i].qz;
				qw = data->RigidBodies[i].qw;
			} else {
				x = -data->RigidBodies[i].x;
				y = data->RigidBodies[i].z;
				z = data->RigidBodies[i].y;

				qx = -data->RigidBodies[i].qx;
				qy = data->RigidBodies[i].qz;
				qz = data->RigidBodies[i].qy;
				qw = data->RigidBodies[i].qw;
			}
				
			body->addFrame(Eigen::Vector3f(x, y, z),
				Eigen::Quaternionf(qw, qx, qy, qz));

			// Clear all the previous markers that were attached to the Rigid Body
			body->clearMarkers();

			// Gather all the Markers attached to the Rigid Body
			for(int iMarker = 0; iMarker < data->RigidBodies[i].nMarkers; iMarker++) {
				// Create a new marker
				Marker marker;

				// Get the information about the marker
				if(data->RigidBodies[i].MarkerIDs)
					marker.setID(data->RigidBodies[i].MarkerIDs[iMarker]);

				if(data->RigidBodies[i].Markers) {
					if (pClient->coordinateSystem()) {
						x = -data->RigidBodies[i].Markers[iMarker][0];
						y = data->RigidBodies[i].Markers[iMarker][1];
						z = data->RigidBodies[i].Markers[iMarker][2];
					} else {
						x = -data->RigidBodies[i].Markers[iMarker][0];
						z = data->RigidBodies[i].Markers[iMarker][1];
						y = data->RigidBodies[i].Markers[iMarker][2];
					}

					marker.setPosition(Eigen::Vector3f(x, y, z));
				}

				// Add the marker to the Rigid Body
				body->addMarker(marker);
			}

			// Unlock the ClientHandler
			pClient->unlock();
		}
	}

	// Update the OptiTrack data
	pClient->updateData();

}
开发者ID:mdfeist,项目名称:ProjectDR,代码行数:91,代码来源:ClientHandler.cpp


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