PDA

View Full Version : Rotate Motion Path

Richard Hebert
07-12-2012, 12:21 PM
I noticed that we can move a path in LW with the Move Path tool. Is there a way to rotate or reorient a path that has been loaded into a scene? Simply adjusting individual path points isn't working out. Thanks for any clues.

Richard

Ryan Roye
07-12-2012, 12:24 PM
One solution is to child the object to a null then rotate the null. I too am stumped as to why we'd have a "move path" tool and not a "rotate path" tool... ah well.

Richard Hebert
07-12-2012, 12:32 PM
Maybe the LW gods will respond if I offer up a digital sacrifice... I'll destroy my old fax machine and see what happens...

Richard

shrox
07-12-2012, 12:35 PM
Maybe the LW gods will respond if I offer up a digital sacrifice... I'll destroy my old fax machine and see what happens...

Richard

http://www.romston.com/wp-posts/09-09-05-officespace/office-space-fax.jpg

Richard Hebert
07-12-2012, 12:38 PM
Ok, now that's funny!!!

tyrot
07-12-2012, 02:28 PM
richard , there was a long thread - one of the plugin writers i dont remember his name , said it is DOABLE - rotate the path

Mike, (wolf) said it is NOT doable

Mike was right it was NOT doable easily.. SO parent that path to null - as chaz mentioned and live happily after- --

parenting things to null is a very nice thing generally :)

Ryan Roye
07-12-2012, 02:41 PM
Yeah, now that I think about the math behind doing such an operation it is a lot different than just moving XYZ...

Move path just goes "OK, all keyframes are going to move in the same direction". Easy.

a theoretical Rotate path would have to do insane mathematical calculations... as moving all of them linearly like XYZ would just spin everything in place. Rotating a path would involve XYZ and HPB, and include equations for arcs that would have to avoid altering the keyframes base position in the path as the user rotates the path. Makes my head hurt just thinking about it... this is why I'm not a full blown programmer. Kudos to the LW programmers.

I think even if they did put a rotate path tool in there, it'd be pretty darn slow as the number of keyframes it needs to move increases.

Nulls rock:thumbsup:. Tons of things you can do with nulls. Organize, add additional flexibility of movement in rigs, offsetting, targetting, guides... they are among the greatest things that ever happened to 3d programs.

RebelHill
07-12-2012, 02:58 PM
In one respect, rotating the path would be quite simple... certainly repositioning the keys would be quite basic... plotting new XYZ positions for each key, easy... altering the rotations, even easier, its just an add operation (where the rotate path amount is added to existing rotation value).

The hard, and probably not possible part would be the interpolation between frames, for anything other than linear interpolation, you'd have to try and find a way to "redraw" the inbetweens and calculate the necessary changes to interpolation settings... Yikes!

What you can also do, however, should you for some reason NOT want the item being altered parented to a new null, is to instead setup a constraint instead of a direct parenting, you can then rebake the keys and remove the constraint again. You can even do this multiple times over to rotate a path back and forth at different points in time, should such a thing be required.

SplineGod
07-12-2012, 03:07 PM
Whats interesting is that older versions of LW used to do it. You were able to offset a motion path which you can still do or rotate a motion path around any keyframe. Dont know why it was removed.

Richard Hebert
07-12-2012, 04:58 PM
Rotating a path shouldn't be that cumbersome. There are programs that allow rotation and a whole lot more. Jimmy rigger comes to mind. I profess ignorance in the mechanics of path manipulation, however, and will defer to the Jedi elite out there.

Richard

papou
07-12-2012, 05:53 PM
there is a master script somewhere that do that... named rotate_motionpath.ls or something like that :P

papou
07-12-2012, 06:07 PM
find it but need to be fixed for compatibility issue since ... 2001.

/*
** LAST REVISION: MONDAY, DECEMBER 24, 2001
**
** NOTE: THIS SCRIPT WILL NOT WORK WITH LSCRIPT VERSIONS 2.2.2 OR NEWER SINCE THAT'S WHEN THE
** firstChannel() FUNCTION GOT WACKED AND IT'S STILL NOT FIXED TO THIS DATE.
*/
@version 2.2
@warnings
@script master
//@strict

ctlRotateX;
ctlRotateY;
ctlRotateZ;
ctlPivot;

curScene;
curItem;
curTime;
Times_With_Position_Keys;
Keys_Coordinates;
Pivot;

create
{
setdesc("LW Rotate Motion Path");
curScene = Scene();
curTime = curScene.currenttime;
curItem = curScene.getSelect();
Times_With_Position_Keys = Get_Times_With_Position_Keys(curItem[1]);
Keys_Coordinates = Get_Keys_Coordinates(curItem[1], Times_With_Position_Keys);
}

