Log in or register to post comments

Getting touch event On 3D model

July 19, 2012 - 3:01am #1

I need to display more than one 3d objects on ImageTarget sample ,and needs to get touch on object event .

can anyone give me the right solution .......

thanks in advance 

Getting touch event On 3D model

December 21, 2016 - 2:27am #22

I need to display more than one 2d objects on ImageTarget sample ,and needs to get touch on object event .

The below solution is not working me. Please help me

Getting touch event On 3D model

February 3, 2014 - 2:42am #21

 And dominoes is handling touches using virtual buttons

No it is not - look at the code.

 

You can follow a discussion of how someone applied touches to cloud reco image targets here:

https://developer.vuforia.com/forum/ios/3d-touch-error

and here:

https://developer.vuforia.com/forum/ios/intersection-point-target-overlay-cloud-reco-example

 

N

Getting touch event On 3D model

February 1, 2014 - 5:11am #20

Hello,

     As we know, Virtual buttons  does not support Cloud databases. So, my question is I am using cloudreco to load a 3d model. And dominoes is handling touches using virtual buttons. So, it is not useful for cloud recongnition.

    And I want to handle touch on that model. So, How can I achieve it ? 

   Thanks. 

 

  

Getting touch event On 3D model

November 29, 2013 - 6:46am #19

See my response to the same question you posted here:

https://developer.vuforia.com/forum/ios/touch-3d-model-and-fade-out#comment-2035471

N

Getting touch event On 3D model

November 29, 2013 - 6:12am #18

Hello! is it possible with any library/api? http://www.youtube.com/watch?v=TzD1g-mhRB8 thank you!

Getting touch event On 3D model

August 26, 2013 - 7:46am #17

It is for native anyway.

With a teapot the best you may be able to do is to use its bounding box which should suffice for most circumstances.

This is the kind of functionality that is easy to achieve in Unity which is why we recommend it as the quickest and most convenient path to creating Vuforia applications.

 

N

Getting touch event On 3D model

August 26, 2013 - 2:38am #16

I suppose this solution is going to work only for cuboid 3D object. It may not work properly for teapot or any other 3D object.

I am using mtl2opengl (https://github.com/ricardo-rendoncepeda/mtl2opengl) to generate 3D model. I need to detect whether user has touched the 3D object. I am just wondering how it can be implemented with native IOS SDK.

Thanks in advance...

Getting touch event On 3D model

October 4, 2012 - 6:03am #15

Can any one please help wtih this in android version its urgent please
thank you

Getting touch event On 3D model

August 16, 2012 - 2:27am #14

Please could you start this as a new thread within the Android forum? ...as this one's for iOS

N

Getting touch event On 3D model

August 15, 2012 - 10:18pm #13

 

Hey Guys,

I want to display no of models, one by one, in my project and change them on touch event.
Can some one guide me how to change my model to some other on tapping the screen in my ImageTarget Project..?

I have tried changing bring teapot after my own model on touch event by calling a new function in ImageTarget.cpp

Heres the link to my ImageTarget.cpp.

Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_getCallFromJava is the function that I have created.

 

Thanks.

 

 

Getting touch event On 3D model

August 13, 2012 - 12:24pm #12

Super - thanks for sharing :)

N

Getting touch event On 3D model

August 13, 2012 - 5:20am #11

Quick  trick :

you have to drop domino at position of your 3d object 

if you are useing more than one 3d object you should drop domino at all 3d object position

 QCAR::Vec2F position (-50.0f, -50);

                dropDomino(position);//this is method defined in dominoes.mm you can add this from dominoes example code

 

now on touch event 

paste code used in dominoes

like

{

UITouch* touch = [touches anyObject];

    CGPoint location = [touch locationInView:self];

    dominoesTouchEvent(ACTION_UP, 0, location.x, location.y);

    handleTouches();//this will called only in tuoch end

}

   In   handleTouches();//this will called in touch end only this is defined in dominoes.mm


 if (touch1.didTap && touch1.startTime > lastTapTime) {

    

    // Find the start and end points in world space for the tap

    // These will lie on the near and far plane and can be used for picking

    QCAR::Vec3F intersection, lineStart, lineEnd;

    

    projectScreenPointToPlane(QCAR::Vec2F(touch1.tapX, touch1.tapY), QCAR::Vec3F(0, 0, 0), QCAR::Vec3F(0, 0, 1), intersection, lineStart, lineEnd);

    

    Domino* domino;

    Domino* selected = NULL;

    

    // For each domino, check for intersection with our picking line

   

    for (int i = 5; i < 10; i++) {

      domino = &dominoArray[i];

      bool intersection = checkIntersectionLine(domino->pickingTransform, lineStart, lineEnd);

      if (intersection) {

        selected = domino;

        [[QCARutils getInstance] squarButtonClicked:i];

        NSLog(@"button at index :%d clicked",i);

        selectedDominoIndex = i;

        break;

      }

    }

  }

 


  

Getting touch event On 3D model

August 12, 2012 - 1:51pm #10

No problem abhishekkatare.

Glad I could help.

If are able to share your solution and your learnings, then the rest of the community will be most grateful :)

N

Getting touch event On 3D model

August 12, 2012 - 2:34am #9

