Example #1
0
void ITA_ForcesApp::getRSCursorPos()
{
	mHasHand = false;
	mMousePos.clear();
	auto numHands = mHandData->QueryNumberOfHands();
	pxcUID handId;

	mNumInputs = 0.0f;
	for (int i = 0; i < numHands; ++i)
	{
		if (mHandData->QueryHandId(PXCHandData::ACCESS_ORDER_BY_ID, i, handId) >= PXC_STATUS_NO_ERROR)
		{
			PXCHandData::IHand *hand;
			if (mHandData->QueryHandDataById(handId, hand) >= PXC_STATUS_NO_ERROR)
			{
				if (hand->HasCursor())
				{
					PXCHandData::ICursor *cursor;
					if (hand->QueryCursor(cursor) >= PXC_STATUS_NO_ERROR)
					{
						auto cursorPos = cursor->QueryPointImage();

						// Mapping block
						PXCPoint3DF32 uvz[1]{ cursorPos };
						uvz[0].z *= 1000.0f;
						PXCPointF32 ijj[1];
						auto stat = mMapper->MapDepthToColor(1, uvz, ijj);
						//
						if(!mMouseInput) 
							mMousePos.push_back( vec3(remapPos(vec2(ijj[0].x, ijj[0].y)), 0.0));

						mHasHand = true;
						mNumInputs += 1.0f;
					}
				}
			}
		}
	}

	if (numHands < 1)
		mIdle = true;
	else
		mIdle = false;

	mForceMode = mRepulsing ? FORCE_R : FORCE_A;
}
Example #2
0
void ITA_ForcesApp::getRSGestureState()
{
	auto numGestures = mHandData->QueryFiredGesturesNumber();
	for (int j = 0; j < numGestures; ++j)
	{
		PXCHandData::GestureData gestData;
		if (mHandData->QueryFiredGestureData(j, gestData) >= PXC_STATUS_NO_ERROR)
		{
			PXCHandData::IHand *hand;
			if (mHandData->QueryHandDataById(gestData.handId, hand) >= PXC_STATUS_NO_ERROR)
			{
				std::wstring str(gestData.name);
				if (str.find(L"cursor_click") != std::string::npos)
				{
					if (mHasHand)
						mRepulsing = !mRepulsing;
				}
			}
		}
	}
}