Andy’s Flipper 2
Andy’s Flipper 2
Thursday, March 13, 2008
Mike Barber, over on dvinfo was wrestling with a bit of code he needed to hack into Apple’s Spinback 3D transition. I totally misunderstood the effect he was trying for but as it turned out, I did at least help him in the right direction.
Mike posted his modded “Flipper” script and I’ve added in some extra controls to make it more flexible.
scriptid "Andy’s Flipper" //DO NOT LOCALIZE
transition "Andy’s Flipper"; // A remixed remix of Spinback3D
group "3D Simulation";
wipeCode(20, 100);
producesAlpha;
input angleofaxis, "Angle of Axis", angle, 0, -360, 360 detent 0;
input spinfactor, "Spin Factor", slider, 1, 1, 10 snap 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
input perspective, "Perspective", slider, 0.3, 0.01, 1.000 detent 0.3;
input borderWidth, "Border", slider, 0, 0, 10 snap 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
input borderColor, "Color", color, 255, 0, 0, 0;
input dontflip, "Spinback", checkbox, 0;
code
on fabs (value _n)
return (_n<0 ? -_n : _n);
end;
float w, h, hprime, alpha, offsetangle, angleofview, xprime, yprime;
point source[4], target[4], poly[4], centerofview;
point3d target3d[4], center3d, eye3d;
dimensionsof(dest, w, h);
borderColor.a = 255;
angleofview = perspective*100;
boundsOf(Dest, target);
centerOf(target, centerofview);
source = target;
poly = target;
hprime = h * aspectof(dest);
xprime = w*fabs(cos(angleofaxis)) + hprime*fabs(sin(angleofaxis));
yprime = w*fabs(sin(angleofaxis)) + hprime*fabs(cos(angleofaxis));
scale(poly, centerofview, xprime/w, yprime/h);
rotate(poly, centerofview, angleofaxis, aspectof(dest));
convert2dto3d(centerofview, center3d, 0);
convert2dto3d(centerofview, eye3d, w/(2*tan(angleofview/2)));
scale(target, centerofview, 1, aspectof(dest));
convert2DTo3D(target, target3d, 0);
rotate3D(target3d, center3d, 0, 0, -angleofaxis);
if ratio < 0.5
rotate3D(target3d, center3d, 0, spinfactor*180*ratio, 0);
else
if dontflip
rotate3D(target3d, center3d, 0, spinfactor*180*(1-ratio), 0);
else
rotate3D(target3d, center3d, 0, spinfactor*180*(1+ratio), 0);
end if;
end if;
rotate3D(target3d, center3d, 0, 0, angleofaxis);
convert3DTo2D(target3d, target, eye3d);
scale(target, centerofview, 1, 1/aspectof(dest));
if srctype1 == knone
exposedbackground=1;
end if
if srctype2 == knone
exposedbackground=1
end if;
channelfill(dest, 0, 0, 0, 0);
if ratio < 0.5
blitrect(Src1, source, Dest, target);
else
blitrect(src2, source, dest, target);
end if;
if borderwidth > 0
framepoly(target, dest, bordercolor, borderwidth/renderRes);
end if;
UPDATED 26/08/09:
Added a few more controls like perspective, distance offset (like an interim scale control), plus my own Easy Ease controls.
_