Trying to hack FCP's Spinback3D plug-in, need FXBuilder help at DVinfo.net

Go Back   DV Info Net > Apple / Mac Post Production Solutions > Final Cut Suite

Final Cut Suite
Discussing the editing of all formats with FCS, FCP, FCE


Reply
 
Thread Tools Search this Thread
Old March 12th, 2008, 11:27 AM   #1
Major Player
 
Join Date: May 2006
Location: Toronto ON Canada
Posts: 731
Trying to hack FCP's Spinback3D plug-in, need FXBuilder help

I come from a PHP programming background, so code is not a new concept, though I have yet to delve into FXBuilder...

FCP's Spinback3D is a 3D Simulation transition effect that rotates your outgoing clip ~90 (looks more like ~85), swaps it for the incoming clip, and reverses the rotation... it isn't a 180 flip, which is what I want.

Sure, I can achieve this with motion keyframes, but I want to do this for several clips and the plugin just makes sense (why the built in plugin doesn't have this as an option, i do not know)

It appears to me that the section of code that governs the rotation is:

Code:
rotate3D(target3d, center3d, 0, 0, -angleofaxis);

if ratio < 0.5
	rotate3D(target3d, center3d, 0, 180*ratio, 0);
else
	rotate3D(target3d, center3d, 0, 180*(1-ratio), 0);
end if;

rotate3D(target3d, center3d, 0, 0, angleofaxis);
Nowhere in the script do I see the ratio variable being defined, so I have no clue from where its value comes!

It should be a simple task, to hack the plugin (or a copy of the plugin... I called it Flip 180) to simply do what it does, but in a full 180 turn. Anyone have any ideas?
__________________
Mike Barber
"I'm laughing to stop myself from screaming."
Mike Barber is offline   Reply With Quote
Old March 12th, 2008, 11:29 AM   #2
Major Player
 
Join Date: May 2006
Location: Toronto ON Canada
Posts: 731
Full code

Here is the full FXBuilder code for the Spinback3D plug-in:

Code:
scriptid "Spinback3D" //DO NOT LOCALIZE
transition "Spinback3D";
group "3D Simulation";
wipeCode(20, 100);
producesAlpha;


input angleofaxis, "Angle of Axis", angle, 0, -360, 360 detent 0;
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;

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 = 30;

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, 180*ratio, 0);
else
	rotate3D(target3d, center3d, 0, 180*(1-ratio), 0);
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;
__________________
Mike Barber
"I'm laughing to stop myself from screaming."
Mike Barber is offline   Reply With Quote
Old March 12th, 2008, 12:19 PM   #3
Major Player
 
Join Date: Mar 2006
Location: Kuala Lumpur, Malaysia
Posts: 645
"ratio" in FxScript pertains to how far through the effect you have progressed (0 at the start to 1 at the end)

what the script is doing then is a simple "if then" conditional switch
if less than half way through the effect then rotate the outgoing clip 180 degrees times the ratio ( so the maximum rotation at ratio of 0.5 will be 90 degrees )
otherwise do the reverse with the incoming clip


so, you need to change that code to:

rotate3D(target3d, center3d, 0, 0, -angleofaxis);

if ratio < 0.5
rotate3D(target3d, center3d, 0, 360*ratio, 0);
else
rotate3D(target3d, center3d, 0, 360*(1-ratio), 0);
end if;

rotate3D(target3d, center3d, 0, 0, angleofaxis);


that'll do what you want (but you may not like the result as the 180 degrees to the angle of view just means you're looking at a flipped image when it cuts ... might want to try changing it to 540 degrees for something more dynamic)
Andy Mees is offline   Reply With Quote
Old March 12th, 2008, 03:34 PM   #4
Major Player
 
Join Date: May 2006
Location: Toronto ON Canada
Posts: 731
Quote:
Originally Posted by Andy Mees View Post
so, you need to change that code to:

rotate3D(target3d, center3d, 0, 0, -angleofaxis);

if ratio < 0.5
rotate3D(target3d, center3d, 0, 360*ratio, 0);
else
rotate3D(target3d, center3d, 0, 360*(1-ratio), 0);
end if;

rotate3D(target3d, center3d, 0, 0, angleofaxis);


that'll do what you want (but you may not like the result as the 180 degrees to the angle of view just means you're looking at a flipped image when it cuts ... might want to try changing it to 540 degrees for something more dynamic)
I may have not described my intended effect well enough, but your suggestion was very helpful in tracking down what change I needed to do. What I actually needed to change the code to was this:

