PDA

View Full Version : anyone else had trouble with this?


vrljc
02-22-2003, 12:41 AM
Has anyone had any trouble with the PathToMotion export feature in Modeler? I created a path in Modeler, then exported it using the PathToMotion feature; when I imported it to an object in Layout, the motion path is all messed up! Is this a bug or something? Or am I doing something wrong with my path?

-vrljc

vrljc
02-22-2003, 01:19 AM
so wierd! What I was doing was taking copied points from a half circle (which formed an arc) and selecting those points and turning them into a path. After exporting the path as a motion file then importing it into layout onto a null, that is when I was getting the screwey motion path.

About 5 minutes ago I went back into Modeler, went onto a new layer, shadowed the origional half circle layer, and with the Points tool I just layed out the points according to the half circle layer. Then I numerically (grrrr) entered in the exact coordinates of the oriigional half circle's points onto the new points that I layed out. Then I created a path out of those new points, exported and imported into Layout and applied it to a null. And the motion path worked!

So i guess the problem is is that u can't create a path in modeler from copied and pasted points then export it as a motion path.

I guess we have a bug on our hands folks! Um Newtek, u listening?

-vrljc

wgreenlee1
02-22-2003, 01:19 AM
You got farther than I did .
I cant even get it to export at all.
I would like to know about this also.

faulknermano
02-22-2003, 07:27 AM
cant be certain: but i have a feeling it has something to do with the point order that the plug exports out. it might be in "global" mode so that regardless of the order of points in the spline, it will always export it out on the order it was originally created. this may explain why copying and pasting points and making a spline do not work.

below are two short scripts. the first one will read a spline's points and output them as a _custom format_ 'motion' file (since i am not intimately familiar with lw's motion file format).

the second one is for layout (generic script) and will take that custom formatted file and apply the motion to the currently selected object(s). you will be prompted the frame separation for each point in the spline, start frame, and whether or not you want to get rid of the old keys before the script adds new ones.

an important note: the Path To Motion plug seems to have a fixed frame separation of 5 frames. it also seems that TCB curves set to <0,0,0> will produce the same curve as a modeler splines with points being keyframes.


// begin Export Motion Custom script for Modeler
// requires polygon or spline selection.
// only first selected polygon / spline will be regarded.
@warnings
main
{
meshName = Mesh(0).name;
tempDir = getdir("Content");
motfile = string(tempDir,"\\",meshName,".txt");
selmode(USER);
polyc = polycount();
if(!polyc[1])
error("<br>Select a polygon or spline.");

reqbegin("Export Selection as Custom Motion File");
c1 = ctlfilename("Motion File",motfile,100,1);

return if(!reqpost());

motfile = getvalue(c1);


// gather points

editbegin();
poly = polygons[1];
wfile = openFile_write(motfile);
if(!wfile)
error("<br>Error opening file.");

pnts = polyinfo(poly);
pnts[1] = nil; pnts.pack(); pnts.trunc();

for(i=1;i<=pnts.size();i++)
{
str = string(pointinfo(pnts[i]));
wfile.writeln(str);
}

}

openFile_write: f
{
rf = File(f,"w");
return(rf);
}
// end Export script




