Tips'n'Tricks

The Tips in detail

back to Tips'n'Tricks index send mail to Adger
previous Tip next Tip
 

 "Tracking the middle of two paths simultanously."

3D Studio Max specific
 

You made objects each following it's own path through space and time. You want to track the middle of them, ie. because you want to make a camera look there or due to other needs you want to estimate this position.

Estimating the "middle position" (or center-world-coordinates) of two static objects is easy: Group them, align the third object to the group's center. Doing this over the time you either got to estimate the refering coordinate for each frame, setting up a positional list, or you'll use an expression controller.

Using expressions can be annoying, since a basic knowledge and understanding of mathmatics is required to get them right. In this case you will want to have a look at vectors (geometry, n-dimensional space) and their mathmatical logic. What you want is to determine the half of the length of the vector created between the center of object 1 and the center of object 2 and apply changes of either coordinate (object 1 and / or object 2) to the coordinates of the third one or: 0.5 * P->Q. For the three-dimensional room, using kartesic coordinates, the formular would be:

   ___
   PQ = 0.5 * SQR( ( x1 - x2 )2 + ( y1 - y2 )2 + ( z1 - z2 )2 )
	

I managed to get this right by one single and simple expression.

To demonstrate this procedure, I'll set up a simple scenario including three dummies and two splines:

  • reset Max
  • create three dummies
  • create any two non-identical splines
  • set up the animation length to 100 frames
  • make dummy01 to follow line01 over the time, ie. by using "Spline Conversion: Convert From". I set Start to 0 (zero) and End to 100, using 101 samples (one for each frame)
  • make dummy02 to follow line02 as described for dummy01.
  • Play the anim. Dummy01 should follow line01, dummy02 should be following line02 and dummy03 should stay static (not moving.)
  • Open trackview.
  • Assign an controller Expression: Position to dummy03
  • within the expression you will need two vector variables:
    • one vector carrying the coordinates of dummy01
    • one vector carrying the coordinates of dummy02
  • create a vector "d1" and assign it to the Controller: Position of dummy01.
  • create a vector "d2" and assign it to the Controller: Position of dummy02.
  • assign the expression "0.5 * (d1 + d2 )"
  • Play the animation. Dummy01 should be following it's path, the same for dummy02. Dummy03 should go along a path representing the relative middle between dummy01 and dummy02.

By using the factor 0.5 you tell that you want the middle (or center) of the vector dummy01->dummy02. Modifying this will enable you to tell various fractions (or multiples) of this vector and translating it to dummy03. The smaller the factor, the closer dummy03 will stay to dummy01, the bigger the factor (up to 1.0) the closer dummy03 will stay to dummy02. Using negative factors (below 0 (zero)) or above 1 (one) is possible, too, but might lead to unpredictable results (I have not checked this out to lengthes. Any volunteers?) This expression works well while dummy01 and dummy02 are using Bezier positions. I did not test this expression on other positional controllers (ie. Euler or List) and not using Bezier positions might not work with this expression.

If you happen to get strange results, try assigning a controller Position XYZ to dummy01 and dummy02. Sometimes the Bezier-Coordinates are not translated correctly into the expression.
 

 
Do you think this tip or trick is... very usefull -- medium -- waste of time