Log in or register to post comments

Code which is triggered when the image target is lost

January 24, 2012 - 7:36am #1

Hello,
Can you please let me know the source code which is executed,when the image target is lost.for example in the project ImageTargets when the stone or chip imagetarget is detected the teapot is rendered,but when the focus on the chips or stones is lost,the tea pot is removed,where in the code is this handled.
regards
khegde

Re: Code which is triggered when the image target is lost

January 27, 2012 - 1:40am #4

If you're using Android and Eclipse look under /jni/ImageTargets.cpp and have a look at the renderFrame method.
The teapot is rendered for every frame the trackable is in view. If the trackable is not in view then the teapot is not rendered for those frames.
There is not any sort of "unrendering" code.

If you want to trigger something when the focus on the target is lost you can try executing something like this in that method:

if(state.getNumActiveTrackables() == 0){
//your code here
}

Re: Code which is triggered when the image target is lost

January 26, 2012 - 10:45pm #3

Hello Kim,
Thankyou for your reply,but i am not able to find the place,where the teapot rendering is removed.
regards
kaushik

Re: Code which is triggered when the image target is lost

January 24, 2012 - 8:20pm #2

This is handled in the renderFrame method in ImageTargets.cpp. This method is called each frame. For each visible target, the teapot is rendered using the pose matrix for that target for that frame. If no targets are visible, nothing is drawn that frame.

Note if you are using the Unity extension this work differently. See the TrackableEventHandler script.

- Kim

Log in or register to post comments