Log in or register to post comments

How to stop AR when moving to other controller

January 15, 2014 - 3:30am #1

Hello sir,

I am trying to build a application where on button click i am calling the qcar code then,

in scanning mode as the image is tracked i am changing the view controller. 

The problems are

1.I cant stop the AR in background even though i changed the controller

2. I a m not getting the view hierarchy .

I am referring the books sample.

 

Please sir help me .i am stuck and getting any help or resources from internet.

Thank You

 

How to stop AR when moving to other controller

January 15, 2014 - 6:53am #8

Thanks. I think the reason you don't see it in viewWillAppear:animated is simply because the XIB gets instantiated EVERY time the experience is loaded. For example, if I go into the Cloud Recognition experience, back out, and then go in again... the view controller gets instantiated via initWithNibName each time (see line 53 of SampleAppAboutViewController). This in turn causes the loadView function to be called, which in turn called the SampleApplicationSession initAR:ARViewBoundsSize:orientation] function, and all the way down the chain until the delegate function onInitARDone:initError is called back in SampleApplicationSession, which then calls [SampleApplicationSession startAR].

Sorry if that's not very clear...

 

 

 

How to stop AR when moving to other controller

January 15, 2014 - 6:39am #7

It should do this automatically 

In the latest Books sample it is using stopAR

- (void)viewWillDisappear:(BOOL)animated {

    if (!self.presentedViewController) {

        [vapp stopAR:nil];

        // Be a good OpenGL ES citizen: now that QCAR is paused and the render

        // thread is not executing, inform the root view controller that the

        // EAGLView should finish any OpenGL ES commands

        [eaglView finishOpenGLESCommands];

    }

 

}

..though for some reason the counterpart call is missing here:

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    // make sure we're oriented/sized properly before reappearing/restarting

    [self handleARViewRotation:self.interfaceOrientation];

}

I'll check as to the reason why.  

However in your own code you should be able to use QCAR utils versions as this is just a wrapper i.e. something like this:

- (void)viewDidAppear:(BOOL)animated

{

    // resume here as in viewWillAppear the view hasn't always been stitched into the hierarchy

    // which means QCAR won't find our EAGLView

    NSLog(@"ARVC: viewDidAppear");

    if (arVisible == NO)

        [qUtils resumeAR];

    

    arVisible = YES;    

}

 

- (void)viewDidDisappear:(BOOL)animated

{

    NSLog(@"ARVC: viewDidDisappear");

    if (arVisible == YES)

        [qUtils pauseAR];

    

    // Be a good OpenGL ES citizen: ensure all commands have finished executing

    [arView finishOpenGLESCommands];

    

    arVisible = NO;

}

 
HTH

N

How to stop AR when moving to other controller

January 15, 2014 - 5:49am #6

Sorry... ignore my last. The Books example doesn't ever leave the BooksViewController.

How to stop AR when moving to other controller

January 15, 2014 - 5:47am #5

Cool. Makes sense. I'm trying to find where you guys do that with the Books example (or at least the equivalent), but no luck so far. Any advice?

How to stop AR when moving to other controller

January 15, 2014 - 5:37am #4

In my experience this has proved to be the best strategy, rather than initialising and deinitialising Vuforia which some developers have experienced problems with.

This way it only initialises once, which means that subsequent invocations (using Pause/Resume) are much quicker and can lead to a better user experience.  

HTH

N

How to stop AR when moving to other controller

January 15, 2014 - 5:29am #3

NalinS wrote:
You need to call [qUtils pauseAR] and [qUtils resumeAR] as a way of pausing/resuming the AR while in other ViewControllers

 

Nalin,

Not to hijack this thread, but does your statement imply that we should be calling [qUtils pauseAR] whenever we dismiss the view controller that presents the EAGL view?

How to stop AR when moving to other controller

January 15, 2014 - 5:03am #2
1.I cant stop the AR in background even though i changed the controller
 
You need to call [qUtils pauseAR] and [qUtils resumeAR] as a way of pausing/resuming the AR while in other ViewControllers
 
2. I a m not getting the view hierarchy .
 
I am not sure what you mean?
 
 
N
 
Log in or register to post comments