Powering up a reactor using nDynamics - Part 1: Plasma core

Uploaded by MayaHowTos on 17.07.2012

nDynamics in Maya let you create realistic motion and effects that are hard to achieve with traditional keyframe animation.
It does this by simulating the effect of gravity, wind, and other forces in your scene, and moving or deforming objects accordingly.
Simulated objects can also collide with each other to produce even more complex behaviors.
In this movie, we'll look at how to use nParticles to generate the plasma core that powers this reactor.
Open the file 'Plasma_core_reactor_part1_start.mb'.
This scene features two animated turrets that are activated once the plasma core has produced sufficient energy.
Open the Preferences window and in Settings > Time Slider, make sure that Playback speed is set to Play every frame.
This forces Maya to evaluate every frame during a simulation rather than skip a few in order to maintain a specific frame rate.
Skipping frames during a simulation can impact its results since each simulated frame depends on the one before it.
Set Max Playback Speed to Real-time [24 fps] to limit the simulation's maximum speed to 24fps.
From the nDynamics menu set, detach the nParticles > Create nParticles menu.
Before we create our nParticles, let's pick an nParticle style as a starting point for our simulation.
These styles act as presets for the nParticles' properties and shaders to look and behave a certain way.
For example, the Balls style applies more bounce to your nParticles than the others,
while the Water style better simulates how a liquid flows.
Refer to the Maya documentation for a complete comparison list between these nParticle styles.
Since the plasma will be mostly gas, either the Cloud or Thick Cloud styles will do.
Cloud uses standard Blinn shaders on the nParticles, while Thick Cloud uses fluid shaders.
Fluid shaders provide richer shading than Blinn, but due to their complexity, they tend to run much slower.
For the scope of this tutorial, let's pick Cloud.
Go to Create Emitter [options], and name the emitter 'plasma_emitter'.
Set Emitter type to Directional and Rate (particles/sec) to 50.
In Distance/Direction Attributes, set DirectionX to 0, DirectionY to 1, and Spread to 0.1.
In Basic Emission Speed Attributes, set Speed to 10, and then click Create.
Move the new emitter object in the Y axis so it's near the opening of the bottom reactor chamber.
In the Outliner, notice the new nodes that define the nparticle system:
The Nucleus solver, representing the engine that does all necessary calculations for each frame of the simulation.
The nParticle emitter, which maintains the overall flow of nParticles.
And the nParticles object itself, which houses the properties of the individual nParticles. Rename this node to 'plasma_nParticle'.
We'll come back to the nParticles shortly to change their look and physical characteristics.
To have nParticles come out of both the top and bottom reactor chambers,
we could create an additional nParticle system for the top chamber.
However, that would mean each time we made a change to one, we'd have to reconfigure the other, which is a bit redundant.
Instead, we'll emit the same nParticles from two different emitters.
Delete the extra nParticle object so you're left with its emitter only.
Select the plasma nParticles node, then the new emitter, and go to nParticles > Use Selected Emitter.
Now rewind and play the simulation to see both emitters output the same nParticle object.
Change the new emitter's DirectionY attribute to -1 so its plasma streams downwards,
and then position it inside the top chamber's opening.
Now let's configure the nParticles' properties to achieve the desired plasma core effect.
Select the plasma nParticles node and in the Attribute Editor, navigate to the 'plasma_nParticleShape' tab.
You can also access this shape node directly from the Outliner if you enable Display > Shapes.
To ensure that the nParticles don't stay onscreen forever, we need to kill them once they reach a certain age.
In Lifespan, set Lifespan Mode to Random range, with a Lifespan value of 2.5 seconds and Lifespan Random value of 0.5 seconds.
Next in Particle Size, set Radius to 1.5 so the plasma fills the reactor chamber openings.
We don't want all our plasma core nParticles to be identical in size, so let's introduce a little variety.
Click the Radius Scale ramp twice to place markers at the middle and end points of the ramp. Set their values to 0.5 and 0.4, respectively.
Notice the nParticles now scale down in size the more they age.
This is because the Radius Scale ramp connects to the per-particle radius attribute on the nParticle node.
The Radius Scale Input attribute below drives this ramp.
We could control each nParticle's size using its speed, particle ID, or even a custom expression.
Lastly, set Radius Scale Randomize to 0.2 to add some scale variation to the mix.
In Dynamic Properties, notice that Ignore Solver Gravity is enabled when Ignore Solver Wind is not.
These attributes are set by the Cloud nParticle style we picked earlier.
This ensures that the Nucleus solver's wind force can affect the nParticles, while its gravity force can't.
You can toggle Ignore Solver Gravity to see the gravity force applied to the nParticles. However, for this tutorial, let's leave it turned on.
To add some volume to the plasma core, we'll use a passive collider,
which is a non-simulated nucleus object that the Nucleus solver evaluates during a simulation for collision detections only.
Any polygon object can be converted into a passive collider. Here, go to Create > Polygon Primitives > Sphere [options].
Set Radius to 3 and click Create. Rename the new sphere 'plasma_volume_geo'.
Set its Translate Y value to 15 to place it in between the two plasma emitters.
With the object selected, go to nMesh > Create Passive Collider.
The new nRigid node represents the passive collider sphere. Rename it 'plasma_volume_nRigid', and then play the simulation.
The plasma nParticles collide with the volume sphere, which is unaffected by the simulation.
Our next step is to wrap the nParticles around the volume sphere.
For this, we'll generate a force field from the volume sphere that can either attract or repel simulated objects within range.
In Force Field Generation, set Force Field to Single Sided to pull in the nParticles towards each of the sphere's faces.
Set Field Magnitude to -10 to create a negative force that attracts nParticles,
and set Field Distance to 15 to extend its reach to all nearby nParticles.
The plasma nParticles now stick to the sphere, but they are not really wrapping uniformly around it.
This is because both the nParticles and the volume sphere
have friction properties that add a bit of unnecessary resistance to the simulation.
To fix this, go to Collisions and set Friction to 0. Do the same for the nParticle object.
If you hide the volume sphere, you'll see the plasma core starting to take shape.
To spin the nParticles around the volume sphere, let's assign them a Vortex field.
Select the plasma nParticles object and go to Fields > Vortex. Rename the new field 'plasma_vortex_field'.
Set its Translate Y value to 15 to position it in the middle of the plasma core, then in Vortex Field Attributes, set Magnitude to 50.
Rewind and play the simulation. The nParticles now spin around the volume sphere, creating our plasma core effect.
Let's open the Hypershade to take a look at the nParticles' shading network.
With the nParticles selected, go to Graph > Graph Materials on Selected Objects.
When you create an nParticle system, Maya automatically builds a shading group based on the current nParticle style.
This shading group is comprised of a surface material and a volume material.
In both these materials, the color, transparency, and incandescence attributes
are driven by the nParticles themselves via the particleSamplerInfo node.
For more details on using the particleSamplerInfo node, see part 2 of our interoperability movie between Maya and Softimage.
In the Shading section of the 'plasma_nParticleShape' tab,
the Surface Shading attribute determines the blending between the surface and volume materials.
Set it to 0.5 to get an equal mix of both.
Set Threshold to 0.5 to fuse together nParticles that are close to each other, and set Opacity to 0.75 so we can partially see through them.
Next, update the Color ramp to match the following. Make sure you set the color model to RGB rather than HSV.
Set Color Randomize to 0.25 to get more color variation.
By default, the nParticles' incandescence is set to black, which means they have no self-illumination.
This attribute drives the incandescence value of both the surface and volume materials.
To get a distinct look for the plasma core, double-click the connection between the "particleSamplerInfo1" and "npCloudBlinn" nodes.
In the Connection Editor, select the outColor attribute on the Outputs list. This connects to the color attribute on the Inputs list.
Select the incandescence attribute below it and close the Connection Editor.
Now the nParticles' Color ramp drives its surface material's color and incandescence.
While the nParticles' Incandescence ramp only drives its volume material's incandescence.
To add an extra bit of illumination, set the Glow Intensity to 0.1 for both surface and volume materials.
The plasma core now shines brightly as it produces enough energy to activate the defense turrets.
In the next movie, we'll simulate a force field to protect this plasma core from incoming attacks.