PDA

View Full Version : How to get IK motion into GRAPH EDITOR expressions


hairy_llama
01-21-2005, 01:14 PM
I can't figure out how to get an objects position when its controlled by IK into my expressions... obj.wpos(Time).x does not work unless it's keyframed motion. I can't use motion modifier expressions, they have to be the graph editor ones... Is there a way to do this?

Dodgy
01-21-2005, 07:35 PM
Not directly unfortunately....

You can work around by using Motion Baker on the driving bone, then maybe baking to a separate channel and using this as the expression driver, or even over writing the base channel, since Ik will be unaffected by key frames in this channel.

MSherak
01-26-2005, 10:51 PM
A way to do this is use IK_Booster.. Since it's an IK system that solves into FK.. This way you can use expressions since you will have the information in the channels..

faulknermano
01-30-2005, 09:34 AM
i'll show you a super-hack with lscript.

first, apply this motion modifier script to the item you wish to *read* IK from:



@warnings
@script motion
expose type, rot as ikreader_01;
selChannel; channelNames;
save: what, io
{
if(what == SCENEMODE)
io.writeln(selChannel);
}
load: what, io
{
if(what == SCENEMODE)
{
line = io.read();
type = selChannel = integer(line);
}
setdesc("IK Reader 01 > ",channelNames[selChannel]);
}
flags
{
return(AFTERIK);
}
create: ma
{
type = selChannel = 2;
obj = ma;
channelNames[1] = "Rotation.H";
channelNames[2] = "Rotation.P";
channelNames[3] = "Rotation.B";
setdesc("IK Reader 01 > ",channelNames[selChannel]);
}
process: ma, frame, time
{
a = ma.get(ROTATION,time);
if(selChannel == 1)
rot = a.h;
if(selChannel == 2)
rot = a.p;
if(selChannel == 3)
rot = a.b;
}
options
{
reqbegin("IK Reader 01 Options");
c1 = ctlpopup("Channel to Read",selChannel,channelNames);
ctlsep();
ctlrefresh(c1,"refreshSelChannel");
reqopen();
}
refreshSelChannel: val
{
type = selChannel = val;
setdesc("IK Reader 01 > ",channelNames[selChannel]);
}

THEN, apply this to a master channel (e.g. custom channel) from which to reference the IK info:


@warnings
@script channel
a; b; c;
save: what, io
{

}

load: what, io
{

}

destroy
{

}
create: channel
{
RefreshNow();
a = ikreader_01$rot;
if(a == nil)
error("<br>Unable to detect IK Reader I/A instance.");
b = ikreader_01$type;
if(b == 1)
str = "Rotation.H";
if(b == 2)
str = "Rotation.P";
if(b == 3)
str = "Rotation.B";
setdesc("IK Reader Channel 01 > ",str);
}

process: ca, frame, time
{
a = ikreader_01$rot;
c = ikreader_01$type;
if(c != b)
changeDesc();
if(a)
ca.set(a);
}
changeDesc
{
b = c;
if(b == 1)
str = "Rotation.H";
if(b == 2)
str = "Rotation.P";
if(b == 3)
str = "Rotation.B";
setdesc("IK Reader Channel 01 > ",str);
}



the basic idea is this: IA script that is applied to the item reads the item's IK info. this info is exposed.

CF script, applied to the custom channel, or a master channel, extracts this IK info and places this info in its channel.

in your expression, instead of referring to the item directly, refer to this channel instead.


just a hack i did a long time ago. might prove useful, or not....

NanoGator
01-30-2005, 04:57 PM
Faulk: Is it possible to calculate an expression inside LScript? I mean... err..

Ill ask this another way because I'm having a hard time formulating this question:

Is there a way to take a string like:

x="[Null.Rotation.H] + Value + [Null (2).Rotation.H]";

... and send it off to Layout or something to evaluate as an expression?

I have a feeling I know the answer to this, but I thought I'd ask anyway. It'd be cool if LScript had an 'evaluate expression' function instead of having to write our own parsers.

faulknermano
01-30-2005, 08:29 PM
a direct answer is: no, i dont think so. but there are two `solutions`to what i think you're trying to describe.

1.) lscript can be called as function in an expression. you can use this functionality somehow.

2.) you can attach expressions via lscript. computation is not by lscript, expressions are only created and subsequently assigned.



GE_CreateExpression <name> <expression>
GE_AttachExpression <channelname> <expressionname>
GE_AttachExpressionID <channelid> <expressionname>
// use CommandInput() with these



edit:

3.) of course, you have the option of using lscript as your 'expression' itself, letting lscript do the calculating. not expression syntax, though.