LScript (Layout) used to bake motion in many of my dynamic scripts such as used in Slider and Wheel & Axle.
Changes
- Added "redraw" to preview calculations in realtime
- Added Lock / Unlock
- Added Bake Keys
Compatible with Newtek LightWave 9.6 and above.
// LScript Master - www.StephenCulley.co.uk // // web address: http://www.stephenculley.co.uk // email address: email@stephenculley.co.uk /* LScript Master - Motion Baker Master_MotionBaker.ls */ @version 2.2 @warnings @script master @name *Motion Baker // Title sTitle = "*Motion Baker"; // Version sVersion = "v1.0"; bRedraw = false; // Redraw iParent = 0; // Parent create { setdesc(sTitle); // Comring comringattach("*MotionBaker","comring_motionbaker"); } destroy { // Comring comringdetach("*MotionBaker"); } flags { return(SCENE); } // COMRING comring_motionbaker:event,data { sMessage = comringdecode(@"s:200"@,data); if(strlower(sMessage) == "*parent") // Parent { if(iParent < event) iParent = event; } } process: event, command { } load: what,io { if(what == SCENEMODE) // processing an ASCII scene file { bRedraw = io.read().asInt(); // Redraw } } save: what,io { if(what == SCENEMODE) { io.writeln(bRedraw); // Redraw } } options { if(reqisopen()) { reqend(); return; } reqbegin(sTitle + " " + sVersion); reqsize(276,148); ctrl_0 = ctlbutton("Calculate",50,"button_calculate"); // Button Calculate ctrl_1 = ctlcheckbox("Redraw",bRedraw); // Redraw ctrl_2 = ctlbutton("Disable",50,"button_disable"); // Button Disable ctrl_3 = ctlbutton("Reset",50,"button_reset"); // Button Reset ctrl_4 = ctlbutton("Write",50,"button_write"); // Button Write ctrl_5 = ctlbutton("Read",50,"button_read"); // Button Read ctrl_6 = ctlsep(); ctrl_7 = ctlbutton("Bake Keys",50,"button_bake"); // Button Bake ctrl_8 = ctlbutton("Lock All",50,"button_lock"); // Button Lock ctrl_9 = ctlbutton("Unlock All",50,"button_unlock"); // Button Unlock // Developer ctrl_dev0 = ctlsep(); ctrl_dev1 = ctltext("","developer: Stephen Culley","http://www.stephenculley.co.uk"); ctlposition(ctrl_0,10,10,90,20); ctlposition(ctrl_1,10,32,90,20); ctlposition(ctrl_2,114,10,75,20); ctlposition(ctrl_3,191,10,75,20); ctlposition(ctrl_4,114,32,75,20); ctlposition(ctrl_5,191,32,75,20); ctlposition(ctrl_6,0,60,276,4); ctlposition(ctrl_7,10,70,90,20); ctlposition(ctrl_8,114,70,75,20); ctlposition(ctrl_9,191,70,75,20); ctlposition(ctrl_dev0,0,98,276,4); ctlposition(ctrl_dev1,10,108,256,20); // Refresh ctlrefresh(ctrl_1,"refresh_c1"); // Redraw reqopen(); } button_calculate // Calculate { Scene = Scene(); iFrame = (Scene.fps * Scene.currenttime).asInt(); // Current frame // Parent iParent = 0; // Parent sMessage = "parent"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); GoToFrame(Scene.previewstart); if(iParent <= 0) { GoToFrame(iFrame); // Restore current frame return; // Exit if none available } // Reset sMessage = "reset"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); GoToFrame(Scene.previewstart); // Read sMessage = "read"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); for(f = Scene.previewstart;f <= Scene.previewend; f++) { for(p = 1; p <= iParent; p++) { // Write sMessage = "write"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",p,cMessage); GoToFrame(f); // Read sMessage = "read"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",p,cMessage); } if(bRedraw) RedrawNow(); // Redraw } GoToFrame(iFrame); // Restore current frame info("*Motion Baker calculated"); } button_read // Read { sMessage = "read"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker set to read"); } button_reset // Reset { sMessage = "reset"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker reset"); } button_write // Write { sMessage = "write"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker set to write"); } button_disable // Disable { sMessage = "disable"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker disabled"); } button_bake // Bake { sMessage = "bake"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker keys baked to channels"); } button_lock // Lock { sMessage = "lock"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker set to locked"); } button_unlock // Unlock { sMessage = "unlock"; cMessage = comringencode(@"s:200"@,sMessage); comringmsg("*MotionBaker",0,cMessage); info("*Motion Baker set to unlocked"); } refresh_c1:value // Redraw { bRedraw = value; }
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs
Thanks!
ReplyDelete