Log in or register to post comments

Modification - Image Targets

June 16, 2011 - 4:20pm #1

Hello,

I want to modify (for training) ImageTargets example.

I want to get:
In place of Teapot I want to get 2 buttons with text WWW1 and WWW2.
WWW1 after click (on tablet/phone screen) open web browser with link
WWW2 after click open another page

To do so, I have to modify JAVA project or CPP files ????

Thanks for answers ;)

With greatings
Niedved

Re: Modification - Image Targets

June 19, 2011 - 8:29pm #7

The simplest approach might be to figure out where the touch lands on the target. You can use the projectScreenPointToPlane() method from the Dominoes sample for this. That will give you the intersection point with the target plane. If you know where your buttons are located on the target, you can either do a simple distance check or a bounds check to see if the intersection point falls inside the button.

- Kim

Re: Modification - Image Targets

June 18, 2011 - 1:56pm #6

Simple touch event is not a problem. It's showed on Domino example.
But I want to have 2 objects rendered on Trackable. 3d buttons.
And its work but now I want to make diferent actions for them. And only after clicking directly on them.

But maybe there is a chance to simply set 2 JAVA buttons in JAVA over my tracable img. And then simply use onclick method?

Thx. :)

Re: Modification - Image Targets

June 17, 2011 - 7:11pm #5

If you look at adb logcat while your AR app is running and you tap the screen you'll notice that the andoird OS picks it up and prints a message to the log. At some level either NDK or java you need to register for that event.

I'm going to add this to one of my projects over the next few days. I'll let you know how to do it.

Re: Modification - Image Targets

June 17, 2011 - 3:09pm #4

Ok so I'm generating two objects (flat 2D buttons ) which show up when my trackable is active.

glUseProgram(shaderProgramID);
         
		 //button left
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotTexCoords[0]);
        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);
        
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, thisTexture1->mTextureID);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] );
        glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]);

		
         //button right
        glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bVertices[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &bTexCoords[0]);
        glEnableVertexAttribArray(vertexHandle);
        glEnableVertexAttribArray(normalHandle);
        glEnableVertexAttribArray(textureCoordHandle);
     
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, thisTexture2->mTextureID);
        glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] );
        glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &bIndices[0]);

No I want to make them clickable. But not by "pressing" them on "paper" but i want to use them like buttons. When I click screen of my phone I want to do some actions in JAVA.

Any idea ?

Re: Modification - Image Targets

June 17, 2011 - 8:55am #3
eggie5 wrote:

The code to do this is in the image targets example - just replace the existing onclick code to call back up to java

Sorry but where is it. I'm looking for it and I can't find it :confused:

Re: Modification - Image Targets

June 16, 2011 - 4:28pm #2

Of couse you have to modify the files - you are adding functionality. The code to do this is in the image targets example - just replace the existing onclick code to call back up to java - and then in java to launch the browser:

String url = "http://www.eggie5.com";
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);

Not sure if you can pass an intent on the native layer...., the above example does it on the android layer - you need to call back up to android from native - an example of this is found in the dominoes example where it plays sounds.

Log in or register to post comments