Log in or register to post comments

Hiding Augmented Layer

May 29, 2013 - 3:10pm #1


I am using the CloudReco sample app, and I want to be able to control the visibilty of the augmented layer.

What I understand so far is that:

  1. The layer is initially created in CROverlayViewController -> targetfound, where adds a subview to arview
  2. Then in EAGLView it converts the layer into a UIImage and renders it on the target.

I would really appreciate it if someone can point me in the right direction as to how I can set the rendered image to either visible or hidden.


Hiding Augmented Layer

June 5, 2013 - 1:57am #9

In this case are you able to control the blending via OpenGL ES right before the image is rendered in RenderFrameQCAR?



Hiding Augmented Layer

June 4, 2013 - 1:13pm #8

Thanks for the suggestion NalinS, however if I understand you correctly then this solution would not work.

The CALayer is rendered into an image and then the image is what is displayed on the trackble, therefore settiing the CALayer to opacity 0 will not have an effect on what is displayed in AR.

Please correct me if I am wrong or if I did not understand you solution fully :)

Hiding Augmented Layer

June 4, 2013 - 8:07am #7

opacity is a member of CALayer.

From XCode docs:


The value of this property must be in the range 0.0 (transparent) to 1.0 (opaque). Values outside that range are clamped to the minimum or maximum. The default value of this property is 1.0.

Just thought it might be worth a try.



Hiding Augmented Layer

June 3, 2013 - 1:03pm #6

No I have not tried this because I don't know how you. Would you mind posting some example code as how I can change the opacity of the layer?

Hiding Augmented Layer

June 3, 2013 - 3:25am #5

Presumably you have tried setting the opacity of the layers?


Hiding Augmented Layer

June 1, 2013 - 5:30am #4

The render state doesnt help me achieve what I am trying to do.

I have two "rendered layers" and I am trying to swap between them.

In CROverlayViewController I create the two layers like this:

- (void)targetFound:(NSNotification *)notification
    dispatch_async(dispatch_get_main_queue(), ^{
        self.targetOverlayView = [[[NSBundle mainBundle] loadNibNamed:@"targetOverlayView" owner:nil options:nil] objectAtIndex:0];
        self.targetOverlayView2 = [[[NSBundle mainBundle] loadNibNamed:@"targetOverlayView" owner:nil options:nil] objectAtIndex:0];
        Book *aBook = [notification object];
        [self.targetOverlayView setBook:aBook];
        [self.targetOverlayView2 setBook:aBook];
        [CRQCARutils getInstance].lastScannedBook = aBook;
        [self.arViewController setOverlayLayer:self.targetOverlayView.layer];
        CALayer *sublayer = [CALayer layer];
        sublayer.backgroundColor = [UIColor blueColor].CGColor;
        sublayer.shadowOffset = CGSizeMake(0, 3);
        sublayer.shadowRadius = 5.0;
        sublayer.shadowColor = [UIColor blackColor].CGColor;
        sublayer.shadowOpacity = 0.8;
        sublayer.frame = CGRectMake(100, 30, 100, 100);
        [self.targetOverlayView2.layer addSublayer:sublayer];
        [self.arViewController setOverlayLayer:self.targetOverlayView2.layer];
        [self.view addSubview:self.targetOverlayView];
        [self.view addSubview:self.targetOverlayView2];
        [self.targetOverlayView setHidden:YES];
        [self.targetOverlayView2 setHidden:YES];
        [self centerViewInFrame];
        loadingView.hidden = YES;
        //  Show close button
        closeButton.hidden = NO;

When I run the code it renders both the layers. I am looking for a way to hide one of the layers, and then when an action occurs I want to hide the visible layer and display the hidden layer.

Any ideas?

Hiding Augmented Layer

May 31, 2013 - 7:08am #3

Thanks for the reply! I will look into it.

Hiding Augmented Layer

May 31, 2013 - 1:46am #2

In EAGLView.mm when it shows the overlay layer for the first time it sets the following state variable:




It might be worth hunting around for this and seeing how it is used as it seems you want to extend the number of states, or possibly add an additional one.  The way it is currently used is a little bit more complex because it handles the cases where it transitions to a 2D overlay back and forth depending on whether the target is acquired and whether the user switches the overlay off.






Log in or register to post comments