• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Animation perspective question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Animation perspective question


  • Subject: Core Animation perspective question
  • From: chaitanya pandit <email@hidden>
  • Date: Fri, 7 Nov 2008 15:44:35 +0530

Hi List,
iWas going through the Flipr sample app (http://www.brockerhoff.net/src/index.html ) and am trying to understand how to compute the perspective.
I could implement the flipping around the Y-Axis in one of my views, but i can't figure out how do i compute the perspective if i would have to rotate the view both 45 degree counter clockwise around the Y- Axis as well as 45 degrees counter clockwise around the X-Axis?


Following is the code used to compute the perspective for rotation about the Y Axis, i need to tweak it for rotation along the x axis simultaneously

// First we calculate the perspective.
float radius = originalRect.size.width/2;
float width = radius;
float height = originalRect.size.height/2;
float dist = 1600; // visual distance to flipping window, 1600 looks about right. You could try radius*5, too.
float angle = direction*M_PI*time;
float px1 = radius*cos(angle);
float pz = radius*sin(angle);
float pz1 = dist+pz;
float px2 = -px1;
float pz2 = dist-pz;
if (time>0.5) {
// At this point, we need to swap in the final image, for the second half of the animation.
if (finalImage) {
[transitionFilter setValue:finalImage forKey:@"inputImage"];
[finalImage release];
finalImage = nil;
}
float ss;
ss = px1; px1 = px2; px2 = ss;
ss = pz1; pz1 = pz2; pz2 = ss;
}
float sx1 = dist*px1/pz1;
float sy1 = dist*height/pz1;
float sx2 = dist*px2/pz2;
float sy2 = dist*height/pz2;
// Everything is set up, we pass the perspective to the CoreImage filter
[transitionFilter setValue:[CIVector vectorWithX:width+sx1 Y:height +sy1] forKey:@"inputTopRight"];
[transitionFilter setValue:[CIVector vectorWithX:width+sx2 Y:height +sy2] forKey:@"inputTopLeft" ];
[transitionFilter setValue:[CIVector vectorWithX:width+sx1 Y:height- sy1] forKey:@"inputBottomRight"];
[transitionFilter setValue:[CIVector vectorWithX:width+sx2 Y:height- sy2] forKey:@"inputBottomLeft"];
CIImage* outputCIImage = [transitionFilter valueForKey:@"outputImage"];


I'd appreciate any help.
Thanks,
Chaitanya
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Prev by Date: Link error: _open$UNIX2003
  • Next by Date: UI help: visibly disabling NSImageView
  • Previous by thread: RE: Link error: _open$UNIX2003
  • Next by thread: UI help: visibly disabling NSImageView
  • Index(es):
    • Date
    • Thread