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

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

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

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

Adobe Creative Team

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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











  • Electricity


    In the world of special effects, one of the most exciting tasks is simulating electricity. Whether it's in short-circuiting robots, Matrix-style ship propulsion, or downed power lines, electricity has a power to fascinate and induce fear, and this power can be exploited with great flexibility using Particle Flow. The primary electrical effect we will explore in this scene is a series of lightning strikes.

    Triggering Lightning with Scene Objects


    In this section, we will create a quick lightning strike, which will be triggered by the near-collision of objects within the scene. The technique used to trigger this lightning bolt is straightforward and could easily be expanded into any application where scene objects need to control particle effects, such as sparks flying from two colliding heavy objects.


    1.

    Scrub the Time Slider and note that the biplane's path takes it near the two vertical lightning bolts. These meshes will serve as helper objects in this exercise, to guide the generation of particle lightning. The trigger for these two bolts of lightning will be movement within the scene, specifically the approach of the biplane. A spherical deflector will be attached to the biplane, and its collision with the particle source icons will trigger the effect.

    Note

    One straightforward method for triggering or influencing particles from scene objects is a collision test.

    2.

    Go to a Top viewport and create an SDeflector space warp (found in the Create panel > Space Warps > Deflectors > SDeflector) with a diameter of 70,000 units (Figure 18.10). The initial location of the space warp is not important.

    Figure 18.10. A simple spherical deflector will be used to trigger the lightning.

    [View full size image]

    3.

    Align the deflector with the Plane group, with each of its World axis positions and Local axis orientations (Figure 18.11).

    Figure 18.11. Align the deflector with the biplane.

    [View full size image]

    4.

    Use the Select and Link tool to link the deflector to the Plane group. Scrub the Time Slider to observe that the deflector follows the biplane's position and orientation throughout the animation.

    5.

    In Particle View, create an Empty Flow and a birth event, renaming the source event Lightning01 and the birth event Lightning Birth01. Wire the two events together.

    6.

    In any viewport, select the Lightning01 source icon and Align its X axis, Y axis, and Z axis pivot points to the pivot point of lightning geometry01. Do not align on any axis of orientation.

    7.

    To make the icon more visible in the Camera viewport, go to the Modify panel and set the icon's length and width to 6000 units (Figure 18.12).

    Figure 18.12. Align the lightning particle emitter with the lightning helper object.

    [View full size image]

    8.

    Set the Viewport Quantity Multiplier to 100%. There is not much performance gain to be had here, as the lightning effect will be produced with a relatively small number of particles.

    9.

    In the Birth operator, set the system to generate a single particle at frame 0.

    10.

    Append a Position Icon operator and specify Pivot as the Location. This single particle will wait to be triggered by the biplane's spherical deflector.

    11.

    Append a Collision Spawn test, and add SDeflector01 to the Deflector list (Figure 18.13).

    Figure 18.13. The lightning particle flow begins with a single particle, waiting for a collision to trigger the effect.

    [View full size image]

    12.

    Create a new Shape Instance operator below the Lightning Birth01 event, renaming the new event Lightning Main Bolt01. Wire the new event to the Collision Spawn test.

    13.

    Specify lightning geometry01 as the Particle Geometry Object, and turn on Animated Shape.

    14.

    To preview the shape in viewports, change the Display type to Geometry.

    If you scrub the Time Slider in the Camera viewport, you will see the instanced lightning mesh spawn around frame 35 and then proceed out of the frame to the left. This is because of a speed setting in the Collision Spawn test (Figure 18.14).

    Figure 18.14. The Collision Spawn test's default settings will bounce the lightning bolt away from the deflector.

    [View full size image]

    15.

    Under Speed, set Offspring to Continue, so that it will not be deflected by the collision. In this way, the deflector acts as a trigger without changing the particle's speed or direction.

    Now when the Time Slider is scrubbed, the lightning bolt remains, and animates, at the source icon's location. The particle's animation, however, does not match the helper's. This is because the age of the spawned particle doesn't match up with the animation frame number (Figure 18.15).

    Figure 18.15. The particle lightning bolt's animation does not sync with that of the helper object.

    [View full size image]

    16.

    To correct this problem, clear the Restart Particle Age check box in the Collision Spawn test so that the spawned particle will inherit the parent particle's age.

    17.

    In the source icon's System Management rollout, set the Render Integration Step to 1 Tick. This will cause the particle evaluation to be updated for renders at the same rate as that of the animated helper object, at the cost of additional computational time.

    18.

    This bolt only needs to be displayed for a very short time, about a third of a second, so append an Age test to the Lightning Main Bolt01 event to test Event Age against a Test Value of 10 frames, with a Variation of 0.

    19.

    Create a new Delete event below the Lightning Main Bolt01 event, rename it Lightning Delete01, and wire it to the Age test. Delete the unneeded Display operator. Note that, in this setup, it is not possible to use a Delete By Particle Age operator because the particle's age has not been reset, and it would already be greater than the test value by the time the test was evaluated (Figure 18.16).

    Figure 18.16. The main lightning bolt flow with Birth, Collision Trigger, and Delete By Event Age.


    At this point in the tutorial, the main bolt of lightning has been set up to be triggered by the biplane's approach and to last for just a fraction of a second. We will continue in the next section to enhance the lightning itself.

    Branched Lightning


    To make the lightning appear more complex, we need to duplicate the instanced lightning bolt along the length of the original. This will create a random branching effect. Placing particles along the surface of an instanced geometry particle is not possible in Particle Flow without heavy scripting, so the helper lightning mesh will be used again. This is why the syncing of the particle and the helper in rendering is so importantwith a render integration step larger than 1 Tick, the branching bolts would not connect properly with the main bolt.


    1.

    Insert a Spawn test just before the Age test. Set it to generate 12 Offspring, and set Variation to 20. Once again, the Restart Particle Age check box needs to be cleared to keep the animation in sync.

    2.

    Copy the Shape Instance operator into a new event, and rename the event Lightning Branch01.

    3.

    Reduce the Scale in the new Shape Instance operator to 30%, and set Variation to 50%.

    4.

    To place the branching bolts along the main one, add a Position Object operator. Turn on Lock On Emitter, and add lightning geometry01 to the list of Emitter Objects.

    5.

    Also turn on Animated Shape and Subframe Sampling.

    6.

    To have branching bolts emitted only from the points along the main bolt where the geometry turns, change Location to Vertices.

    7.

    Change the Display type to Geometry. If you scrub the Time Slider, you will see smaller bolts spawn along the length of the main one. They may appear to be disconnected, but keep in mind that their placement will sync up in renders (Figure 18.17).

    Figure 18.17. The branching bolts appear along the main bolt, spawning from random vertices.

    [View full size image]

    8.

    To orient these branches randomly, add a Rotation operator. The default Orientation Matrix Random 3D will randomly point the branches away from their emitter points.

    9.

    To cause the branches to die out when the main bolt does, clone the Age test, using Instance as the method, to the end of the Lightning01 Branch event. Making these operators instances allows the bolt duration to be changed easily from one operator.

    10.

    Wire the Age test output to the Lightning Delete01 event (Figure 18.18).

    Figure 18.18. The particle setup for the lightning bolt and branching bolts.

    [View full size image]


    At this point, the lightning bolt is set up to be triggered by the approaching biplane and to generate a branching electrical bolt (Figure 18.19). In the next section, we will add an electrical corona of sorts to simulate the charged particles that we imagine are generated by a powerful bolt of electricity.

    Figure 18.19. The branching-lightning-bolt effect.

    Expanding Electrical Field


    Once the lightning bolt is triggered, a field of charged particles will be emitted and will rapidly disperse. While this effect is perhaps not true to the visuals of real-life lightning, we are expressing the power and style of lightning in this tutorial, and so we'll explicitly create this effect.


    1.

    Insert another Spawn test into Lightning Main Bolt01, before the Age test. Set it to spawn 1000 offspring, and set Variation to 15%.

    2.

    Create a new event consisting of a Shape Facing operator, and rename the event Electrical Field01. Wire the new event to the Spawn test.

    3.

    Choose the Camera01 (not its target) as the Look At Object.

    4.

    Set the Size/Width to In Screen Space, using a 1% Proportion and Variation set to 20%.

    5.

    Before the particles show up, they must have a position set, so add a Position Object operator.

    6.

    Add lightning geometry01 to the list of Emitter Objects, and turn on Animated Shape and Subframe Sampling.

    7.

    To spawn the particles in a cloud around the bolt, turn on Surface Offset, and set the Minimum offset to 250 units and the Maximum offset to 1000 units.

    8.

    The particles need to rapidly disperse after spawning, so add a Speed operator. Set Speed to 5000 units, Variation to 3000, and Direction to Random Horizontal (Figure 18.20).

    Figure 18.20. The lightning bolt will now spawn a cloud of energetic particles.

    [View full size image]

    If you scrub the Time Slider, the particle field spawns in a cluster along the body of the main bolt and rapidly disperses along the World XY plane (Figure 18.21).

    Figure 18.21. A cloud of particles is emitted from an area surrounding the main lightning bolt and rapidly disperses.

    [View full size image]

    The final aspect of the dispersing particles to create is a fade effect. The particles will shrink and become less opaque as they disperse.

    9.

    Append a Send Out test to Electrical Field01.

    10.

    Create a new event consisting of a Material Dynamic operator, rename the event Fade Field01, and wire it to the Send Out test.

    11.

    Assign the material Lightning Corona. This material's opacity is keyed to particle age, becoming more transparent as the end of the particles' life span approaches.

    12.

    To shrink the particles as well, add a Scale operator, set its Type to Relative Successive, and set all three Scale Factors to 98%. This rescaling effect is the reason for separating the field fade into a separate event; otherwise, the Scale operator would conflict with the scale settings in the Shape Facing operator.

    13.

    To specify the particle's life span, append a Delete operator, set to delete By Particle Age, with a Life Span of 15 frames and a Variation of 5 (Figure 18.22).

    Figure 18.22. The completed lightning bolt particle setup.

    [View full size image]

    14.

    The lightning bolt will now display three distinct phases: the initial strike (Figure 18.23), the strike with electrical field (Figure 18.24), and the lingering electrical field (Figure 18.25).

    Figure 18.23. The first stage of the lightning bolt.

    Figure 18.24. The second stage, with electrical field.

    Figure 18.25. The third stage, with lingering electrical field.


    In this tutorial, care has been taken to keep the particle setup controlled parametrically. The triggering of the lightning could easily be changed to another time or another deflector, and every subsequent event would follow naturally.

    Particle Caches


    If you scrub the Time Slider through the triggering of the lightning bolt, you will notice a small hitch in the refresh rate due to the particle calculations involved. While this lag may be barely noticeable at this point in the chapter, as more effects are added, the delay will rapidly increase.

    There are several ways to manage this, including turning off particle flows (either through Particle View or the PF Source icon), reducing the Viewport Quantity Multiplier, reducing the percentage of particles visible through Display operators, and setting Display types to Dot or Tick wherever possible. The most effective method, however, while keeping particles active is a particle cache.

    The Cache operator stores the many calculations required by Particle Flow, so that when a scene is played back (in viewports, at render, or both), the stored values are used instead of being reevaluated.


    1.

    Return to the global Lightning01 event and append a Cache operator.

    2.

    Set it to be used at Viewport/Render and to update manually.

    3.

    To maintain sync with the settings in the source icon, set Sampling to Integration Step.

    4.

    Click the Update button under Manual Update.

    The Particle View window will disappear, and the scene will play through in the viewport from beginning to end, which will take a few moments. When the process is completed, all of the particle calculations necessary for the scene will be stored in the Cache operator. This will speed up the playback of this part of the effect.


    Note

    Unless Particle Caches are set to update automatically, they will not reflect future changes to the events they encompass, so be sure to update if the particle setup is changed.

    Now that the first lightning bolt has been tweaked and polished, let's create an identical bolt to be associated with the second helper bolt.

    Duplicating Particle Setups


    Given that a second vertical lightning bolt helper exists in the scene, it seems obvious that we should duplicate the lightning particle setup from the first lightning bolt. The modular nature of Particle View makes cloning particle setups pretty easy, after considering a few minor caveats.


    1.

    Select all seven events associated with the first bolt and clone them, using Copy as the method.

    Any of the test output handles that were repositioned from their default location will need be moved again, as this information is not conveyed with the cloning operation.

    2.

    Any references to lightning geometry01 will need to be updated to refer to lightning geometry02, specifically two Shape Instance operators and two Position Object operators.

    3.

    In the viewport, select the Lightning02 PF Source emitter and align its X-axis, Y-axis, and Z-axis pivot points to the pivot point of lightning geometry02 using the Align tool.

    If you scrub the Time Slider, both lightning effects will be triggered at the same moment, even though the deflector has not reached the second source icon. This is due to the Cache operator, which contains information about the frame at which the deflector triggered the first source icon. When you duplicated the Cache operator, the particle information stored in it was duplicated as well, and is being applied to the duplicate bolt.

    4.

    Select the Cache operator for the second lightning bolt and click its Update button. Once the update is complete, the second bolt should trigger around frame 130.

    5.

    Repeat steps 13 to create the particle setup for the third lightning bolt. The third bolt will work a little differently, so delete its Cache operator and Collision Spawn test (Figure 18.26).

    Figure 18.26. The duplicated lightning-bolt particle setups.

    [View full size image]

    It will not be necessary to update the caches again, unless changes are made to the events they cover. Note that the caches are empty when the file is reopened, unless Save Cache With File is checked. This option, however, can very quickly inflate file sizes.


    In this next section, we will further explore the use of scripts in Particle Flow to control the third lightning bolt.

    Triggering Lightning with Scripts


    A third lightning bolt is evident in the scene, one that follows the position of the biplane throughout the scene. This bolt will actually strike the biplane and spark an explosive reaction.

    Rather than using a collision trigger, we'll use a script to explicitly force the frame on which the lightning bolt fires. Particle scripting employs many of the same conventions and variables that are used in MAXScript, with the addition of parameters and controls for nearly every aspect of particles.

    Particle script operators are evaluated differently from other operators in that they are immediately examined at the beginning of an animation, even if they appear to be restricted to later evaluation due to an Age test, for example. Therefore, scripts need to take into account the possibility that they will be run before any particles have even been birthed or before the particles they are intended to operate on have arrived in the proper event.

    In addition, scripts are only evaluated at render time if they are located in an event that contains renderable particles, meaning at least one birthed particle with Render, Shape, and Position operators.

    Particle Flow scripts have a particle-specific focus on time. Controlling particle age within a script is very straightforward; however, accessing scene time is more difficult. The usual global variable for scene time, currentTime, will only be accurate during viewport playbacks. During renders, this global is not passed to Particle Flow. A typical workaround is to birth a particle at frame 0 and use its age for scene time.

    Initially, we will use a placeholder particle's age to track scene time and compare it against a specified frame for triggering the final lightning strike.


    1.

    Create a new Standard Flow, naming the global event Script Flow and the birth event Script Holder.

    2.

    Set this system to birth one particle at frame 0.

    3.

    The Speed and Rotation operators are unneeded, so delete them (Figure 18.27).

    Figure 18.27. A bare particle setup to support a particle script.

    4.

    To ensure that the particle does not appear in the scene, select the Script Flow PF Source icon and move it 20,000 units on its Z axis.

    5.

    Append a Script operator to Script Holder, and click the Edit Script button to open the Script Editor. The default script can appear intimidating, primarily because of the wide range of operations and variables allowed. The majority of the default script consists of commented lines, so any line beginning with "" is not an operational portion of the script.

    • The ChannelsUsed section refers to properties of the particle that will need to be passed to the script. The Speed of this particle is not significant, so delete the line pCont.useSpeed = true.

    • The Proceed section contains the basis of the script's operations. Delete the sample script, leaving only the leading and trailing parentheses.

    6.

    Replace the deleted script with the following text (Figure 18.28):


    persistent global StrikeFrame = 275

    Figure 18.28. A simple script to set the StrikeFrame variable.

    [View full size image]

    This declaration creates a variable named StrikeFrame and assigns it the value 275. Prefacing the declaration with the terms persistent and global will make this variable persist when the scene is reopened and make it accessible to other scripts in the scene. This is the point where you can specify on which frame the third lightning bolt will strike the biplane, triggering the explosion.

    Note

    The completed script is available as a text file on the accompanying DVD as lightning_strike_script_final.txt.

    7.

    To check your script for syntax errors, go to File > Evaluate All.

    8.

    Close the window to return to Particle View. It is not necessary to save the script; it is automatically stored in the Script operator.

    9.

    Return to the Lightning03 particle flow. Since the Collision test was deleted, there is nothing to trigger the effect at this point. Append a Script test to Lightning Birth03 and click the Edit Script button. Like the Script operator, the Script test operator contains a default test.

    10.

    Remove the lines specifying the Time and Position channels in the ChannelsUsed section and replace them with pCont.useAge = true so that the particle's age channel will be available to the test.

    11.

    Replace the sample script in the Proceed section with the following:


    if (pCont.NumParticles() > 0) AND (pCont.particleAge >
    StrikeFrame ) then
    (
    pCont.particleTestStatus = true
    )

    Tip

    Consider evaluating your script whenever you make changes, to check for simple typographical errors that might prevent your script from functioning properly.

    The first line of this test script contains a Boolean test, which will allow the rest of the script to execute only if both subtests pass. The first test requires that there be at least one particle in the flow, and the second test requires that the current age of the particle (which should be equal to the scene time) is greater than the value stored in StrikeFrame (Figure 18.29).

    Figure 18.29. A Script test to check that StrikeFrame has passed.

    [View full size image]

    If these subtests pass, then the test status is set to true, meaning that any particles passed to it will continue on to the event wired to the test's output. Now let's continue.

    12.

    Wire the Script test's output to Lightning Main Bolt03.

    13.

    If you render a still at frame 276, the third bolt can now be seen striking the biplane (Figure 18.30).

    Figure 18.30. The lightning bolt now strikes at the frame specified in the particle script.

    14.

    Clone the Cache operator from Lightning02 to Lightning03 and update the cache. Note that the script test results are cached as well, so if StrikeFrame is changed, then the cache will need to be updated or turned off before the new value is used.

    15.

    Feel free to hide the three lightning geometry helpers now to unclutter the display.


    In this section, we have used scripts and script tests to pass and evaluate a user-defined variable and control particle behavior. This is just one of many possibilities for explicitly defining event-driven particles with scripting. Any time you wish to accomplish something unusual with Particle Flow, such as particle rain clouds whose movement is synced with a shaman's dancing, consider particle scripting. In the next few tutorials, we will use the same script test to spark several explosive effects.


    • / 193