Friday, December 11, 2015

Blender handling animated non linear motion for path follow objects

For starters, as I've seen (pardon my ignorance if I am incorrect), it seems a common way to use path based animated motion for objects in blender is easily handled by using path objects such as bezier and nurbs curve objects.  I've lately used Bezier curves to handle this which are especially nice since in edit mode you can also see any torsion, or twisting, on the curve.  This is shown by the direction arrows along the curves spine.

   I have also been interested in modeling kinematic physical motion of say a camera without invoking blender's physics system in doing so and this has generally lead to some interesting observations.

First, to constrain an object to a given bezier curve object path, you select the child object first, hold shift and select the parent object (lmb click for selection...in this case the bezier object).  Then you hit 'ctrl + p' and select 'path follow'.

You will also want to have the object set at the bezier curves starting position.  You can determine this again in 'edit' mode on the bezier curve if you aren't sure which point on the curve is the start versus the end.  This will be shown with all direction arrow's on the spine of the curve (in 'edit' mode) moving away from such point and obviously being an end point on the curve (assuming your curve is not a closed loop).  If you don't want to reconfigure the curve's start and end points literally and they need be reversed, you can do so in 'edit' mode selecting all the curve's points and then selecting 'curve' > 'segments' > 'reverse direction'  (extremely handy).

The general art of modeling physical motion is given by parabolic type curvature.  These are curves which generally may need no more than 2 points on a given bezier path curve though I have used a third point in provisioning greater ease in managing the control points for a given curve arc.  I have usually situated a third control point nearer the maximum height often for a given quasi parabolic motion path arc.

Now, there are some additional things to be considered which are that alternately if you want to track the camera's frame rotation to another object, you can do so again selecting the camera (child first) and then selecting the object to be tracked.  This will not disrupt the animated motion of the camera on the bezier path, for instance, but will instead ensure that the camera is pitch, roll, yawed in the direction of the tracking object.   Once having selected the child and parent objects, in 'Object' mode, use 'Object' > 'Track' > 'Track to Constraint' .  That will lock the camera, for instance, on another object.  I personally like to use empty objects here (not physically shown) as tracking constraint objects.

Now for many new to the experience of animation, you will have linear motion (linear velocity) over time for a change in the object's position with respect to the path follow object.  You can modify the velocity of the object without effecting its linearity under the Bezier curve data tab.  This is between the bezier curve objects 'Material' (right of) and 'Modifier' (left of) tab (right hand most side of your browser under a default Blender workspace).  Under the Bezier curve data tab scroll down and select 'path animation' which should already be checked with the curve having been parented.  Expand this section, you can modify the velocity of animation of any path follow object by increasing or decreasing the frames settings.  This is the number of frames needed for an object to elapse over the course of the given bezier path object.  Obviously a lesser number of frames increases the object's velocity while increasing the number of frames decreases the path follow object's velocity.

Now, if you were wanting to experiment with non linear motion on such path, well, it is a bit more advanced and leads me to a suggestion (wish list) for Blender's programmers as a possibility.  First, I may suggest as a wish list a parametric subdivision for all given motion states as opposed to motion being determined solely by higher order polys restricted standard single variable equations.  Why so?  Firstly the conversion from single variable equations from any parametric form has a bit of work load.  Secondly physical solutions are often described in 2 dimensions with parametric equations of motion described separately for each dimensions which means the one or two axis will have a linear form (barring air resistance or any other non gravitational forces) while a third axis will have some gravitational form and is given by a non linear quadratic form.  Unfortunately this is not easily resolved in blender since f-curve modifiers are restricted relative to the usual sense of animation using interpolated bezier curve forms.  This leads me to indicate how to implement non linear motion on a follow path constrained bezier curve object.  So if you followed the step above.  You can pull up your 'Animation' workspace setup or alternately you'll want to at least pull up your 'Graph Editor' (e.g. change from '3D view' to 'Graph 'editor' is where the drop down box is located).

Next you'll want to go to 'key' > 'Add F-curve modifier' >  'Generator'.  Now, you'll need to adjust the properties of the generator that you added if you want to make things non linear.  You'll need to expand the 'properties' view area under the graph section to do this.  If you know how to pull up the 'properties' view area under the '3D view'  mode it is exactly the same on the 'Graph editor'.  There is a little plus '+' symbol in the upper right corner of the 'Graph Editor' window that is clicked and dragged to the left for this properties view expansion.  Next, go to the 'Generator' tab and it should read 'Factorized' or 'Expanded' polynomial.  I prefer the expanded form since it is a bit easier in reading and applying coefficient values here.  Curve types and what they mean.  Generally Quadratics while appropriate and correct in describing at least on a given gravitationally bound axis motion is not right when trying to determine motion of the object on a given object constrained path.  The reason for this has to do with what I explained above.  Namely, a single variable equation describes motion on both axis as opposed to motion relative a kinematic (parameterized) form.  If you wanted to determine what this single variable equation would look like first you'd need to convert from the parametric form and then solve (kinematic form would often be given in a time order based variable in either dimension say for a 2 dimensional problem) and then having used a linear or quadratic form based upon whether or not gravity applies in such dimension.  Additionally, the generator equation provided only solves one to one any given position meaning that the same local y solution (height solution)  yields the same local x on the bezier curve.  This is why modeling a maximum height with zero velocity at the height of a given parabolic trajectory means rolling back down the same path as opposed to in a typified kinematic manner (with positive transverse velocity) a different position x in approaching the same y as having been given before.  Blender's animation system is designed around periodicity here or in other words, repeating motions that would include things like a runner's stride having extended to a given maximum length and then having in relation to the runner's body having periodically returned back to a position encountered before (e.g., where the runner's torso center is represented as local x point of origin, his leg's will always repeatedly cross such as local zero in such moving coordinate system).  How then do you ensure that an object continues a long a given path even after it approaches zero velocity with the generator equation found?  Technically you'll need to use at least cubic or higher order equations (which are poly order: 3 and greater).   Polynomials that are odd will have inflection points that are necessary (by odd I mean poly order: 3, 5, 7, 9... and so forth).  The key to reduce the rapidity of growth of a given cubic or higher order polynomial is to keep the higher degree terms (x^3, x^5, and so forth) powers with smaller coefficient factors while keeping the lower degree (x, and x^2) coefficient terms higher.  Thus, typically I've set my coefficients as follows (5.120 for x, -.120 for x^2, and .001 for the x^3 term).  This tends to lead to a flattening of the growth with decent initial growth in the beginning and a small amount of growth in the object's movement near the tail end of a given 60+ frame curve elapse.   The x term will tend to flatten a curve with increasing positive value while raising the negative value (with increasing negative values) on the x^2 coefficient term tends to increase the height of the inflection point and move it further in the positive x axis direction (that is increasing the time to hit a given maximum velocity).  For my work, I have left the cubic term (x^3) alone at its given value (it needs to have a small amount at least in providing the inflection point on the curve) but obviously small enough so as to make acceleration much to rapid to prove useful for animation purposes especially in physics.

If you try any math handling between kinematic and single variable equations you'll need to consider in the conversion process (inverting the parametric value of y) to avoid the periodicity problem in blender's math system here.  It interprets +y values as positive local transverse (local x) gains while keeping the object still uniquely path constrained even if such position is parametrically outside the boundaries of the bezier curve object.  This is Blender's math interpretive way of differentiating a given y for two possible local x coordinate positions on a non one to one function bezier function.
Or basically in the conversion process, you'll need to invert the parabola at the maximum height for a given parameteric to single variable equation conversion.    

No comments:

Post a Comment

Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...