PDA

View Full Version : Camera Path Motion



Matt
06-10-2008, 04:28 PM
Saw this on Lux's site:

http://forums.luxology.com/discussion/topic.aspx?id=26321

Looks very nice and fluid.

I know we can generate paths in Modeler, but not sure it works the same way as the author of this script describes.

Be nice for someone to take a whack at this for LightWave, I know I always struggle getting silky smooth, constant speed camera motion, especially with movement as complex as shown in the videos.

Matt

faulknermano
06-12-2008, 02:55 AM
code is incomplete. lots of stuff to do for it. but basic positional 'velocity constraint' is in place. things to do: envelope-able speed, rotational velocity constraint (if that's possible for me to do).

usage: animate a path first using a null. then your main object follows that null via this script. set its speed limit. if speed limit is too high for the overall length of the path it will revert to following the path normally.




@warnings
@script motion
@name Cruise Control 2
followItem;
mps;
timeSegment;

flags
{
// return(AFTERIK);
}
process: ma, frame, time
{

distTravelled = getDistanceTravelled(ma.objID,time);
if(followItem)
{
myPos = getMotionPathDistance(followItem,distTravelled,tim e);
if(myPos)
ma.set(POSITION,myPos);
}
}

create: obj
{
followItem = nil;
setdesc("Cruise Control 2");
timeSegment = 1 / Scene().fps;
mps = number(recall("mps",1));
}
options
{

reqbegin("Cruise Control 2");
c1 = ctlallitems("Follow Item",followItem);
c2 = ctldistance("Meters per Second",mps);
return if(!reqpost());

followItem = getvalue(c1);
mps = getvalue(c2);
store("mps",mps);
reqend();

}

getDistanceTravelled: item, myTime
{

return(myTime * mps);

}

getMotionPathDistance: item, distTravelled, distTime
{
totalDist = 0; // totalDist is distance that is measured from the start
// get the distance from zero time to specified time (usually the currenttime)
for(i=0;i<=distTime;i=i+timeSegment)
{
wpos1 = item.getWorldPosition(i);
wpos2 = item.getWorldPosition(i+timeSegment);
wpos3 = item.getWorldPosition(i+timeSegment+timeSegment);
wposDist = vmag(wpos2 - wpos1);
wposEndVec = wpos3 - wpos2; // used when overshooting
totalDist = totalDist + wposDist;

// need to reach distTravelled. but also need to be precise

if(totalDist >= distTravelled)
{
excess = distTravelled - totalDist;
endMag = vmag(wposEndVec);
if(endMag)
ratio = excess / vmag(wposEndVec);
else
ratio = 0;
finalPos = (ratio * wposEndVec) + wpos2;
return(finalPos);
}

}
// returns original if desired speed is too fast for curve
return(wpos1);

}

save: what, io
{
if(what == SCENEMODE)
{
io.writeln(followItem.genus);
io.writeln(followItem.name);
io.writeln(mps);
}
}

load: what, io
{
if(what == SCENEMODE)
{
followItemGenus = integer(io.read());
followItemName = io.read();
mps = integer(mps);
followItem = getOA(followItemName,followItemGenus);
}
}
getOA: str, genus
{
if(genus == MESH)
m = Mesh(str);
if(genus == LIGHT)
m = Light(str);
if(genus == CAMERA)
m = Camera(str);
return(m);


}

faulknermano
06-12-2008, 03:04 AM
btw, make sure that your path is 'long' and 'fine' enough. the script has trouble with short and 'jerky' paths. the script simply retrieves position data from the path - it doesnt calculate anything except for the remapping based on distance travelled. so the path must have as much 'detail' as possible.