0

我已经用 vuforia eclipse 项目制作了 5(五个)3D 对象,现在我希望这 5 个对象中的每一个都具有点击功能:1. 第一个对象-->当我触摸 1 个图标时,它链接到网站 2. 第二个对象--> 打开画廊 3. 第三个对象 --> 打开文件(例如 pdf) 4. 第四个对象 --> 打开这样的文件 5. 关闭应用程序。

在这种情况下请帮助我,任何帮助将不胜感激。谢谢,

问候

4

2 回答 2

0

I use Android as an operating system. @ashatte

于 2013-10-09T04:51:54.373 回答
0

您应该查看视频播放示例应用程序:here

特别是,isTapOnScreenInsideTarget()方法位于VideoPlayback.cpp

JNIEXPORT bool JNICALL
Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlayback_isTapOnScreenInsideTarget(JNIEnv *env, jobject, jint target, jfloat x, jfloat y)
{
    //LOG("Java_com_qualcomm_QCARSamples_VideoPlayback_VideoPlayback_isTapOnScreenInsideTarget");
    // Here we calculate that the touch event is inside the target
    QCAR::Vec3F intersection, lineStart, lineEnd;

    SampleMath::projectScreenPointToPlane(inverseProjMatrix, modelViewMatrix[target], screenWidth, screenHeight,
                              QCAR::Vec2F(x, y), QCAR::Vec3F(0, 0, 0), QCAR::Vec3F(0, 0, 1), intersection, lineStart, lineEnd);

    // The target returns as pose the center of the trackable. The following if-statement simply checks that the tap is within this range
    if ( (intersection.data[0] >= -(targetPositiveDimensions[target].data[0])) && (intersection.data[0] <= (targetPositiveDimensions[target].data[0])) &&
         (intersection.data[1] >= -(targetPositiveDimensions[target].data[1])) && (intersection.data[1] <= (targetPositiveDimensions[target].data[1])))
        return true;
    else
        return false;
}

然后您应该查看VideoPlayback.javamGestureDetector代码,因为这是 Android Activity 检测到触摸事件并调用本机方法的地方。

mGestureDetector = new GestureDetector(
            getApplicationContext(), mSimpleListener); 

// Set the double tap listener:
mGestureDetector.setOnDoubleTapListener(new OnDoubleTapListener()
{
    /** Handle the double tap */
    public boolean onDoubleTap(MotionEvent e)
    {
        for (int i = 0; i < NUM_TARGETS; i++)
        {
            // Verify that the tap happens inside the target:
            if (isTapOnScreenInsideTarget(i, e.getX(), e.getY()))
                // Do what you need to do here
        }
    }
}

本质上,您需要将相关方法和文件从 VideoPlayback 示例应用程序中复制到您的项目中(无论是 FrameMarkers 还是 ImageTargets)。很难更具体,因为实现这一点需要大量小的代码更改,但这应该让你开始......

于 2013-10-10T05:57:03.903 回答