In the previous movie, we created a plasma core for this reactor using an nParticle system.
In this movie, we'll protect it with an nCloth force field, which will deform based on the core's pulsing.
Open the file 'Plasma_core_reactor_part2_start.mb',
which features an updated plasma core that expands and contracts procedurally using a MEL expression.
If you're uneasy with MEL script, you can instead opt to animate the passive collider's scale over time.
Feel free to jump ahead if you prefer to proceed that way.
Open the Expression Editor. Go to Select Filter > By Expression Name, and then click on the 'plasma_volume_scale' expression.
First, we calculate the cosine of time (in seconds), which returns a value between -1 and 1, as shown in this graph.
Then, we update the equation by changing the cosine wave's amplitude and frequency, as well as adding an offset to it.
This results in a compressed cosine wave, which means a faster scale animation,
with values ranging from 0.5 to 1.5 ensuring that the plasma volume never scales in negative values and turns inside out.
We store the output value in the variable $volumeScale,
which we use in the 'xform' command with the -s flag to alter the scale attribute of 'plasma_volume_geo'.
An alternative method to using MEL would be to set animation keys on the volume sphere's scale X, Y, and Z attributes.
For each resulting animation curve, set Post Infinity to Cycle to ensure that the animation loops for the entire length of the simulation.
Before we create this force field, let's cache the current nParticles locally.
With a cache, Maya doesn't have to simulate them every time, which will speed up performance.
Select plasma_nParticle, then from the nDynamics menu set, go to nCache > Create New Cache [options].
Reset the window settings, then make sure the Cache directory path is set to your current project
and that the Cache name reflects your selected nParticles. Click Create.
Maya evaluates the simulation and creates one cache file per frame for the specified Cache time range.
A new nCache node drives the nParticles' simulation data instead of the Nucleus solver.
To simulate a deformable force field around the plasma core, go to Create > Polygon Primitives > Cylinder [options]
Set Radius to 7.5, Height to 30, and Axis, Height, and Cap divisions to 30, 20, and 0, respectively.
Click Create. Rename the new cylinder 'forceField_geo'.
Set its Translate Y value to 15 to center it to the plasma core.
Notice the cylinder mesh's uniform topology, which helps reduce risks of polygon distortion during simulation.
Switch to Wireframe view, then go to Face component mode, and delete the top and bottom faces of the force field.
Let's also delete its construction history before we move on.
To convert the cylinder to an nCloth object, go to nMesh > Create nCloth [options].
You can either create a new Nucleus solver or attach the nCloth object to an existing one.
Simulated objects can only interact with each other if they share the same solver, so let's use the current solver.
Rename the new nCloth node to 'forceField_nCloth', and then play the simulation.
The force field falls down under the pull of the solver's gravity.
It also collides with the plasma nParticles and the passive collider since they all share the same Nucleus solver.
Note that the vortex field we created in the previous movie does not affect the nCloth force field.
To assign a field to an unaffected nucleus object, select the nucleus object, then the field, and go to Fields > Affect Selected Object(s).
Here, we'll leave the force field unaffected because we don't want it to spin around.
Instead, let's start by making the force field gravity-independent.
Navigate to the 'forceField_nClothShape' tab in the Attribute Editor, and in Dynamic Properties, turn on Ignore Solver Gravity.
Switch to X-Ray mode, then rewind and play the simulation.
We want the force field to act as a barrier strong enough to protect the plasma core without imploding.
To give the force field more structure, set its Rigidity property to 0.1.
While this may seem like a low value, it'll make sense later when we start deforming the force field.
As an added precaution, we'll anchor the force field using a Transform nConstraint.
Switch to Edge component mode and double-click an edge along the top border of the force field to select the edge loop.
Hold shift and double-click an edge along the bottom border.
With both edge loops selected, go to nConstraint > Transform.
This links the corresponding vertices, highlighted in green, to a Transform constraint locator,
effectively binding their position in XYZ space.
Rename the new nConstraint node 'forceField_transform_nConstraint'.
Let's test this dynamic constraint using Interactive Playback mode,
which lets you interact with objects in your scene as the simulation plays out.
Rewind the simulation, then go to nSolver > Interactive Playback.
Select the nConstraint and move it from side to side. Notice how the nCloth interacts with the plasma core.
When you're done, rewind the simulation and reset the nConstraint's Translate attributes to their original values.
Now that the force field is in place, let's deform it using a volume axis field so it follows the plasma core pulses.
Select the force field nCloth object, then go to Fields > Volume Axis. Rename the new field 'forceField_ripple_field'.
Set the field's Translate Y value to 15 and Scale X, Y, and Z values to 10 so it covers more than the force field's diameter.
In Volume Axis Field Attributes, set Magnitude to 200 and Attenuation to 1.
In Volume Speed Attributes, set Away From Center to 50.
Play the simulation using Interactive Playback and scale the field up and down to deform the force field.
In Volume Control Attributes, change Volume Shape from Cube to Sphere to match the plasma core's volume.
To create deformation ripples based on the plasma core pulses,
we need to constrain the field's scale to the passive collider currently hidden.
In the Outliner, select 'plasma_volume_geo', then 'forceField_ripple_field',
and from the Animation menu set, go to Constrain > Scale [options].
Make sure that Maintain offset is turned on, and click Add.
Finally, to make the force field nCloth object a bit more stretchable,
go to its Dynamic Properties and reduce both Stretch and Compression Resistance properties to 2.
This loosens up the force field and induces more ripples as the volume axis field deforms it.
Rewind and play the simulation once more. After an extreme deformation to start, the nCloth settles into a nice even pulse.
To fix this initial deformation, we can set animation keys on the volume axis field's magnitude
so it starts with a value of 0 and increases to 200 around frame 25.
Once you're done simulating the force field, it's a good idea to cache it like we did for the plasma core.
This way, Maya can render each frame without having to simulate it first, which will speed up the rendering process.
This scene file already contains a material for the force field, so right-click it and go to Assign Existing Material > forceField_mat.
If you inspect this material in the Hypershade, notice that the Transparency attribute is mapped to a 3D marble texture.
This marble texture determines what is visible on the force field.
It also connects to an animated 3D placement node, which gives the effect of travelling energy.
All that is left is to pick a camera angle and render the simulation.
This reactor is now fully protected from incoming attacks…at least for the time being.
Now that we've covered some of the concepts behind nDynamic simulations,
you can disable the nCache nodes we created and tweak the simulation attributes
to customize the look and feel of your reactor and force field.