- Sort Posts
- 9 replies
- Last post
Change the model
Change the model
Change the model
Change the model
Hello Check,
I see you used the display a toast example however you are showing a dialog instead of a toast. The toast was set with a default length. In your code your dialog will not go away because there is no event to trigger it going away. You can do a check to see if there are zero trackables found in the c++ code and then call a java function to hide the dialog.
Thank you,
-Peter
Re: Change the model
Hi Peter,
Here i attached the code which i modified.,
In ImageTarget.cpp
int lastTrackableId = -1;
JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv * env, jobject obj)
{
//LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame");
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Get the state from QCAR and mark the beginning of a rendering section
QCAR::State state = QCAR::Renderer::getInstance().begin();
// Explicitly render the Video Background
QCAR::Renderer::getInstance().drawVideoBackground();
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx
{
// Get the trackable:
const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
// Compare this trackable's id to a globally stored id
// If this is a new trackable, find the displayMessage java method and
// call it with the trackable's name
if (trackable->getId() != lastTrackableId) {
jstring js = env->NewStringUTF(trackable->getName());
jclass javaClass = env->GetObjectClass(obj);
jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
env->CallVoidMethod(obj, method, js);
lastTrackableId = trackable->getId();
}
QCAR::Renderer::getInstance().end();
}
}
In ImageTargeRedender.java
public void displayMessage(String text)
{
// We use a handler because this thread cannot change the UI
Message message = new Message();
message.obj = text;
mainActivityHandler.sendMessage(message);
}
In ImageTarget.java
OnResume method
ImageTargetsRenderer.mainActivityHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
String text = (String) msg.obj;
// The Toast display the name of the detected trackable on the screen
Context context = getApplicationContext();
int duration = Toast.LENGTH_SHORT;
// Toast toast = Toast.makeText(context, text, duration);
// toast.show();
// The following opens a pre-defined URL based on the name of trackable detected
if (text.equalsIgnoreCase("stones"))
{
dialog = new Dialog(ImageTargets.this);
dialog.setContentView(R.layout.main);
button = (ImageView) dialog.findViewById(R.id.imageView1);
dialog.show();
} } }; }
In the above the code, the custom image is show on the screen, when the marker is move away..,help me to solve the problem..,
Re: Change the model
Hello check,
Can you post the code from your renderframe function in ImageTargets.cpp ? Does the augmentation go away when you move away from the marker or is it staying on screen?
In Our sample app in ImageTargets.cpp in the renderFrame function notice the for loop under the comment "//Did we find any trackables this frame?" This is where we render if a target is detected. Then notice how we swap textures based on the trackable found. If you want separate augmentations you can edit this portion to render different augmentations based on the trackable found.
Thank you,
-Peter
Re: Change the model
Hello check,
Please see the ImageTargets sample application for an example of creating a menu. In the sample app the menu is accessed by the Menu button on the Android phone however you can change this. The menu responds to user presses on items in the menu.
please let me know if you have questions about the code after looking at the ImageTargets sample application.
Thank you,
-Peter
Hi Peter!
Thank you for your reply. As you said, I already done that a couple of times already. I've been doing that ever since.
I also removed the teapot.h and the syntax #include "Teapot.h" so that there will be no more teapot to show. BUT still, the shape
of the model is still the shape of the teapot. :(