Code:
if ratio < 0.5
	rotate3D(target3d, center3d, 0, 180*ratio, 0);
else
	rotate3D(target3d, center3d, 0, 180*(1+ratio), 0);
end if;
The change is in the else clause, from 180*(1-ratio) to 180*(1+ratio).

So, for those interested in a simple 3D flip transition, here is the code:

Code:
scriptid "Flipper" //DO NOT LOCALIZE
transition "Flipper"; // A remix of Spinback3D by Mike Barber
group "3D Simulation";
wipeCode(20, 100);
producesAlpha;


input angleofaxis, "Angle of Axis", angle, 0, -360, 360 detent 0;
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;

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 = 30;

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, 180*ratio, 0);
else
	rotate3D(target3d, center3d, 0, 180*(1+ratio), 0);
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;
__________________
Mike Barber
"I'm laughing to stop myself from screaming."
Mike Barber is offline   Reply With Quote
Old March 12th, 2008, 09:16 PM   #5
Major Player
 
Join Date: Mar 2006
Location: Kuala Lumpur, Malaysia
Posts: 645
cool.

lets add a couple of extra controls in there:

input spinfactor, "Spin Factor", slider, 1, 1, 10 snap 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
input doflip, "Flip", checkbox, 1

then change the code snippet to:

if ratio < 0.5
rotate3D(target3d, center3d, 0, spinfactor*180*ratio, 0);
else
if doflip
rotate3D(target3d, center3d, 0, spinfactor*180*(1+ratio), 0);
else
rotate3D(target3d, center3d, 0, spinfactor*180*(1-ratio), 0);
end if
end if;

Last edited by Andy Mees; March 12th, 2008 at 10:40 PM.
Andy Mees is offline   Reply With Quote
Old March 13th, 2008, 04:51 AM   #6
Major Player
 
Join Date: May 2006
Location: Toronto ON Canada
Posts: 731
Quote:
Originally Posted by Andy Mees View Post
lets add a couple of extra controls in there
Interesting...

Do you know of any good websites or books for learning FXBuilder? I would really like to dive into this stuff (not that I have any free time, but I am interested).

I'm thinking of trying to hack the Page Peel to see if I can replicate the CC Twister plugin from AfterEffects... that appears to be a much bigger task than a simple flip!
__________________
Mike Barber
"I'm laughing to stop myself from screaming."
Mike Barber is offline   Reply With Quote
Old March 13th, 2008, 09:08 AM   #7
Major Player
 
Join Date: Mar 2006
Location: Kuala Lumpur, Malaysia
Posts: 645
hands down best place to get your feet wet is by absorbing all you can over on Joe Mallers website ...
http://joemaller.com/fcp/fxscript_basics.shtml

... read all the tutorials, download all the example, explorer and debug scripts, check out all the links from his site. its easily the best resource

also check out his FxScript Reference site
http://www.fxscriptreference.org/

Open up all of Apple's scripts and have at them. Tweak the code and see how it affects the runtime ... a great way to figure out how it all works.

Matt Sandstrom's Too Much Too Soon plugs are excellent and he offers them free and unlocked so that you can see his code and so see how others might code similar effects yet using different function calls
http://www.mattias.nu/plugins/

last but certainly not least, grab the Using FxScript document off Apple's Developer website
http://developer.apple.com/documenta...ngFXScript.pdf
Andy Mees is offline   Reply
Reply

DV Info Net refers all where-to-buy and where-to-rent questions exclusively to these trusted full line dealers and rental houses...

Professional Video
(800) 833-4801
Portland, OR

B&H Photo Video
(866) 521-7381
New York, NY

Z.G.C.
(973) 335-4460
Mountain Lakes, NJ

Abel Cine Tech
(888) 700-4416
N.Y. NY & L.A. CA

Precision Camera
(800) 677-1023
Austin, TX

DV Info Net also encourages you to support local businesses and buy from an authorized dealer in your neighborhood.
  You are here: DV Info Net > Apple / Mac Post Production Solutions > Final Cut Suite

Thread Tools Search this Thread
Search this Thread:

Advanced Search

 



Google
 

All times are GMT -6. The time now is 05:31 AM.


DV Info Net -- Real Names, Real People, Real Info!
1998-2017 The Digital Video Information Network