Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

handle touches on 3d object Dominoes Vuforia

Tags:

opengl

vuforia

I use vuforia with sample Dominoes

Tell me please what is domino->pickingTransform in

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;
        }
    }

I replaced domino->pickingTransform with matrix44F (modelViewMatrix)

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);

but now the application does not detect touch on 3d

I think that domino->pickingTransform is modelViewMatrix after rotation, isnt it?

my app havent any rotation and I need to detect touches in the same state of the object

like image 380
mr_nobody Avatar asked Oct 18 '22 18:10

mr_nobody


1 Answers

domino->pickingTransform is pretty much the final matrix that is being drawn for each domino object. The dominos sample work in a way that for each object (domino), the app checks the projected point of the screen touch and sees if it intersects the matrix of the object. The picking matrix is not exactly the same, since you want to make the touching more responsive, so you make it a little wider than the drawing matrix.

It is hard to understand with what exactly you have replaced it, but it should be pretty similar matrix (4X4, of course) to the one with which you are drawing each of your objects.

like image 190
yakobom Avatar answered Oct 21 '22 05:10

yakobom