本文整理汇总了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();
}