Log in or register to post comments

Best way to handle pausing QCAR when dismissing a view controller?

January 15, 2014 - 5:54am #1

In another thread Nalin suggest to call [qUtils pauseAR] when dismissing/popping the view controller that presents the EAGL view.

I was looking through the VuforiaSamples project to see where this is done (just for an example), but cannot find it anywhere.

I mean, I know where to put it in my code, but just want to see some examples of where this is done since it is probably best practice.

Any suggestions?

Best way to handle pausing QCAR when dismissing a view controlle

January 16, 2014 - 7:24am #4

Here is a snippet from an App thats in the Apple App store.  The App recognizes the cloud based image and then pauses AR from EAGLView and then starts another viewcontroller.  I have a server DB key (IDGKey in snippet) stored as the Cloud image name field.  This snippet is from my EAGLView:

 

if (state.getNumTrackableResults() > 0)

    {

        // Get the trackable:

        trackableResult = state.getTrackableResult(0);

        modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackableResult->getPose());

        

        // The target:

        const QCAR::Trackable& trackable = trackableResult->getTrackable();

        assert(trackable.getType() == QCAR::Trackable::IMAGE_TARGET);

        

        // Get the size of the ImageTarget

        QCAR::ImageTargetResult *imageResult = (QCAR::ImageTargetResult *)trackableResult// <<<<<

        QCAR::Vec2F targetSize = imageResult->getTrackable().getSize();

        trackableSize.data[0] = targetSize.data[0];

        trackableSize.data[1] = targetSize.data[1];

        

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {

            trackableSize.data[0] *= 1.25f;

            trackableSize.data[1] *= 1.25f;

        }

        

        QCAR::ImageTarget* imageTargetTrackable = (QCAR::ImageTarget*)&trackable;

        NSString *uniqueTargetId = [NSString stringWithUTF8String:imageTargetTrackable->getUniqueTargetId()];

      

        NSString *imageName = [NSString stringWithUTF8String:imageResult->getTrackable().getName()];

 

      glDisable(GL_BLEND);

      glDisable(GL_DEPTH_TEST);

      

      glDisableVertexAttribArray(vertexHandle);

      glDisableVertexAttribArray(normalHandle);

      glDisableVertexAttribArray(textureCoordHandle);

      

      QCAR::Renderer::getInstance().end();

 

      [self presentFramebuffer];

      [framebufferLock unlock];

      

 //     NSLog(@"image Target ID: %@ \nTarget Name: %@", uniqueTargetId, imageName);

      

      NSString *IDGKey = imageName;

      

      [CRQCARutils getInstance].lastTargetIDScanned = uniqueTargetId;

      

      [qUtils pauseAR];

 

      MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];

      [[appDelegate arParentViewController] startSB0:IDGKey];

    }

Best way to handle pausing QCAR when dismissing a view controlle

January 15, 2014 - 7:11am #3

yes - should be.

N

Best way to handle pausing QCAR when dismissing a view controlle

January 15, 2014 - 5:58am #2

OK, I think I found the equivalent. In the SampleApplicationSession class there is a function called stopAR:error that gets called when a view controller's viewWillDisappear:animated function is called.

Do I have that correct?

Log in or register to post comments