Front and back flip animation
-
I would like to implement a switch between two views, each with their
own set of controls etc., so the switch animates like when you click
on the small "i" on a widget, i.e. the concept of a front and a back.
The animation should flip the views around a vertical axis in the
middle of their frame. I've looked at the ViewFlip and GeekGameBoard
examples (and many others) and kinda have things working, but it is
not quite what I want. I would like to solicit opinions on what the
best strategy is. The ViewFlip uses CATransform3DMakeRotation, but
that isn't ideal as described in the GeekGameBoard example. The
GeekGameBoard uses CALayer and not NSViews, so I'm unsure how to
change the example to what I need.
One approach I've considered is to add an animation to the parent view
("subviews" property) so it moves and resizes the view. Let's say that
the views are 200x400 and with frameOrigin at 0,0. Would it then make
sense to have the front animate from ((0,0),(200,400)) to ((100,0),
(0,400)) and the reverse for the back (assuming doubleSided is NO)?
Is there a much better and obvious way, once you've seen the
light :o), to achieve the front/back flip animation?
Kind Regards,
Geert B. Clemmensen -
On 15 Feb '08, at 1:52 AM, Geert B. Clemmensen wrote:> The ViewFlip uses CATransform3DMakeRotation, but that isn't ideal as
> described in the GeekGameBoard example.
From what I now know, I think it's OK to use that function, as long
as you only use it to generate the _intermediate_ transformations
during the rotation. The bugs it introduced into GeekGameBoard were
apparently due to roundoff errors: if you call it with a rotation of Ãâ¬
[180ð] it doesn't give you an exact flip-about-y-axis matrix, but has
some tiny nonzero values left over in other cells. And that leads CA
to decide your layer/view still has a 3D transform, which affects the
way it does clipping, causing the glitches that I ran into in GGB.
So it should be OK to use CATransform3DMakeRotation to generate the
transformations during the flip, but at the end of the flip you should
construct your own matrix and use that.
ââ¬âJens -
Geert,
This may help you some, I just came across this today:
http://www.brockerhoff.net/src/index.html
Rainer has a Flipr project which performs the same operation on a
window, maybe you could adapt it to your views. I'm not familiar with
the source at all, but if you haven't seen this thought you might
appreciate it.
Best regards,
Steven Huey
On Feb 15, 2008, at 4:52 AM, Geert B. Clemmensen wrote:> I would like to implement a switch between two views, each with
> their own set of controls etc., so the switch animates like when you
> click on the small "i" on a widget, i.e. the concept of a front and
> a back. The animation should flip the views around a vertical axis
> in the middle of their frame. I've looked at the ViewFlip and
> GeekGameBoard examples (and many others) and kinda have things
> working, but it is not quite what I want. I would like to solicit
> opinions on what the best strategy is. The ViewFlip uses
> CATransform3DMakeRotation, but that isn't ideal as described in the
> GeekGameBoard example. The GeekGameBoard uses CALayer and not
> NSViews, so I'm unsure how to change the example to what I need.
>
> One approach I've considered is to add an animation to the parent
> view ("subviews" property) so it moves and resizes the view. Let's
> say that the views are 200x400 and with frameOrigin at 0,0. Would it
> then make sense to have the front animate from ((0,0),(200,400)) to
> ((100,0),(0,400)) and the reverse for the back (assuming doubleSided
> is NO)?
>
> Is there a much better and obvious way, once you've seen the
> light :o), to achieve the front/back flip animation?
>
> Kind Regards,
> Geert B. Clemmensen -
Hello,
I finally got this to work the way I wanted to. The main trick is that
for a layer associated with a view (setWantsLayer:YES) the anchorPoint
is (0, 0). Apple's CALayer documentation states that the anchorPoint
(0.5, 0.5), but alas, this isn't the truth in all cases.
The final pieces of the puzzle came around when I earlier today
stumbled on MFFlipController done my Mike Lee (http://boondoggle.atomicwang.org/lemurflip
). It took me a few minutes assembling the X-code project, but after
that it was smooth sailing. I would say that, for my specific purpose,
Mike's example is by a good margin better that anything I've found on
Apple's site. Thx. Mike.
Kind Regards,
Geert B. Clemmensen
Begin forwarded message:> From: "Geert B. Clemmensen" <gclem...>
> Date: 15. februar 2008 10.52.25 GMT+01:00
> To: Cocoa Developers <cocoa-dev...>
> Subject: Front and back flip animation
>
> I would like to implement a switch between two views, each with
> their own set of controls etc., so the switch animates like when you
> click on the small "i" on a widget, i.e. the concept of a front and
> a back. The animation should flip the views around a vertical axis
> in the middle of their frame. I've looked at the ViewFlip and
> GeekGameBoard examples (and many others) and kinda have things
> working, but it is not quite what I want. I would like to solicit
> opinions on what the best strategy is. The ViewFlip uses
> CATransform3DMakeRotation, but that isn't ideal as described in the
> GeekGameBoard example. The GeekGameBoard uses CALayer and not
> NSViews, so I'm unsure how to change the example to what I need.
>
> One approach I've considered is to add an animation to the parent
> view ("subviews" property) so it moves and resizes the view. Let's
> say that the views are 200x400 and with frameOrigin at 0,0. Would it
> then make sense to have the front animate from ((0,0),(200,400)) to
> ((100,0),(0,400)) and the reverse for the back (assuming doubleSided
> is NO)?
>
> Is there a much better and obvious way, once you've seen the
> light :o), to achieve the front/back flip animation?
>
> Kind Regards,
> Geert B. Clemmensen
>


