I need to create button that event of button can choose or select model that users wanted
How can I do?
It's going to be a little difficult working with QCAR if you don't know C/C++, but here's the basic idea:
When an Android button is tapped in Java, you call a native method to handle the event. This happens in the UIThread, and it's important to know that the UIThread cannot make OpenGL calls.
The OpenGL context is bound to the GLThread. If you're looking at the ImageTargets sample project, all the methods in the ImageTargetsRenderer.java class are called on the GLThread. When these methods call down to native it is safe to make OpenGL calls.
So when a button is pressed in Java, you call down to native and save a bit of state, say an ID for the model you want drawn. Then, on the next onDrawFrame method call (this is called in a loop by the rendering system) you can use that state information to draw the correct model.
You can swap the model by changing the calls to glVertexAttribPointer and glDrawElements. You may also want to bind a different texture by changing the call to glBindTexture. Search for those names in ImageTargets.cpp or Dominoes.cpp (the ImageTargets sample is much simpler, and might be a better starting point).
I have already tested your Dominoes sample application and VirtualButtons sample. It work fine
I have already created button on the screen but I don't know how send the events to native code to switch model
My application have two buttons which modify from Dominoes
The first button , I input event for playing mediaplayer of Android Sdk
The second button ,I need to create event for switching model
Please help me ,
I dont' have knowledge in C/C++
Thank you kim for your suggestion
Do you want to create a button that the user taps on the screen, or a Virtual Button that the user presses on the target?
If you just want an on-screen button, you can use the Android SDK to place it and handle its events, and then send the events to native code to switch your model. See the Dominoes sample application for some example code.
If you'd like to use QCAR's Virtual Buttons, take a look at the VirtualButtons sample for some example code on creating these and handling events. It should be pretty simple to swap your model data after a button press.
Are you sure you want to delete this message?
Are you sure you want to delete this conversation?