// begin Import Motion Custom script for Generic Layout
// requires at least one item to be selected prior execution
// if more than one selection, motion will be applied to all selected.
@warnings
generic
{
startFrame = Scene().previewstart;
framesep = integer(recall("FRAMESEP",5));
deleteOldKeys = integer(recall("DELOLDKEY",1));
tempDir = getdir("Content");
fm = string(tempDir,"\\","*.txt");

motfile = globalrecall("FM_CUSTOM_MOT",fm);
s = Scene().getSelect();
if(!s[1])
error("<br>Select at least one item.");

reqbegin("Import Custom Motion File");
c1 = ctlfilename("Motion File",motfile,100,1);
c2 = ctlinteger("Start Frame",startFrame);
c3 = ctlinteger("Frame Separation",framesep);
c4 = ctlcheckbox("Delete Old Keys \(Position Only\)",deleteOldKeys);

return if(!reqpost());

motfile = getvalue(c1);
startFrame = getvalue(c2);
framesep = getvalue(c3);
deleteOldKeys = getvalue(c4);

store("FRAMESEP",framesep);
store("DELOLDKEYS",deleteOldKeys);

reqend();

rfile = openFile_read(motfile);
if(!rfile)
error("<br> Error reading file.");

t = (startFrame / Scene().fps) - (framesep / Scene().fps);

for(i=1;i<=s.size();i++)
{
if(deleteOldKeys)
{
chan = s[i].firstChannel();
while(chan)
{
if(strleft(chan.name,8) == "Position")
deleteKeysOfThisChannel(chan);
chan = s[i].nextChannel();
}
}
}

while(!rfile.eof())
{
t = t + (framesep / Scene().fps);
line = rfile.read();
v = vector(line);
// cycle objects
for(i=1;i<=s.size();i++)
{
// cycle channels
chan = s[i].firstChannel();
while(chan)
{
if(chan.name == "Position.X")
chan.createKey(t,v.x);

if(chan.name == "Position.Y")
chan.createKey(t,v.y);

if(chan.name == "Position.Z")
chan.createKey(t,v.z);

chan = s[i].nextChannel();
}
}
}
}
deleteKeysOfThisChannel: chan
{
kc = chan.keyCount;
for(i=1;i<=kc;i++)
keytimes[i] = chan.getKeyTime(chan.keys[i]);

for(i=1;i<=kc;i++)
{
if(keytimes[i] == 0)
continue;
ke = chan.keyExists(keytimes[i]);
if(ke)
chan.deleteKey(ke);
}
}
openFile_read: f
{
rf = File(f,"r");
return(rf);
}
// end Import script


"LScript: the future within your reach." :)

wgreenlee1
02-22-2003, 07:37 AM
Oh thats cool.
Got them babys into notepad and on floppys already.
Thank you.


:thumbsup:

vrljc
02-22-2003, 02:03 PM
faulknermano strikes again! geez, this is what, the 3rd and 4th lscript you have made for a question of mine?

you r the man! thank u!

-vrljc

vrljc
02-22-2003, 02:16 PM
whoops! I hit a snag! When I ran Lscript on the both Lscripts, I came up with basically the same error for both.

In modeler, I was getting an error saying:

Line 16, invalid argument count to ctlfilename()

and in Layout I was getting an error saying:

Line 19, invalid argument count to ctlfilename()

I am on a Macintosh running 6.5b if this helps

-vrljc

anobrin
02-22-2003, 11:41 PM
My Path to motion function is working fine
( LW7.5 MAC OSX)

faulknermano
02-23-2003, 04:42 AM
Originally posted by vrljc
whoops! I hit a snag! When I ran Lscript on the both Lscripts, I came up with basically the same error for both.

In modeler, I was getting an error saying:

Line 16, invalid argument count to ctlfilename()

and in Layout I was getting an error saying:

Line 19, invalid argument count to ctlfilename()

I am on a Macintosh running 6.5b if this helps

-vrljc


hmm.. got be because of 6.5b... first try updating your lscript plugs to the latest availble version fro 6.5 (that would be v2.2 i think). you've got to head over to bob's site and download it there.


at any rate whether or not you already have everything updated, remove the "1" from the ctlfilename like:


...
c1 = ctlfilename("Motion File",motfile,100,1);
...


SHOULD read:


...
c1 = ctlfilename("Motion File",motfile,100);
...


do that for both the layout and modeler script.

if it doesnt work, please email me or send me PM and i'll try to work it out with you.

vrljc
02-23-2003, 01:36 PM
All I can say is wow! It worked! Thanx again faulknermano. I find making curves in modeler(for layout motion paths) so much easier than doing it all in Layout. Now that I have gotten the grip of the graph editor, it is easy sailing from here.

Thanx again!

-vrljc

faulknermano
02-23-2003, 02:27 PM
:thumbsup:

CGTalk Moderation
01-14-2006, 11:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.