PDA

View Full Version : Passing plugin data to other plugins



adamredwoods
09-29-2007, 06:06 PM
Hello, seems I have a problem and could gratefully use any insight anyone has.

Setup:
Bone01 (parent) has a motion modifier on it, for say rotation.
Bone02 (child) has a motion modifier on it, for another rotation.

Those who recognize this situation know that I'm not going to get BONE02 to rotate where I want it to, because LW doesn't store post-motion modifier info. Bone01 rotation will have to be keyed, or somehow evaluated by Bone02, before I can get Bone02 to rotate to where I need it to be. But these solutions are out (for now).

This thread:
http://newtek.com/forums/showthread.php?t=30440
says to use IPC, but AFAIK the IPC is only in lscript.

Questions:
Is there a way to use IPC in the C SDK? I could not find the documentation.

Is there another way to let multiple MM plugins know of an objects plugin's data?

Many thanks,
Adam

Dodgy
09-29-2007, 06:18 PM
The ring....

adamredwoods
09-29-2007, 09:09 PM
That's right, I missed that one when I was looking through the SDK...

Do you know how it would be best to share the bone01 information with bone02 ,or even if another child bone03 is added with another MM plugin?

Would it be best to just have bone01 attach to the ring and send data to the ring whenever there is a change in its rotation; then when bone02 is processing, it looks for the proper topic and grabs that info from the ring.

Or is it more interrupt driven, where you must process the event immediately upon delivery or it's lost?

I'm going to play with it a bit.


Thanks Dodgy!

Dodgy
09-30-2007, 07:45 AM
Each time data is put into a topic, then a specific 'read' procedure (which has been defined by you) will be called, and it will process the data. If you look at my muscle plugin, it shows one example of how this can be used in practice.

adamredwoods
09-30-2007, 01:26 PM
Right on. :thumbsup:

I think I will setup the plugins as:
- each has an event callback willl return the rotation/position/scale matrix data when the appropriate topic is triggered
- a topic is triggered as I need it in the main execution of the plugin
- it then receives data and parses the returned info from each plugin.
- the parsed data will have ID and data, so just match the ID with the parent and add that to rotation

My other thought (as the wheels started turning again) was I wonder how well 'settag' works. I've used that as well to store data on individual bones. But there is overhead parsing time.

Or even... creating a new channel and storing the data there. And I think that is how IKBoost works.

I guess there are a few ways of interplugin communication.
//Adam

adamredwoods
10-01-2007, 09:43 PM
Well, here's my initial attempt. It doesn't work.

I used LScript, since it's easy to prototype before going to C. The scene test setup is to create two nulls adding this Motion Modifier plugin to both of them. Name one null "me". that is the caller to the second null. It says, give me your rotation.

...Aside from it not working, I think I will try a different method, with envelopes and channels, since I think this method isn't instant feedback (ie needs a keyframe).

Posted the code for future archeologists.

Notes:
I think the problem is in the way I encode/decode the data, but I'm not sure. The integer works, but not the floats.
I also had the caller call every cycle, because I wanted to see how much it would slow down. I was planning on seeing how slow after 50 or so nulls had this MM on it. It would give me an idea of performance/scalability of the comring.




@warnings
@script motion
@version 2.7

TOPIC="ringtest";
thisObj;
[email protected],0,[email protected];
step=0;
dlist = @"i","f#3"@;

create: obj
{
inData[1]=0;
thisObj=obj;
comringattach(TOPIC,"comringevent");

setdesc("ComRing Tester");
}
destroy
{
comringdetach(TOPIC);

}
process: ma, frame, time
{
tid=thisObj.id;
if(thisObj.name=="me" ) {
jd = @tid,0,0,[email protected];
j=comringencode(dlist, jd);
comringmsg(TOPIC,1,j);

}
if(step==2) {


dx = thisObj.getWorldRotation(time);
[email protected],dx.x,dx.y,[email protected];
j=comringencode(dlist, jd);
comringmsg(TOPIC,2,j);
step=0;
}

if(step==3) {
setdesc("t: "+t+" d:"+inData[2].asStr()+" "+inData[3].asStr()+" "+inData[4]);
step=0;
v = <inData[2],0,0>;
ma.set(ROTATION, v);
}

}

comringevent: event, data
{

if(event==1) {
//this has been hailed, flag to send data back as event2
i = comringdecode(dlist,data);
thisID = i[1];
if(thisID != thisObj.id) {
step=2;
}
}
if(event==2) {
//receive
inData = comringdecode(dlist, data);
step=3;
}
}
flags
{
return;
}