PDA

View Full Version : Expression for object on deforming motion path

 Jimothius01-25-2008, 05:11 AMI have a curve that is animated with deformers, and I want an object to travel along that path at a consistent speed. Since the length of the curve is changing, a linear animation from 0 to 1 doesn't give a constant speed. Is there a way I can use arclen to make the object travel the same distance on the curve between each frame?
Jimothius
01-26-2008, 04:55 AM
It occurred to me that locking the length of the curve would eliminate the problem, if I only had one curve. Truth is, I have many curves of different lengths running parallel, all deforming together. I want objects to travel along all their respective motion paths at the same speed (but with random start frames), and this is where I think arclen would come in handy... I just can't figure out how to implement it into an expression.

Any suggestions out there?

tbaypaul
01-26-2008, 05:39 PM
well this bit of mel will create a little example of what you are talking about, but sometimes what works in your head doesn't really work out physically when you do the math. If the path changes too radically, or increases and decreases in length the objects can jump along the path in an unexpected manner....when you use math to control motion you are giving up some control and must make sure the function's range is behaving as you expect when you are changing it's domain.

{
playbackOptions -min 0 -max 120 ;
curve -d 3 -p 0 0 10 -p 0 0 8.333333 -p 0 0 5 -p 0 0 0 -p 0 0 -5 -p 0 0 -8.333333 -p 0 0 -10 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 4 -k 4 ;
select -r curve1.cv[2] ;
newCluster " -envelope 1";
select -r curve1.cv[3] ;
newCluster " -envelope 1";
select -r curve1.cv[4] ;
newCluster " -envelope 1";
arclen -ch 1 curve1;
polySphere -r .25;
pathAnimation -fractionMode false -follow true -followAxis x -upAxis y -worldUpType "vector" -worldUpVector 0 1 0 -inverseUp false -inverseFront false -bank false -startTimeU `playbackOptions -query -minTime` -endTimeU `playbackOptions -query -maxTime` -c curve1 pSphere1;
createNode multiplyDivide;
setAttr multiplyDivide1.operation 2;
connectAttr -force curveInfo1.arcLength multiplyDivide1.input2X;
connectAttr -force multiplyDivide1.outputX motionPath1.uValue;
expression -s "float \$vel = 1.0;\r\nmultiplyDivide1.input1X = frame * \$vel;" -o multiplyDivide1 -ae 1 -uc all;
}

CGTalk Moderation
01-26-2008, 05:39 PM
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.