Page 1233 - Kitab3DsMax
P. 1233

oldRt = fishObj.rotation.z_rotation
                                                      newRt = (in coordsys pathObj pathObj.rotation.z_rotation)
                                                      if ((random 1 100) > 85) then
                                                      (
                                                       fishObj.rotation.z_rotation += (newRt - oldRt) *
                                                       (random 0.5 1.5)
                                                      )
                                                     )
                                                    )                         Chapter 49: Automating with MAXScript
                                                 2. Save your script (File ➪ Save), and then press Ctrl+E to evaluate the script again. This script is
                                                    saved in the Chap 49 directory as FishPath2.ms. Make the Camera01 viewport active, and click
                                                    Play Animation. Figure 49.16 shows another frame of the animation. As you can see, the fish is
                                                    heading in the right direction this time, and the tail is flapping wildly.
                                                      FIGURE 49.16
                                                    A tail-flapping fish that faces the right direction as it follows the path






























                                             Okay, take a look at what changed. First, you added a variable to refer to the fish’s tail, so that it is easy to
                                             change when you add another fish. Also, you accessed the bend modifier of the tail and set its axis to 0,
                                             which corresponds to the X-axis. (You can try other values to see that it really does change the axis parame-
                                             ter in the rollout.)





                                                                                                                      1185
   1228   1229   1230   1231   1232   1233   1234   1235   1236   1237   1238