flags
{
return(SCENE, OBJECTS, EFFECTS);
}

options
{
windowWidth = 320;
windowHeight = 140;

if(reqisopen())
{
reqend();
}
else
{
reqbegin("Rotate Motion Path");
reqsize(windowWidth, windowHeight);

ctlRotateX = ctlslider("Rotate X", 0, -100, 100);
ctlRotateY = ctlslider("Rotate Y", 0, -100, 100);
ctlRotateZ = ctlslider("Rotate Z", 0, -100, 100);
ctlPivot = ctlvector("Pivot", 0, 0, 0);

ctlposition(ctlRotateX, 5, 5);
ctlposition(ctlRotateY, 5, 25);
ctlposition(ctlRotateZ, 5, 45);
ctlposition(ctlPivot, 5, 85);

reqopen();
}
}

process: event, command
{
//info("command is <", command, ">");
commandParts = parse(" ", command);
if (commandParts[1] == "SelectItem" || commandParts[1] == "SelectByName")
{
curTime = curScene.currenttime;
curItem = curScene.getSelect();
//info("Now we have <", curItem[1].name, "> selected");
Times_With_Positon_Keys = nil;
Keys_Coordinates = nil;
Times_With_Position_Keys = Get_Times_With_Position_Keys(curItem[1]);
Keys_Coordinates = Get_Keys_Coordinates(curItem[1], Times_With_Position_Keys);
}
}

{
}

{
}

{
}

Rotate: flag
{
//info("flag is <", flag, ">");
{
rotationAngle = getvalue(ctlRotateX);
}
{
rotationAngle = getvalue(ctlRotateY);
}
{
rotationAngle = getvalue(ctlRotateZ);
}
rotationAngle /= 100.0;

{
curTime = curScene.currenttime;
curItem = curScene.getSelect();
Pivot = curItem[1].getPosition(curTime);
}
else
{
Pivot = getvalue(ctlPivot);
}

for a = 1 to Keys_Coordinates.count() do begin
{
DeltaY = Keys_Coordinates[a,2] - Pivot.y;
DeltaZ = Keys_Coordinates[a,3] - Pivot.z;
rotatedX = Keys_Coordinates[a,1]; // X IS NOT CHANGED WHEN WE ROTATE ABOUT X AXIS.
rotatedY = (CosRotationAngle * DeltaY) - (SinRotationAngle * DeltaZ) + Pivot.y;
rotatedZ = (CosRotationAngle * DeltaZ) + (SinRotationAngle * DeltaY) + Pivot.z;
}
{
DeltaX = Keys_Coordinates[a,1] - Pivot.x;
DeltaZ = Keys_Coordinates[a,3] - Pivot.z;
rotatedX = (CosRotationAngle * DeltaX) + (SinRotationAngle * DeltaZ) + Pivot.x;
rotatedY = Keys_Coordinates[a,2]; // Y IS NOT CHANGED WHEN WE ROTATE ABOUT Y AXIS.
rotatedZ = (CosRotationAngle * DeltaZ) - (SinRotationAngle * DeltaX) + Pivot.z;
}
{
DeltaX = Keys_Coordinates[a,1] - Pivot.x;
DeltaY = Keys_Coordinates[a,2] - Pivot.y;
rotatedX = (CosRotationAngle * DeltaX) - (SinRotationAngle * DeltaY) + Pivot.x;
rotatedY = (CosRotationAngle * DeltaY) + (SinRotationAngle * DeltaX) + Pivot.y;
rotatedZ = Keys_Coordinates[a,3]; // Z IS NOT CHANGED WHEN WE ROTATE ABOUT Z AXIS.
}

c = curItem[1].firstChannel();
while(c)
{
if (c.name == "Position.X")
{
c.createKey(Times_With_Position_Keys[a], rotatedX);
Keys_Coordinates[a,1] = rotatedX;
}
if (c.name == "Position.Y")
{
c.createKey(Times_With_Position_Keys[a], rotatedY);
Keys_Coordinates[a,2] = rotatedY;
}
if (c.name == "Position.Z")
{
c.createKey(Times_With_Position_Keys[a], rotatedZ);
Keys_Coordinates[a,3] = rotatedZ;
}
c = curItem[1].nextChannel();
}
end
}

Get_Times_With_Position_Keys: item
{
timesWithKeys = nil;
i = 0;
c = item.firstChannel();
while(c)
{
if (c.name == "Position.X" || c.name == "Position.Y" || c.name == "Position.Z")
{
for a = 1 to c.keyCount do begin
k = c.keys[a];
keyTime = c.getKeyTime(k);
i++;
timesWithKeys[i] = keyTime;
end
}
c = item.nextChannel();
}
timesWithKeys = My_Reduce(timesWithKeys, "FORWARD");
return timesWithKeys;
}

