3

Attempt A

this code

CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = -1.0 / 1000.0;
perspectiveTransform = CATransform3DRotate(perspectiveTransform, angle / 2.0, 0.0, 1.0, 0.0);
self.sublayerTransform = perspectiveTransform;

gives this result

A

The red frame is the background color of the layer

Attempt B

This code

CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = -1.0 / 1000.0;
// following line is added 
perspectiveTransform = CATransform3DTranslate(perspectiveTransform, -width / 2.0, 0, 0);
perspectiveTransform = CATransform3DRotate(perspectiveTransform, angle / 2.0, 0.0, 1.0, 0.0);
self.sublayerTransform = perspectiveTransform;

gives this result

B

The red frame is the background color of the layer

So what is wrong?

In the rendered example from "Attempt A" is seen from left center and therefore the fold is seen from the wrong angle (left fold gets slightly thinner than right fold)

By translating it on the x-axis, as in "Attempt B", I am able to get it rendered correctly, but then occurs another mistake: the content is now out of bounds (red rectangle is bounds).

How can I make the camera be from the middle?

Community
  • 1
  • 1
hfossli
  • 22,616
  • 10
  • 116
  • 130

1 Answers1

-1

Well, it seems like changing the anchorpoint is the easiest. I just need to change some other transforms (not revealed in post) to make it work.

hfossli
  • 22,616
  • 10
  • 116
  • 130
  • LoL If you post the other changes it will be helpful to others who ran into the same problem :) – The iOSDev Dec 19 '12 at 09:34
  • Good idea. I did not reveal to much of the code so I thought it was not so important. But basically I just had to translate the other views accordingly (not via sublayerTransform) – hfossli Dec 19 '12 at 13:34
  • 1
    Thanks for providing some detail about the solution may this will help some one and also increase your reputation too :) – The iOSDev Dec 20 '12 at 05:13