View Full Version : Multiple instances through Motion modifier

04-03-2007, 10:04 AM

I'm writting a Motion plugin that reads a motion file, eg. the plugin is a motion modifier that reads a motion directly from a motion file. The result is that the object moves as if it hasn't keyframes.

The plug has an interface that enables the user to select the motion file that is gonne be read. MotionReader is a class that reads through the motion file.

Here is the option function of my interface:

LWError options( LWInstance inst )
char node[ MAXFILESZ ] = "";
char path[ MAXFILESZ ] = "";
char name[ MAXFILESZ ] = "";

LWFileReqLocal frloc;
int result;

frloc.reqType = FREQ_LOAD;
frloc.title = "Load Motion File";
frloc.bufLen = MAXFILESZ;
frloc.pickName = NULL;
frloc.fileType = LWFTYPE_MOTION;
frloc.path = path;
frloc.baseName = node;
frloc.fullName = name;

result = filereq( LWFILEREQ_VERSION, &frloc );

if (result == AFUNC_OK && frloc.result > 0)
reader = new MotionReader(frloc.fullName);

msg->info("Load file:", "FAILED");

return NULL;

The plugin works well if there's only one object. However, as soon as I had the motion modifier to another object, the motion plug reads the same file for both. If I change the file, the 2 objects still moving together but reading the new file.

I would like to know if anyone knows how I could intanciate 1 MotionReader for 1 object ?!...

Thanks for your help.

04-04-2007, 08:15 AM
LWInstance of your handler is local data where you should place everything item related.. I see that you have some global variable reader, that must be redesigned.. Only things like GlobalFunc * should be global variables, everything else put to LWInstance structure (you define it, just type-cast it where needed)..

04-04-2007, 10:21 AM
Thanks mate,

I had already find the problem and it was the one you explained me !! However, I have anothe question. My plug is a motion reader than links an object to a motion file and reads through it. It's areal time reader, eg the motion of the object changes whenever the motion file change. To select a motion file, I've had an Interface to the motion plugin. The result is that each object moves without any keyframe.

However, as I would like to link each object of my scene at the same time. Is there a way to set a parameter into a motion plugin by using a layout plugin ?! Or can plugins communicate between them ?!