PDA

View Full Version : Getting an Lscript to update in real time



cesario1212
04-04-2003, 04:46 PM
I'm using an Lscript expression to control a double jointed elbow. I have one null's H channel controlling the H channels for the two bones, so they move together at once. I'm using a mapRange Lscript to list the values and then I'm using that as a subexpression within a less than or equal to expression. It works, the problem is that LW doesn't update the movement in real time. I have to make a keyframe in order for the expression to update the values.

I could put AutoKey on and then it updates in real time. The problem is that autokey keys every channel (which makes a bad mess) and not always when I want it to key (say I'm playing around with the angles.

So here's my question: does anyone know how to force LW to update the outputed expression values in real time without making keys?

Art-man

P.S. I'm using a Mac with LW 7.5 (in case that matters)

Tom Speed
04-05-2003, 09:12 AM
Hi,

Within the script, put a RefreshNow(); command somewhere, that should tell Layout to update/evaluate all motion in your scene.

Cya!
Tom

cesario1212
04-05-2003, 01:43 PM
I keep getting an unresolved function reference error when I put it in various points in the expressions.

Art-man

faulknermano
04-05-2003, 07:12 PM
i dont think you can, at any rate, safely put in CS commands outside generics or master class. why dont you run a master class in background:



@script master
create
{
setdesc("AutoRefresh");
}

process: event, command
{
if(event == COMMAND)
Refresh();
// or RefreshNow();
}

Tom Speed
04-05-2003, 08:08 PM
Hi,

Faulknermano, you can use CS commands anywhere now, it was an experimental feature of v2.5.

v2.5 Notes (http://www.lightwave-outpost.com/Bob/LScript/v25.html) (scroll to the bottom of the page)




Global Command Sequence Access
Description
Layout's Command Sequence system, heretofore limited only to the Generic and Master class of scripts, can now be invoked from any Layout LScript. No restrictions are placed on where or when CS functions can be called.

Known Issues
Command Sequence functions can be called at the wrong time and place, with appropriate consequences, even though such times and places are unknown. Be prepared for application crashes if CS functions are used lavishly and without consideration for Layout's current state.


Cya!
Tom

faulknermano
04-06-2003, 12:36 AM
that's right.. note the operative word that i used "safely". :D

for example, in motions scripts, i cannot imagine calling RefreshNow() repeatedly (since there are ALOT of calls to the process func in one given time). i wish there was, however, a newtime func like displacement scripts, so that you can keep track of every 'motion loop,' if you catch my meaning.

Tom Speed
04-06-2003, 07:21 AM
Ahh, you mean so no frames are skipped when you want to evaluate a whole scene?


Tom

faulknermano
04-06-2003, 08:48 AM
actually, oppositely: so that a the proc function (or whatever func provided) will only evaluate *once* every frame. i dont know if you followed the thread back in the lscript mailng list, but item motion handler script evaluate many times (depending on total motion length) per 'frame travel.' currently, it seems impossible to check for the instance's own positon / rotation at a specified time, because the process func will always reevalute the whole timeline from beginning to end. what, i think is needed, is a separate func apart from process that will only be called ONCE per frame travel.

cesario1212
04-06-2003, 01:06 PM
Woah, Woah, Woah. I should have put on my first message, that I'm still a newbie to Lscript and all that. I'm a college student. You guys are going way over my head here, although I greatly thank you for all your help.

Where do I execute the script you gave me? In Lscript Commander? And what exactly are the events and command variables?

Does the event equal "AddRotation H P B" where H,P,and B are specific numbers for the specific Control Null rotation? Or is it for each idividual bone rotation?

What does the command equal?

What goes between the parenthesis for the "Refresh()" and "RefreshNow()" commands? Do I use both, or was the "or" in the script there to say I should try either one?

I've gone through the LW manuals, but they're useless. My teachers are of no help. I'm still looking for on-line web pages that may help me with my overwhelming ignorance, so I apologize for all the questions.

Art-man

faulknermano
04-06-2003, 09:39 PM
Where do I execute the script you gave me? In Lscript Commander? And what exactly are the events and command variables?


you load it up as a master class lscript

the event and command variables are the event type and the string value of the command itself. it's all in the User Guide.



What goes between the parenthesis for the "Refresh()" and "RefreshNow()" commands? Do I use both, or was the "or" in the script there to say I should try either one?

most of the time, Refresh() is fine. but there are cases when RefreshNow() does certain things that Refresh() cant. like for example, when de-parenting an object and moving some place, RefreshNow() will update Layout 'quickly' while Refresh() does not seem to take effect.

cesario1212
04-07-2003, 05:32 PM
No dice. The event and command variables are merely reading the rotation of the null and not updating the bones influenced by the expressions.

Can I place expression outputs (ie. values) into variables and tell LW to update from there? Or is another tactic nessary. I've been skimming the LW Lscript user guide and ref manual. I'm still in the process of learning (ie. I'm still in the middle of my crash course in programming).

Here are the expressions I am using to control everything. "SDP_ELBOW_RT_FOLLOWER" is the control Null used to control the H rotation of the two elbow bones.

Elbow_RT_1 (attached to H channel of first elbow joint)
[SDP_ELBOW_RT_FOLLOWER.Rotation.H]<=3.000?[Elbow_RT_1base]:Value

Elbow_RT_2 (attached to H channel of second elbow joint)
[SDP_ELBOW_RT_FOLLOWER.Rotation.H]<=3.000?[Elbow_RT_2base]:Value


Elbow_RT_1base
mapRange([SDP_ELBOW_RT_FOLLOWER.Rotation.H],-67.760,3.000, -67.760,3.000)

Elbow_RT_2base
mapRange([SDP_ELBOW_RT_FOLLOWER.Rotation.H],-67.760,3.000, -86.740,3.000)


Or, is there a way for Autokey just to key one channel? I'll settle for that if that route happens to be easier.

Art-man

faulknermano
04-08-2003, 10:50 AM
No dice. The event and command variables are merely reading the rotation of the null and not updating the bones influenced by the expressions.

hmm.. the idea is to call a Refresh() so that Layout can update the expressions. now, i've done this with displacement scripts wherein an IK driven forearm drives the displacement in realtime by using the AutoRefresh script.

other than that, i'm not sure how to go about it.