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 (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 [EMAIL PROTECTED]

Reply via email to