Hi abhishekkatare,

Can you post the solution, plis?

I have the same problem.

Thanks in advance. ;)

Getting touch event On 3D model

August 11, 2012 - 1:44am #8

Thanks so much NalinS

  Now i got solution .....

Getting touch event On 3D model

August 7, 2012 - 10:18pm #7

Hi NalinS,

I have tried to much ,but unable to get solution ....

can you please try to understand it further 

I have rendered more than 3 square  with texture that seems like buttons....

now user tries touch them through screen(not virtual buttons) 

on touch screen i can get (x,y) value of screen 

but how can i get that any 3d object is present at that position and which Object present at that position 

http://www.youtube.com/watch?v=wi80g9WJvmw 

please see this video at( 1.05 min ) this will clear all requirement of mine

please help it's urgent 

 

 

Getting touch event On 3D model

July 27, 2012 - 5:18am #6

It is not clear to me what you are trying to do.

However this code ends up with the modelViewProjection set up for an augmentation:

            QCAR::Matrix44F modelViewProjection;

            

            ShaderUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);

            ShaderUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);

            ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);

so am I right in thinking you want to detect when the user touches this 3D object?, because this matrix should contain the coordinates.

The renderAugmentation method in the dominoes sample uses this matrix to render all the dominoes, and calculates their positions from the modelViewProjection matrix.  You might need to experiment a little and try a few things out.

 

 

Getting touch event On 3D model

July 26, 2012 - 11:08pm #5

Hi, Nalins

thanks for your response ....

I tried to much than i found that . in dominos example we draws domino by getting touch coordinates(x,y). so we can further calculate the intersection 

of touch event point and domino for delete functionality .

 

but in my case we do not know the coordinates since we are drawing it by just using 

ShaderUtils::translatePoseMatrix 

can you please explain that how to use dominos code for my requirement.

can i use

bool intersection = checkIntersectionLine(SampleMath::Matrix44FIdentity(), lineStart, lineEnd);

if yes than how 

thanks 

Getting touch event On 3D model

July 24, 2012 - 2:47am #4

Hi abhishekkatare,

Ok let's break this down, but bear in mind the two are related:

To get touch events from the screen, your view/class must handle events / implement methods for 

touchesBegan, touchesMoved, touchesCancelled, touchesEnded

As you can see from EAGLView.mm in the dominoes sample:

// Pass touch events through to the Dominoes module

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch* touch = [touches anyObject];

    CGPoint location = [touch locationInView:self];

    dominoesTouchEvent(ACTION_DOWN, 0, location.x, location.y);

}

 

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch* touch = [touches anyObject];

    CGPoint location = [touch locationInView:self];

    dominoesTouchEvent(ACTION_CANCEL, 0, location.x, location.y);

}

 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch* touch = [touches anyObject];

    CGPoint location = [touch locationInView:self];

    dominoesTouchEvent(ACTION_UP, 0, location.x, location.y);

}

 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch* touch = [touches anyObject];

    CGPoint location = [touch locationInView:self];

    dominoesTouchEvent(ACTION_MOVE, 0, location.x, location.y);

}

You can see that these touches are passed through to the dominoesTouchEvent, which records the touches for later validation by HandleTouches, which is the code that answers your second question as to which model does the user touch.

HTH

N

 

 

Getting touch event On 3D model

July 23, 2012 - 11:19pm #3

Thanks a lots...

now i can add more than one 3d models...

but my requirement is to get touch events ...from screen .....

when user touches screen how can i determine if he/she trying to touch which model ...?

I do not need to let him touch ,like in dominos example....

this is how i am to implement .....http://www.youtube.com/watch?v=wi80g9WJvmw  


can you please help me

Thanks 

 

  
 
 
 
 
 
 
 
 
 
 
 

 

 

Getting touch event On 3D model

July 19, 2012 - 4:05am #2

hi abhisekkatare,

You can use the following code as an example, which places a second teapot translated by a few units, on top of the same image target:

// second teapot

            QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

            

            ShaderUtils::translatePoseMatrix(10.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);

            ShaderUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);

            ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);

            

            glUseProgram(shaderProgramID);

            

            glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.vertices);

            glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.normals);

            glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)obj3D.texCoords);

            

            glEnableVertexAttribArray(vertexHandle);

            glEnableVertexAttribArray(normalHandle);

            glEnableVertexAttribArray(textureCoordHandle);

            

            glActiveTexture(GL_TEXTURE0);

            glBindTexture(GL_TEXTURE_2D, [obj3D.texture textureID]);

            glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (const GLfloat*)&modelViewProjection.data[0]);

            glDrawElements(GL_TRIANGLES, obj3D.numIndices, GL_UNSIGNED_SHORT, (const GLvoid*)obj3D.indices);

            

 

            

            ShaderUtils::checkGlError("EAGLView renderFrameQCAR");   // this will help you to figure out exactly where this code goes


As for getting a touch on the object, you should look at the dominoes sample.  HandleTouches takes the touch and uses

projectScreenPointToPlane

..in order to create an intersection line for the touch.  The code also shows how to check this line against all the dominoes to see if it touches it.

  

HTH

N

 

 

Log in or register to post comments