INSIDE 3DS MAX® 7 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

INSIDE 3DS MAX® 7 [Electronic resources] - نسخه متنی

Adobe Creative Team

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











  • More with PFlow Scripts


    Earlier in this chapter, you explored how to control particle emissions from scene interaction through collision with the biplane's linked spherical deflector, as well as how to control particles from a simple script test. In this section, the direction of control is reversed, with scene objects controlled from a script that you will create in Particle View.

    In order to gain increased flexibility in particle setup, it is important to be able to create influences in both of these directions. For example, if you want to trigger a troll to come out of hiding only when the last particle of a magical attack has faded, you could use a particle script, triggered by particle speed, to move the mesh troll in the scene.

    In the scene we're working with, you will use particle scripting to add a chaotic element to the biplane's trajectory at the moment of impact.

    Examine the "flight path" spline. This spline controls the path of the biplane through the scene. A spline vertex near the impact point has been selected, and is controlled, via the Linked XForm modifier, by a dummy object (Figure 18.51).

    Figure 18.51. A dummy object controls the portion of the flight path near the impact point.

    [View full size image]

    If you select the dummy object and go to the Motion panel > Assign Controller rollout, you will see that a Position List controller has been applied, with a Linear Position controller and a Noise Position controller.

    Examining the properties of the Noise Strength track (by expanding the Noise Position controller and right-clicking on Noise Strength) reveals that the X, Y, and Z strength values are set to 0, meaning that no noise effect is created (Figure 18.52). It is this Strength track that will be modulated within Particle Flow to create the impact movement.


    1.

    Return to Particle Flow, and open the script in the Script Holder event. The script to control the dummy's Noise Strength track will be inserted in the Proceed section, just after the StrikeFrame declaration line. The script is available as a text file, called lightning_strike_script_final.txt, on the accompanying DVD.

    2.

    Enter the following lines (not the commentary) into the script. It is recommended that you copy and paste the text from the provided text file, as even a single typo can render the script nonfunctional.


    RampUpFrames = 3

    The variable RampUpFrames contains the number of frames over which the effect will increase from zero to full strength.


    EffectFrames = 3

    The variable EffectFrames indicates the duration of the full-strength effect.


    RampDownFrames = 20

    RampDownFrames determines the number of frames set aside for the diminishing of the effect back down to zero.


    EffectStrength = 3000

    EffectStrength determines the maximum Noise Strength value.


    ProgressFrame = pCont.particleTime StrikeFrame

    ProgressFrame keeps track of how far into the Noise effect the script is progressing. Given the values assigned above, this value will increase from 1 to 26.


    if pCont.particleTime < StrikeFrame then
    $Dummy01.position.controller.NoisePosition.NoiseStrength =
    [0, 0, 0]

    If StrikeFrame has not yet been reached, keep the Noise Strength value at zero. To speed calculations before the lightning strike, this line could be removed (although if the Time Slider were moved directly from a frame occurring within the range of the script to the beginning, Noise Strength would not be reset, and the scene would begin playing with the strength set to a non-zero value).


    if (pCont.particleTime >= StrikeFrame) and (pCont.particleTime <
    (StrikeFrame + RampUpFrames + EffectFrames + RampDownFrames))
    then

    If the current frame is within the duration of the effect, then continue to the next conditional test.


    (
    if ProgressFrame <= RampUpFrames then
    (
    CurrentStrength = ((ProgressFrame + 0.1) / RampUpFrames) *
    EffectStrength
    $Dummy01.position.controller.NoisePosition.NoiseStrength =
    [CurrentStrength, CurrentStrength, CurrentStrength]
    )

    If the frame is within the ramp-up period, then modulate the effect strength over the total number of ramp-up frames. The 0.1 value is added to avoid a zero result.


    if (ProgressFrame > RampUpFrames) and (ProgressFrame <=
    (RampUpFrames + EffectFrames)) then
    (
    CurrentStrength = EffectStrength
    $Dummy01.position.controller.NoisePosition.NoiseStrength =
    [CurrentStrength, CurrentStrength, CurrentStrength]
    )

    If the frame is within the range of the full effect duration, then set the Noise Strength to the maximum value.


    if ProgressFrame > (RampUpFrames + EffectFrames) then
    (
    CurrentStrength = ((RampDownFrames - (ProgressFrame -
    RampUpFrames - EffectFrames) + 0.1) / RampDownFrames) *
    EffectStrength
    $Dummy01.position.controller.NoisePosition.NoiseStrength =
    [CurrentStrength, CurrentStrength, CurrentStrength]
    )

    If the frame is within the ramp-down period, then reduce the effect strength over the total number of ramp-down frames. The 0.1 value is added to avoid a zero result.


    )
    if pCont.particleTime > (StrikeFrame + RampUpFrames +
    EffectFrames + RampDownFrames) then
    $Dummy01.position.controller.NoisePosition.NoiseStrength =
    [0, 0, 0]

    If the current frame is after the total duration of the effect, then reset Noise Strength to zero.

    With this completed script, you will cause the dummy's position to change based on the timing of the lightning strike (Figure 18.53).

    Figure 18.53. This script modulates the dummy's Noise Position Strength track according to the lightning strike's timing.

    [View full size image]

    3.

    Close the Script Editor. If the editor fails to close or gives an error message, recheck the script for typos, misspelled variable names, and mismatched parentheses.

    If you scrub the Time Slider over the duration of the script's function, frames 275301, the dummy will jerk at the moment of the lightning strike, moving the biplane and its emitted particles as well.


    Figure 18.52. A Noise Position controller, with Strength initially set to 0, has been applied to the dummy.

    This script obviously only begins to explore the possibilities inherent in Particle Flow scripts. While the full range of scripting possibilities is beyond the scope of this chapter, more information can be found in the Scripting chapter in this book, as well as in the online MAXScript Reference (Help menu > MAXScript Reference).


    • / 193