OK, turns out that the zPosition property of the layers is important here. I 
was setting them to values like 100, and -100. That turns out to be way too 
small - the perspective/rotation transform I was applying to the 'behind' 
layers was swinging these layers into a zPosition that greatly exceeds these 
numbers. Changing to values like 1000 fixes the issue. It's a bit hard to get a 
feel for what these numbers mean - it must hugely depend on what sort of  
"camera field of view" (or whatever the right terminology is - focal length?) 
for the Core Animation 3D system.

Anyway, what I've learned is that the z values need to be big, and probably not 
terribly precise.


--Graham





On 26/07/2011, at 11:31 AM, Graham Cox wrote:

> Hi David,
> 
> 
> This sounds somewhat close to what I have already. My layer hierarchy is:
> 
> 
>                Root
>                     |
>    -------------------------
>    |                |               |
> Rep1        Rep2       Rep3
>    |                |               |
> --------     --------           |
> |         |     |         |          |
> L1   L2   R1    R2     Text
> 
> 
> Where L1, L2, R1 and R2 are custom CALayer subclasses that draw the coloured 
> bars, and Rep 1..3 are the replicator layers that provide the reflective 
> effect. (Sidenote: I'm pretty sure it's not possible to create the reflection 
> effect I want using a single rep layer, as each one is set to a different 
> perspective transform).
> 
> The 3 replicator layers are siblings, where Rep3 which hosts the text is 
> added last and should therefore draw last, i.e. on top. (I've tested this 
> assumption by trying to move it elsewhere in the sublayers list using 
> -insertSublayer:atIndex: but this doesn't appear to change anything.
> 
> I also found that the text is not just being overwritten by the replicator 
> layer's drawing - if I set its position to overlap the actual content (L1, 
> R1, etc) it is also drawn over by the main content, so it does seem to simply 
>  be in the wrong place in the drawing order.
> 
> One strange thing was that for a while, it started to work correctly, without 
> me doing anything, then some cycles of dev and debugging later elsewhere in 
> the code, reverted to this behaviour. The code I was working on was nothing 
> to do with the graphical layers at all. This suggests that maybe there's 
> something a bit random going on in establishing which layer gets to draw when.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to