- Sort Posts
- 7 replies
- Last post
Re: Added button function in the texture.
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.
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.
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.
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
I don't understand the question, what would you like to do?
- Kim