我是android -ndk AR的新手,所以需要一些帮助我使用Virtaul按钮样本(来自Vuforia)。
我可以通过物理触摸获得虚拟触摸
如果我触摸屏幕上的红色按钮,那么茶壶会变成红色如果触摸蓝色按钮茶壶换成蓝色茶壶?
答案 0 :(得分:1)
我自己想通了 需要一个复杂的caclution和 使用以下公式来使用它
QCAR::CameraDevice& cameraDevice = QCAR::CameraDevice::getInstance();
const QCAR::CameraCalibration& cameraCalibration = cameraDevice.getCameraCalibration();
/////////////////////////////////////////////////////////Tyre//////////////////////////////////////////
QCAR::Vec2F cameraPoint = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -97.68, -15.93, 0.f ));
QCAR::Vec2F cameraPoint1 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -28, -15.93, 0.f ));
QCAR::Vec2F cameraPoint2 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -97.68, -50.52, 0.f));
QCAR::Vec2F cameraPoint3 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -28.f, -50.52, 0.f));
//////////////////////////////////////////////////HeadLight////////////////////////////////////////////////////////////
QCAR::Vec2F cameraPoint4 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -52.28, 53, 0.f ));
QCAR::Vec2F cameraPoint5 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -21.f, 53.f, 0.f ));
QCAR::Vec2F cameraPoint6 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -53.f, -8.f, 0.f));
QCAR::Vec2F cameraPoint7 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( -21.f, -8.f, 0.f));
//////////////////////////////////////////////////////Indicator//////////////////////////////////////////////////////////////////////////////
QCAR::Vec2F cameraPoint8 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F(-4.f, -94.f, 0.f ));
QCAR::Vec2F cameraPoint9 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( 18, -94, 0.f ));
QCAR::Vec2F cameraPoint10 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F(-4.f, -71.f, 0.f));
QCAR::Vec2F cameraPoint11 = QCAR::Tool::projectPoint(cameraCalibration, trackable->getPose(), QCAR::Vec3F( 18.f, -71.f, 0.f));
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
QCAR::Vec2F screenPoint= cameraPointToScreenPoint(cameraPoint);
QCAR::Vec2F screenPoint1= cameraPointToScreenPoint(cameraPoint1);
QCAR::Vec2F screenPoint2= cameraPointToScreenPoint(cameraPoint2);
QCAR::Vec2F screenPoint3= cameraPointToScreenPoint(cameraPoint3);
//////////////////////////////////////////////////////////////////
QCAR::Vec2F screenPoint4= cameraPointToScreenPoint(cameraPoint4);
QCAR::Vec2F screenPoint5= cameraPointToScreenPoint(cameraPoint5);
QCAR::Vec2F screenPoint6= cameraPointToScreenPoint(cameraPoint6);
QCAR::Vec2F screenPoint7= cameraPointToScreenPoint(cameraPoint7);
//////////////////////////////////////////////////////////////////
QCAR::Vec2F screenPoint8= cameraPointToScreenPoint(cameraPoint8);
QCAR::Vec2F screenPoint9= cameraPointToScreenPoint(cameraPoint9);
QCAR::Vec2F screenPoint10= cameraPointToScreenPoint(cameraPoint10);
QCAR::Vec2F screenPoint11= cameraPointToScreenPoint(cameraPoint11);
//////////////////////////////////////////////////////////////////
blY_Tyre=screenPoint.data[0];
blX_Tyre=screenPoint.data[1];
brY_Tyre=screenPoint1.data[0];
brX_Tyre=screenPoint1.data[1];
tlY_Tyre=screenPoint2.data[0];
tlX_Tyre=screenPoint2.data[1];
trY_Tyre=screenPoint3.data[0];
trX_Tyre=screenPoint3.data[1];
//////////////////////////////
blY_Lite=screenPoint4.data[0];
blX_Lite=screenPoint4.data[1];
brY_Lite=screenPoint5.data[0];
brX_Lite=screenPoint5.data[1];
tlY_Lite=screenPoint6.data[0];
tlX_Lite=screenPoint6.data[1];
trY_Lite=screenPoint7.data[0];
trX_Lite=screenPoint7.data[1];
//////////////////////////////
blY_Miror=screenPoint8.data[0];
blX_Miror=screenPoint8.data[1];
brY_Miror=screenPoint9.data[0];
brX_Miror=screenPoint9.data[1];
tlY_Miror=screenPoint10.data[0];
tlX_Miror=screenPoint10.data[1];
trY_Miror=screenPoint11.data[0];
trX_Miror=screenPoint11.data[1];