Get_Keys_Coordinates: item, timesWithKeys
{
keysCoordinates = nil;
for a = 1 to timesWithKeys.count() do begin
//info("Times_With_Keys[", a, "] = ", Times_With_Keys[a]);
c = item.firstChannel();
i = 0;
while (c)
{
if (c.name == "Position.X" || c.name == "Position.Y" || c.name == "Position.Z")
{
i++;
keysCoordinates[a,i] = c.value(timesWithKeys[a]);
}
c = item.nextChannel();
}
end
return keysCoordinates;
}

My_Reduce: array, flag
{
size = array.size();
if (flag == "FORWARD")
{
start = 1;
stop = size;
step = 1;
}
else if (flag == "BACKWARD")
{
start = size;
stop = 1;
step = -1;
}
for (a=start ; true ; a+=step)
{
if (flag == "FORWARD" && a > stop)
{
break;
}
if (flag == "BACKWARD" && a < stop)
{
break;
}
element = array[a];
if (element != nil)
{
if (flag == "FORWARD")
{
start2 = a + 1;
stop2 = size;
step2 = 1;
}
else if (flag == "BACKWARD")
{
start2 = a - 1;
stop2 = 1;
step2 = -1;
}
for (b=start2 ; true ; b+=step2)
{
if (flag == "FORWARD" && b > stop2)
{
break;
}
if (flag == "BACKWARD" && b < stop2)
{
break;
}
if (array[b].asStr() == element.asStr())
{
array[b] = nil;
}
}
}
}
array.pack();
array.trunc();
return array;
}

nickdigital
07-12-2012, 06:51 PM
Has this issue been fogged?

papou
07-12-2012, 07:51 PM
I'm not sure the issue is the issue in the NOTE.
It's seem to be more a minor issue about parsing or something about string or function changes since 2001.

Btw, resolving this minor issue may be follow by the major issue...

PS: I'm not the author of this script. I can't remember about his name...

Sensei
07-12-2012, 09:07 PM
I think even if they did put a rotate path tool in there, it'd be pretty darn slow as the number of keyframes it needs to move increases.

It would be pretty much as fast or as slow as Move Path Tool.

I could write it, together with Scale Path tool, if there would be serious interest ;) You know what I mean..

Nulls rock:thumbsup:. Tons of things you can do with nulls. Organize, add additional flexibility of movement in rigs, offsetting, targetting, guides... they are among the greatest things that ever happened to 3d programs.

Nulls don't do anything.. ;)

It's parenting child item to parent item that you're talking about.

ps. You're over complicating this tool.. Interpolation between frames?! WTF. Move Tool doesn't change key frame, just key value. So the same would be with Rotate/Scale Path Tool.
Imagine spline in Modeler, and how you are doing Translate, Rotate, and Stretch on it..

jeric_synergy
11-25-2012, 04:31 PM
(bump)

Move Tool doesn't change key frame, just key value. So the same would be with Rotate/Scale Path Tool.
Imagine spline in Modeler, and how you are doing Translate, Rotate, and Stretch on it..
Indeed, what's the issue? A path is a spline, when did rotating a spline become difficult?

Richard Hebert
11-26-2012, 01:09 AM
The problem that I had was a motion capture file (jogger) whose motion path could be moved around in x,y,z but could not be rotated for better alignment with the model dock scene that I'm working on.

jeric_synergy
11-26-2012, 12:00 PM
Richard, I meant programatically/mathematically, not "why would you want this?". It's a very desirable feature, one I thought we had (!).

(RH says it's hard, Sensei says it's easy, I should just take cover and stay quiet....)

Sensei
11-26-2012, 12:05 PM
I will write interactive tool for this.

jeric_synergy
11-26-2012, 12:10 PM
I will write interactive tool for this.
Excellent!

(Seriously, didn't we used to be able to do this???)

Richard Hebert
11-28-2012, 01:49 AM
Hi Jeric, didn't mean that as a slight or anything just reminiscing the origins of the thread. Things like that don't come through in print like in person. Sorry for any misunderstanding!

jeric_synergy
11-28-2012, 01:10 PM
Hi Jeric, didn't mean that as a slight or anything just reminiscing the origins of the thread. Things like that don't come through in print like in person. Sorry for any misunderstanding!
No worries! I realize my post was ambiguous, and I agree with you that this would certainly be a desirable function that I too would want (I coulda sworn we had it!). :beerchug:

Mathematically (says the guy who can't remember what dot product is), I'd think that a motion path is a spline, and "we" know how to rotate splines, so what's the issue??? Maybe it's the keyframes and their temporal component -- although why that would matter in a purely spatial transform/rotation I don't know. Anyway, the big brains are on it, so perhaps a plugin will pop out in the near future. ::crossed fingers::