处理3d对象多米诺骨牌Vuforia

时间:2017-01-24 23:29:18

标签: opengl vuforia

我使用带有示例Domino的vuforia

请告诉我什么是domino->采用

中的pickingTransform
Vuforia::Vec3F intersection, lineStart, lineEnd;
    projectScreenPointToPlane(Vuforia::Vec2F(touch1.tapX, touch1.tapY), Vuforia::Vec3F(0, 0, 0), Vuforia::Vec3F(0, 0, 1), intersection, lineStart, lineEnd);

    Domino* domino;
    Domino* selected = NULL;
    float dist;

    // For each domino, check for intersection with our picking line
    for (int i = 0; i < dominoCount; i++) {
        domino = &dominoArray[i];
        bool intersection = checkIntersectionLine(domino->pickingTransform, lineStart, lineEnd);
        if (intersection) {
            selected = domino;
            selectedDominoIndex = i;
            break;
        }
    }

我用matrix44F(modelViewMatrix)替换了domino-&gt; pickingTransform

intersection = SampleMath.getPointToPlaneIntersection(
                SampleMath.Matrix44FInverse(vuforiaAppSession.getProjectionMatrix()),
                matrix44F, metrics.widthPixels, metrics.heightPixels,
                new Vec2F(x, y), new Vec3F(0, 0, 0), new Vec3F(0, 0, 1));
        lineStart = SampleMath.getPointToPlaneLineStart(
                SampleMath.Matrix44FInverse(vuforiaAppSession.getProjectionMatrix()),
                matrix44F, metrics.widthPixels, metrics.heightPixels,
                new Vec2F(x, y), new Vec3F(0, 0, 0), new Vec3F(0, 0, 1));
        lineEnd = SampleMath.getPointToPlaneLineEnd(
                SampleMath.Matrix44FInverse(vuforiaAppSession.getProjectionMatrix()),
                matrix44F, metrics.widthPixels, metrics.heightPixels,
                new Vec2F(x, y), new Vec3F(0, 0, 0), new Vec3F(0, 0, 1));

        boolean bool = checkIntersectionLine(matrix44F, lineStart, lineEnd);

但现在应用程序没有检测到3d上的触摸

我认为domino-&gt; pickingTransform是旋转后的modelViewMatrix,不是吗?

我的应用没有任何轮换,我需要检测对象的相同状态的触摸

1 个答案:

答案 0 :(得分:3)

domino->pickingTransform几乎是为每个多米诺骨牌对象绘制的最终矩阵。多米诺骨牌样本的工作方式是,对于每个对象(多米诺骨牌),应用程序检查屏幕触摸的投影点,并查看它是否与对象的矩阵相交。拾取矩阵并不完全相同,因为您希望使触摸更具响应性,因此您可以使其比绘图矩阵更宽一些。

很难理解你究竟取而代之的是什么,但它应该是与你绘制每个物体的矩阵非常相似的矩阵(当然是4X4)。