small medium large xlarge

Generic-user-small
11 Aug 2009, 11:50
Christoph Ludwig (13 posts)

Hi,

I have a layer tree, part of which looks as follows:

+ CALayer ("slot")
  + CALayer ("envelope")
    + CALayer ("event")
      + CALayer ("event image")
    + CALayer ("group icon")
    + [UILabel layer] ("group count")

The zPosition of the event, icon, and label layers is 0.0.

The group icon is supposed to appear (visually) in the top right corner of the event image and serves as background for the label. That worked as expected so far, I could even animate the event layer and the icon stayed where it should.

Now I added an additional animation to the event layer. As far as I can tell the code changes affect the event layer and the event image layer only. However, suddenly the icon and the label are gone, even before the animation runs. :-(

More precisely, it seems they are shrouded by the event layer: If I set @event.hidden = YES@ then I can verify that the icon and the label are still where they are supposed to be. I suspected that I screwed up the sublayer order but a dump of the layer tree to the console showed the sublayer order unchanged. I also tried to assign the layers different zPositions, to no avail.

Has anyone a tip how I can further debug this issue? I ran out of ideas.

Thanks!

Christoph

Generic-user-small
12 Aug 2009, 16:43
Christoph Ludwig (13 posts)

Hi,

some distance and a decent diff-viewer (emacs’s ediff in my case) finally did the trick. For the animation I had assigned the event layers’s @anchorPointZ@ a negative value. I was under the impression that @anchorPointZ@ is only relevant to define the origin of the map defined by transformation, but it apparently also affects the “effective” zPosition of the layer.

Which brings me to a follow-up question: With exception of CATransformLayer, all CA layer classes on the iPhone use a “flattened hierarchy rendering model”. What exactly are the formulas that describes the projection of a point in a sublayer onto the plane of its superlayer?

Let L1 be a layer and @t:(x, y, z) –> (x’, y’, z’)@ be the map described by L1’s projective transformation matrix @transform@. Am I correct that the change phi of coordinate system C1 of L1 and coordinate system C2 of its superlayer L2 is given by

  phi: (x1, y1, z1) --> (x2, y2, z2) = (ox, oy, oz) + t(x1, y1, z1)
where 
    ox = position.x - (bounds.origin.x + anchorPoint.x * bounds.size.width)
    oy = position.y - (bounds.origin.y + anchorPoint.y * bounds.size.height)
    oz = zPosition - anchorPointZ

?

Now where does @sublayerTransform@ enter the picture? (More to the point: When is it applied to the picture? :-) )

Cheers!

Christoph

Biopic_100x100_pragsmall
12 Aug 2009, 17:32
Bill Dudney (917 posts)

Hi Christoph,

Although its not clearly documented from what I’ve been able to gather from experimentation is that the default projection of layers into their superlayer is orthographic. If you apply a sublayerTransform it becomes a perspective projection.

Good luck!

You must be logged in to comment