Log in or register to post comments

Added button function in the texture.

March 26, 2011 - 3:01am #1

Is it possible?

if it is possible.

I want its method,please :confused:

Re: Added button function in the texture.

April 1, 2011 - 9:10am #8

Yep. If you want to pull the touch handling code out of the Dominoes application, you'll want to grab both the Java and the native (.cpp) code. In Dominoes.java, the onTouchEvent() method is responsible for passing Android touch events to native. It calls the Dominoes.cpp nativeTouchEvent() method with the touch information.

Then, each frame, the Dominoes.cpp handleTouches() method is called to handle any new touch information.

This code is just a sample of what can be done, you will need to adapt it to your project's needs.

- Kim

Re: Added button function in the texture.

April 1, 2011 - 1:36am #7

You're going to have to look at example code to see how to make calls to native code.
It's something like this:

On java side:

protected native void myNativeMethod();

On native side:

JNIEXPORT void JNICALL
    Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_myNativeMethod(JNIEnv* env, jobject obj)
    {}

Re: Added button function in the texture.

March 31, 2011 - 7:44pm #6

Hi kim..i'm come back.

i'm sorry to ask again..

i did cording in the handleTouches()

but...i don't know how i can use the method.

because this method is in the .cpp file ....

please help me again T.T

Re: Added button function in the texture.

March 29, 2011 - 2:05am #5

oh god, thank u ~

i get a big hint to my project.

gob bless you -kim

if i have problems in middle of my project, again ask u :)

Re: Added button function in the texture.

March 28, 2011 - 5:49am #4

Ah, you want to know if the user is touching the teapot when he touches the screen. The QCAR SDK doesn't have any "picking" functions built in, but you can look at the code in the Dominoes sample as a starting point. Open Dominoes.cpp and look at the handleTouches() method. These are the relevant lines of code:

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

...

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

That code can only find intersections with bounding boxes though, and you would need to create the bounding box around your teapot by hand. If you want more precise picking algorithms you'll either need to write your own or find a physics engine that you can integrate.

- Kim

Re: Added button function in the texture.

March 28, 2011 - 12:02am #3

thank u for your reply

ok, explain what i want to do

example sample texture,the teapot, touch on the screen

and be operated just like button

if i touch the teapot, screen is changed the diffrent Activity

i'm sorry, i can not speak english very well

i wish that you understand it .. T.T

Re: Added button function in the texture.

March 27, 2011 - 10:24am #2

I don't understand the question, what would you like to do?

- Kim

Log in or register to post comments