3 Replies Latest reply on Apr 27, 2006 3:03 AM by James Newton, ACP

    Rotation issues

      Here I am again... Sorry if I am bothering you!

      I'm trying to make a model go from a to b, where a is where you do a mousedown and b is where you do a mouseup. And it works with interpolation (thank you James Newton!) and looks quite good. The next step for me is to make the model rotate with interpolating so that a special face of the mesh points towards b. The "model.pointAt(loc1)" works but I can't control it so the results are not satisfying. An example of what I want to do can be found in Warcraft Reloaded by the genius Necromanthus.
      Any suggestions?
        • 1. Re: Rotation issues
          James Newton, ACP Level 3
          Let's break this down into steps.

          To use interpolate() you need two transforms: the transform of the model before it moves and a transform representing its position at the end of its move. Suppose myObject is a pointer to the object you want to rotate. Suppose myTarget is a pointer to the object that you want myObject to point at. You can obtain these two transforms as follows:

          myStartTransform = myObject.transform.duplicate()
          myEndTransform = myObject.transform.duplicate()

          Now you simply need to perform the interpolation between these two transforms, and set the transform of myObject to the result. So long as there is no update between the lines above and the first interpolation, the user will never see that myObject rotated momentarily to its end position.
          • 2. Re: Rotation issues
            Mazuho Level 1
            Thanks again!
            Is there something special to think of when interpolating an object two times? As it is now I have put the rotation interpolation and the movement interpolation in the same handler, and it seems as they don't work together just like that. Should I put them in separate handlers or something? Now they are both called on exitframe. Thanks for all your help.
            • 3. Re: Rotation issues
              James Newton, ACP Level 3
              When you use interpolate(), Director chooses shortest path. This may not be the most natural. If you need more precise control of the movement, then I think that you will need to come to terms with the 3D mathematics involved, and build the animation yourself.

              It sounds that you are trying to get the object to travel along the direction in which it is facing, so that it arrives at its end point after describing a curve. It would be much easier to make the object rotate on the spot, then travel in a straight line (think RoboCop). The more complex alternative is to precalculate the curve, say using a bezier, then work out on each frame how far the object will have travelled along the curve, and so what its new rotation and position will be.

              Here are a couple of examples of pre-calculated Lingo-controlled animations: Light a match and Fold a mesh