Simulation of Cloud Formation using MAYA based particles
Advisor: Dr David Ebert
Associate Professor
Ruchirgatha
Masters' Project
Department of Computer Science and Engineering
University of Maryland, Baltimore County
1000, Hilltop Circle, Baltimore, Maryland - 21250.
Abstract
The high complexity of the real world makes it difficult to realistically
simulate it. The project aims at modeling and simulating the formation
of clouds using Maya's particle systems. Particle systems are used due
to their analogous nature to bubble packets. Bubble packets (hence particles)
rise up in air due to convection. The model tries to incorporate various
physics based parameters, through controls set on the particle characteristics
and their path of motion. Mainly vortex, gravity and wind effects have
been introduced to trace the motion of bubbles. The bubbles aggregate to
form the cloud.
Various methods were tried to incorporate volumetric rendering. However
the tradeoff of time
versus the volumetric effect is too high. This has currently limited
this approach to surface texture based particles.
Introduction
Simulation of realistic cloud formation is a challenging research area in computer graphics. This is due to its computationally intensive nature in the case of scientific based modeling. The high complexity and topographical subtlety found in nature, makes it a very tough area to model realistically.
Ebert [*] introduced a powerful and flexible new approach in this area, which combines volumetric procedural modeling with the use of implicit surfaces. This technique can render clouds volumetrically and so it is possible to seamlessly enter the cloud and move through it.
The technique suggested by Ebert[*] is a two step modeling approach and has been modified in this project to incorporate MAYA and its utilities. The project aims to develop new cloud formation techniques. The first step uses particle systems to model and animate the formation of clouds. The particles are emitted and their movement tries to trace the movement of bubbles emitted during natural cloud formations. The number and size of the bubbles formed depends on the moisture content of air, land temperature and atmospheric pressure at that time. The particles stabilize at certain heights according to atmospheric conditions. However the sub structures within the cloud still have energy and are in constant flux. This substructure can be modeled through turbulent fields, rotation & revolution of molecules. Once the movements and shape of large level clouds are decided, we can attach either textures or implicits to the particles and model the volume using procedural techniques. Realism will be enhanced by the use of turbulence and noise functions.
We could incorporate physics based knowledge for simulation of cloud
structure and formation into this model. However the trade off between
visually convincing depiction and physically accurate models has to be
kept in mind.
Previous Work
The concept of particle systems is central to this project. This concept was introduced by Reeves [*] in 1983. It introduced the concept of modeling an object as a cloud of primitive particles that define its volume. Particles can be created and the parameters for them may be varied. This leads to increased realism of different objects according to the natural characteristics of the different objects. The particle parameters are listed below.
Another approach suggested in 1983 by Voss[*], suggested modeling clouds and rendering them as fractally generated densities with a series of plane parallel models. This approach had the advantage of being faster however it does not realistically simulate cloud development, instead it tries to achieve shapes close to the cloud shapes. Densities bounded by analytic functions have also been used to define cloud shapes ( Max N[*]). Gardener[*] approached the problem of simulating clouds with the help of quadric surfaces in 1984. Quadric surfaces are used to model a single natural scene feature - for example a tree or a cloud. This leads to a reduction in the number of scene elements and hence the complexity of the scene. The texture patterns can be mapped onto quadric surfaces to make the surfaces seem more realistic. Thus get the curved surface at the first stage. In the next stage the shape is remodeled better and then the texture is mapped together with modulation of surface shading. This makes the texture look more realistic. This concept combined geometric databases with texture databases. However such scenes can not support "walk throughs" for the scene. This is due to the fact that this level of granularity is not volumetric in nature. He (Gardener[*]) then built up on his previous approach by modeling different types of clouds, thus a comprehensive model for visual simulation of clouds was built. Cloud development could be horizontal or vertical according to the atmospheric conditions. The cloud model is composed of the following three building blocks: sky planes, ellipsoids and a mathematical texturing function which uses the approximation of Fourier's series from four up to seven sines (sin). It also adds randomness in it by adding phase shifts to the terms. The main disadvantage of this approach remains its two dimensional nature.
Kajiya et. al[*] suggested the approximate solution for the three dimensional radiative scattering equation as a new method in comparison to the single scattering for illumination purposes. Thus the new algorithm ray traces objects represented by densities within a volume grid using the above said new scattering equation approximation. These techniques allow the application of ray tracing to Reeves'[*] particle systems as well. The rendering procedure is separated into two steps. The first step drives the radiation from a light source into an array, which holds the contribution of each light source to the brightness of each point in space. The second step occurs once per ray trace. Each ray is first culled against a bounding rectangular prism as an extent, thus the brightness of the ray sums the contribution of each volume element. The cloud model for generating density functions is as following: the process of cumulus convection is numerically modeled, thus generating three - dimensional optical density functions. This model has nine equations to incorporate the equation of motion, continuity, condensation and evaporation. Convective motion of the atmosphere, latent heat of vaporization of water and frictional effects are considered approximately. Thus the cloud can realistically evolve with time.
Gaseous motion modeling was suggested by Stam et.al. [*], it modeled perceptually convincing depiction of smoke, steam, mist and water reacting to a turbulent field. This approach requires interlocking models for turbulent fields, gaseous flows and realistic illumination. The behavior can be modeled at two scales - large scale behavior based on the deterministic component and small scale behavior based on the stochastic component. An "advection - diffusion" model is used to animate the particle system based gas embedded in a wind field. Gases are modeled as density distributions of particles. The "advection - diffusion" equation is solved by modeling the gas particles as fuzzy blobbies with time varying parameters.
Ebert[*] combined the traditional volumetric procedural models with implicit functions to create a model that has the advantages of both techniques for modeling realistic clouds. This technique can be applied to some other gaseous phenomena's also. Implicit functions have been used for creating solid objects and smoothly blended surfaces. The volumetric cloud model has two levels. At the high level is the cloud macrostructure, it is modeled by the implicit functions. At the lower level is the cloud microstructure, it is modeled by the turbulent volume densities. This allows the procedural simulation of natural detail to the level needed. Simple mathematical functions are added to allow shaping of the density distributions and control over the sharpness of the density falloff. The implicit primitives are volume rendered as a semi transparent medium. The implicit density functions are primitive based density functions.
Foster[*] modeled hot gas motion introducing the turbulent rotational movement of the gas molecules, thus introducing swirling, rolling, billowing and gusting effects. It introduces a physics based model specifically designed to realistically animate the complex rotational component of gaseous motion, effects due to regions of different temperatures within a gas, and interaction between gases and other objects are taken into account. The developed model approximates for the following: convection, turbulence, vorticity and thermal buoyancy. It can also accurately model gas flowing around objects. A volume of gas is represented as a combination of a scalar temperature field, a scalar pressure field, and a vector velocity field. The motion of the gas is then broken into the following two components. Firstly the convection component due to Newton's laws of motion. Secondly the rotation and swirling due to drag and thermal buoyancy. The Navier-Stokes equation is approximated for the rotational motion, buoyancy and convection, also the components which cause mixing due to temperature differences are added. This coupling provides realistic rotational and chaotic motion for a hot gaseous volume.
Neyret[*] went a step further in realistic cloud formation simulations
by incorporating many atmospheric physics based phenomena's to closely
approximate the simulation of cloud development for convective clouds.
He states that the shape of a convective cloud can be considered as a surface,
hence detailed information is required only within the periphery of the
cloud volume. Atmospheric physicists characterized many specific structures
appearing in fluid phenomena.
Some of these that have been incorporated into this model are:
Background on Clouds
Clouds are comprised of visible ice crystals and/or water droplets suspended in air. Clouds can be classified as:
Proposed Model
The proposed model for cloud formation incorporates the effects of gravity and emission of cloud bubbles from an area rather than a point through the use of multiple emitters. Another approach to simulate the above stated effect could be through the use of a single emitter whose position maybe decided by the user. Thus the user may decide the area from which the particle (bubble) emission is taking place. The cloud bubbles path of movement is typically swirling (amount of swirl may be adjusted by the user) through the use of vortices. Cloud bubbles themselves act as vortices once the cloud is formed - this has been incorporated through the use of a vortex. The size of the particle grows as the height increases. After a certain radii, the bubble may either split or still grow till a maximum specified by the user. In case the bubble splits the number of particles it will split into are randomly variable but the maximum may be five at a time. Visibility of the cloud bubble is determined according to the height. The height may be either specified by the user or may be determined from surface temperature conditions as a bubble rises approximately one kilometer for every four degree Celsius (or it may be defaulted). Opacity of the particle increases randomly per particle after the height at which visibility is attained. However there is variability among the particle characteristics in terms of both radius (size), opacity, and height at which visibility is attained.
In these simulations, incorporation of certain specific structures such as instability, bubbles, columns, turrets, vortices, and Bernard cells has been done. Theoretically it is based as follows, the bubbles are generated on the ground. They are distributed on the ground. We can have the user specify the area and the humidity level and that can be used to decide the number of bubbles generated. The user can decide the area by the placement of the emitter and its spread. Then the bubbles rise due to the force generated by the difference in the temperature. While rising their weight as well as the force of gravity has some effect on them. The vortex field comes close to simulating the movement of bubbles in air, so it has been used to define the path of the bubbles. At some altitude depending on the surface temperature, the number of dust nuclei at that height and the humidity content, condensation takes place, so the hot steam cools off and can be now seen as cloud particles. The user can also explicitly specify the height at which the stabilization and the aggregation of the bubbles occur to form the cloud. A bubble may be replaced by a particle, which has several attributes such as position, radius, opacity, velocity, and lifetime. By generating new particles and moving particles according to their speed, a high level structure of a cloud can be obtained. The control on the particles' movement and the number is crucial to the type of cloud that we want to form. These three parameters can actually change one type of cloud into another. The basic high level procedure is listed below.
Algorithm Outline:
Produce bubbles from emitters with radius, position, opacity and speed
incumbent upon it
Increase radius variably
If radius increases more than maximum set limit then split the bubble
Produce new "child bubble" and initialize the new bubble's
Implementation Details
The experimental method used in this project used Maya and its functions to write programs in MEL (Maya Embedded Language) to simulate the shape and movement of clouds incrementally. The process may be divided into the modeling and the rendering part. For previewing the results the Maya renderer was used. For the final results surface based textures were mapped onto the particles.
The first simulation used spheres as primitives to model the cloud with cloud textures attached to the sphere. Hence these spheres were more of surfaces and not volumetric clouds in nature.
The second simulation used a single emitter and equations were chalked out for the particles' velocity, path, radius and opacity. The software rendered cloud volumes replaced the point particles. Air and gravity fields were introduced to influence the position and velocity of the particles. Each particle had a dynamic weight associated with it as well.
The third simulation used multiple emitters and multiple vortex fields for the particles. This simulation was coded in MEL. The particles were again the software cloud particles provided by Maya. The radius and opacity and velocity of the particles varied randomly within set limits. Turbulence, vortex and gravity fields were used to influence the particles as well. The volume shader was used together with the particle cloud texture to render out the animation.
The fourth simulation had the new property of splitting up of the cloud bubbles should their size grow more than a set size. It was an incremental step over the third simulation and fully coded in MEL.
The graphical user interface was also set up using MEL - parameters allowed for user selection included:
Number of frames in animation
Maximum particles in the cloud
Rate of emission of particles
Placement of emitter
Placement of vortices
Placement of turbulence
Weight of each particle approximately
Magnitude of gravity
Magnitude of vortex
Magnitude of turbulence
Frequency of turbulence
Maximum radius of a particle in the cloud
Maximum opacity of a particle in the cloud
Maximum incandescence of a particle in the cloud
Threshold for the particle blobs
Type of cloud
Surface Temperature
Humidity
Stabilizing Height
Results
Conclusion
Particle Systems may be used very effectively to simulate certain natural phenomena. They are best used when they have an analogous mechanism in nature. Hence their efficacy in modeling cloud formation and development.
Future work
For the rendering part various methods were tried before deciding to stick with the surface based textures due to the tradeoff between time and complexity. Volumetric rendering may be accomplished by replacing each particle by a sphere. Varying the transparency of each point within or on the sphere based on random noise and turbulence functions makes the spheres look more realistic as clouds. Thus volume rendering for clouds constructed with 300-500 particles, this method is unrealistic. However if we make either the particle radii quite small or decrease the number of particles while increasing the radii, the tradeoff might change. Thus the level of detail required may be used to incorporate whether rendering of the cloud volume is more necessary or that of the whole cloud and its shape. This could be looked into in the future. Another method could be to make the particles really small and increase the number of particles - now fly throughs would be possible even though the cloud is still surface based.
Also multiple emitters did not end up working in Maya. Probably due to multiple particle sets processing concurrently, the buffer space ended up getting full and so the naming convention would not work. This also could be looked into in the future as it will provide greater flexibility in simulating the rise of bubble packets.
Acknowledgments
I would like to thanks Dr. David Ebert for his helpful comments and guidance. Dr Dan Bailey for helping me out with some of my queries with Maya. No report would be complete without an acknowledgement to my family, especially my parents for their love, constant encouragement and support.
References
[1] "Particle Systems - a technique for modeling a class of fuzzy objects
"- William T Reeves
Computer Graphics Vol. 17 No 3 July 1983.
[2] "Fourier Synthesis of Gaussian fractals: 1/f noises, landscapes
and flakes" - Richard Voss -
SIGGRAPH 83 Volume 10.
[3] Max N - Panel on simulation of natural phenomena - SIGGRAPH 83.
[4] "Simulation of natural scenes using textured quadric surfaces" -
Geoffrey Y Gardener - july
1984 Computer Graphics Vol. 18 No 3.
[5] "Ray tracing volume densities" - James T Kajiya, Brian P. Von Herzen
-july 1984 Computer
Graphics Volume 18 No 3.
[6] "Visual simulation of clouds" - Geoffrey Y Gardener - july 1985 SIGGRAPH Vol. 19 No 3.
[7] "Turbulent wind fields for gaseous phenomena" - Jos Stam and Eugene
Fiume
-SIGGRAPH93 proceedings Volume 27 August 1993.
[8] "Volumetric modeling with implicit functions" - David S Ebert -
SIGGRAPH 97
proceedings Aug. 97.
[9] "Modeling the Motion of Hot, Turbulent Gas" - Nick Foster and Dimitri
Metaxas,
Proceedings of SIGGRAPH '97.
[10] "Qualitative simulation of convective cloud formation and evolution"
- Fabrice Neyret -
Eurographics Sep. 97.
[11] Official A/W MAYA page - http://www.aw.sgi.com/entertainment/index.html
[12] MAYA based LUMIS page - http://www.lumis3d.com/
[13] MAYA based QueenMaya magazine - http://reality.sgi.com/tkluyskens_aw/txt/queen.html
[14] Clouds: PSC Meteorology Program Cloud Boutique Web page -
http://vortex.plymouth.edu/cloud.html
[15] Clouds: UIUC Cloud Catalog - http://covis.atmos.uiuc.edu/guide/clouds/
[16] Clouds: NCSA Digital Information System Overview -
http://www.ncsa.uiuc.edu/ SCMS/DigLib/text/
[17] Clouds: `The science of the clouds' [by] R. A. R. Tricker: New
York: American Elsevier
Pub. Co. 1970.
[18] Clouds: `Storm and cloud dynamics' [by] William R. Cotton, Richard
A. Anthes: San Diego:
Academic Press, 1989.
[19] Clouds: `Cloud Dynamics' [by] Robert A. Houze, Jr.: San Diego: Academic Press, 1993.
Appendix
/******************************************************************************/
// Creation Date: 30 March 1999
// Author: Ruchirgatha
// Description:
// This script creates GUI & code for the formation of clouds.
//
// Input Arguments:
// None.
//
// Return Value:
// None.
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// BEGIN //////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
global proc cloud()
{
waitCursor -state on;
string $window = "cloudWindow";
if (!`window -exists $window`)
makecloudWin($window);
showWindow $window;
waitCursor -state off;
}
//
//
global proc makecloudWin(string $window)
{
// string $radiusSlider;
// string $Position;
// float $height_temp;
window
-title "Cloud"
-iconName "Cloud"
-titleBar true
-minimizeButton true
-maximizeButton false
-sizeable true
$window;
columnLayout -rs 5 -cw 5 -adjustableColumn true;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// GENERATE CLOUD //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
floatSliderGrp
-l "Length (frames)"
-field true
-s 1
-v 10
-min 10
-max 1000
-pre 0 framesToGrow;
floatSliderGrp
-l "Maximum particles"
-field true
-v 100
-s 1
-min 1
-max 300
-pre 0 maximumClouds;
floatSliderGrp
-l "Growth rate"
-field true
-v 50
-s 0.1
-min 0.01
-max 500
cloudEmissionRate;
floatSliderGrp
-l "No of Emitters"
-field true
-v 1
-s 1
-min 1
-max 1
cloudEmitterNum;
floatFieldGrp
-l "Emitter Pos XYZ"
-numberOfFields 3
-value1 0.0
-value2 0.0
-value3 0.0
ePos;
floatSliderGrp
-l "VortexB Mag"
-field true
-v 25
-s 1
-min 1
-max 100
cloudBottomVortex;
floatFieldGrp
-l "VortexB Pos XYZ"
-numberOfFields 3
-value1 0.0
-value2 0.0
-value3 0.0
vBPos;
floatSliderGrp
-l "VortexT Mag"
-field true
-v 65
-s 1
-min 1
-max 100
cloudTopVortex;
floatFieldGrp
-l "VortexT Pos XYZ"
-numberOfFields 3
-value1 0.0
-value2 45.0
-value3 0.0
vTPos;
floatSliderGrp
-l "Weight"
-field true
-s 0.01
-v 0.05
-min 0.01
-max 5
-v 0.1 cloudWeight;
floatSliderGrp
-l "Gravity"
-field true
-v 10
-s 0.1
-min 0
-max 100
cloudGravity;
floatSliderGrp
-l "Turb Mag"
-field true
-v 4
-s 0.1
-min 0
-max 200 cloudCurlMagnitude;
floatSliderGrp
-l "Turb Freq"
-field true
-v 0.2
-s 0.01
-min 0
-max 1 cloudCurlFrequency;
floatFieldGrp
-l "Turb Pos XYZ"
-numberOfFields 3
-value1 0.0
-value2 46.0
-value3 0.0
TPos;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// CLOUD CHARACTER ////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
floatSliderGrp
-l "OpacityPPMax"
-field true
-s 0.01
-min 0.0
-max 1
-v 0.1 cloudOpacity;
floatSliderGrp
-l "GlowPPMax"
-field true
-v 0.0
-s 0.01
-min 0.0
-max 1
-v 0.1 cloudIncand;
floatSliderGrp
-l "Threshold"
-field true
-s 0.01
-min 0.01
-max 2
-v 0.1 cloudThresh;
floatSliderGrp
-l "RadiusPPMax"
-field true
-s 0.01
-min 0.01
-max 10
-v 3 cloudRadius;
separator -style "out";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// CLOUD SPECIAL ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
optionMenu
-l "TypeOfCloud at Alt(miles)";
menuItem -l "Cumulus 0-2";
menuItem -l "StratoCumulus 0.5 - 1";
menuItem -l "AltoCumulus 2 - 3.7";
menuItem -l "CirroCumulus 6 - 7";
menuItem -l "Cumulonimbus 0 - 6";
menuItem -l "Stratus 0 - 1";
menuItem -l "AltoStratus 2 -3.5";
menuItem -l "CirroStratus 4 - 4.5";
menuItem -l "Cirrus 5 - 6";
floatSliderGrp
-l "Surface Temp"
-field true
-s 0.01
-min 0.01
-max 10
-v 0.1 Temp;
floatSliderGrp
-l "Humidity"
-field true
-s 0.01
-min 0.01
-max 10
-v 0.1 Humidity;
checkBox -label "Height=SurfTemp/4" -v on defHeight;
checkBox -label "Rate=Humidity*SurfTemp" -v on defRate;
floatSliderGrp
-l "Stabilizing Height"
-field true
-s 5
-min 10
-max 150
-v 45 Height;
button -l "Grow Cloud"
-c "generateCloud()";
separator -style "out";
string $closeButton = `button
-l "Close"
-c ("window -e -vis 0 " + $window)`;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// END ////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// BEGIN//////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
global proc generateCloud()
{
waitCursor -state on;
string $temp[];
global string $gravity;
global string $turbulence;
global string $vortex_top;
global string $light;
float $rate = `floatSliderGrp -q -v cloudEmissionRate`;
int $MaxCount = `floatSliderGrp -q -v maximumClouds`;
float $Weight = `floatSliderGrp -q -v cloudWeight`;
int $Num_Emitter=`floatSliderGrp -q -v cloudEmitterNum`;
float $gravityMagnitude = `floatSliderGrp -q -v cloudGravity`;
float $turbulenceMagnitude = `floatSliderGrp -q -v cloudCurlMagnitude`;
float $turbulenceFrequency = `floatSliderGrp -q -v cloudCurlFrequency`;
float $VortexBMagnitude = `floatSliderGrp -q -v cloudBottomVortex`;
float $VortexTMagnitude = `floatSliderGrp -q -v cloudTopVortex`;
int $playlen = `floatSliderGrp -q -v framesToGrow`;
float $Max_Radius = `floatSliderGrp -q -v cloudRadius`;
float $Max_Thresh = `floatSliderGrp -q -v cloudThresh`;
float $Max_Opacity= `floatSliderGrp -q -v cloudOpacity`;
float $Max_Incand = `floatSliderGrp -q -v cloudIncand`;
float $EX= `floatFieldGrp -q -value1 ePos`;
float $EY= `floatFieldGrp -q -value2 ePos`;
float $EZ= `floatFieldGrp -q -value3 ePos`;
float $VBX= `floatFieldGrp -q -value1 vBPos`;
float $VBY= `floatFieldGrp -q -value2 vBPos`;
float $VBZ= `floatFieldGrp -q -value3 vBPos`;
float $VTX= `floatFieldGrp -q -value1 vTPos`;
float $VTY= `floatFieldGrp -q -value2 vTPos`;
float $VTZ= `floatFieldGrp -q -value3 vTPos`;
float $TX= `floatFieldGrp -q -value1 TPos`;
float $TY= `floatFieldGrp -q -value2 TPos`;
float $TZ= `floatFieldGrp -q -value3 TPos`;
int $hght_choice=`checkBox -q -v defHeight`;
int $rate_choice=`checkBox -q -v defRate`;
global int $i = 1;
string $emitter[];
string $particles[];
string $vortex[];
float $x, $y, $z;
$x =-5.0;
$y=$z=0.0;
float $radius_tmp;
float $opacity_tmp;
float $incand_tmp;
//LIGHT SETUP
//
defaultAmbientLight(1, 0.45, 1,1,1, "0", 0,0,0, "1");
// setAttr "lightShape.visibility" 0;
// $light = "|"+$tmp_light;
// hide ($light);
//GRAVITY SETUP
//
$temp = ` gravity -name gravity
-m $gravityMagnitude
-pos 0 0 0
-dx 0 -dy -1 -dz 0 `;
$gravity="|" + $temp[0];
hide ($gravity+"|"+$temp[1]);
//SETUP END TURBULENCE FIELDS
//
$temp = `turbulence
-name cloudTurbulence
-m $turbulenceMagnitude
-frequency $turbulenceFrequency
-mxd 3.5
-att 1
-pos $TX $TY $TZ `;
$turbulence = "|"+ $temp[0];
// hide ($turbulence+"|"+$temp[1]);
//SETUP END VORTEX FIELD
//
$temp = `vortex
-name cloudTopVortex
-m $VortexTMagnitude
-mxd 5
-att 0.25
-pos $VTX $VTY $VTZ
-ax 0
-ay 1
-az 0`;
$vortex_top = "|"+ $temp[0];
// hide ($vortex_top+"|"+$temp[1]);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//SET UP EMITTERS , PARTICLES & VORTICES & CONNECT THEM TO
//EACH OTHER & GRAVITY & TURBULENCE
//
for($i=0;$i<$Num_Emitter;$i++)
{
if($i==0){$x=$y=$z=0;}
string $emitter_name="cloudGenerator"+$i;
$temp = `emitter
-type direction
-name $emitter_name
-mxd 0.25
-mnd 0.01
-r $rate
-spd 5.0
-pos $EX $EY $EZ
-dx 0
-dy 1
-dz 0
-sp 0.15 `;
string $Emitter = "|"+ $temp[0];
$emitter[$i]=$Emitter;
hide ($Emitter+"|"+$temp[1]);
//
//
string $vortex_name="VortexField"+$i;
$temp = `vortex
-name $vortex_name
-m $VortexBMagnitude
-mxd 30
-att 1.5
-pos $VBX $VBY $VBZ
-ax 0
-ay 1
-az 0`;
$vortex[$i] = $temp[0];
string $Vortex = "|"+$temp[0];
hide ($Vortex+"|"+$temp[1]);
//
//
string $cloud_name="cloudParticles"+$i;
$temp = `particle -name $cloud_name`;
string $Particles = $temp[0];
$particles[$i]=$Particles;
string $particlesShape = $temp[1];
setAttr ($particlesShape + ".maxCount") $MaxCount;
setAttr ($particlesShape + ".dynamicsWeight") $Weight;
setAttr ($particlesShape + ".renderType") 8;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
setAttr ($particlesShape + ".castsShadows") on;
addAttr -ln radiusPP -dt doubleArray $particlesShape;
addAttr -ln radiusPP0 -dt doubleArray $particlesShape;
addAttr -ln radiusPPCache -dt doubleArray $particlesShape;
addAttr -ln "opacityPP" -dt doubleArray $particlesShape;
addAttr -ln incandescencePP -dt vectorArray $particlesShape;
addAttr -ln incandescencePP0 -dt vectorArray $particlesShape;
addAttr -ln incandescencePPCache -dt vectorArray $particlesShape;
addAttr -is true -ln "betterIllumination" -at bool -dv true
$particlesShape;
addAttr -is true -ln "threshold" -at "float" -min 0 -max 1 -dv 0
$particlesShape;
addAttr -ln CloudId -at long -min 0 -max 4 $particlesShape;
setAttr -e -keyable true ($particlesShape+".CloudId");
addAttr -ln CPP -dt doubleArray $particlesShape;
setAttr -e -keyable true ($particlesShape+".CPP");
addAttr -ln C -at double -min 1 -max 100 -dv 1 $particlesShape;
setAttr -e -keyable true ($particlesShape+".C");
addAttr -ln ParticleId -dt doubleArray $particlesShape;
setAttr -e -keyable true ($particlesShape+".ParticleId");
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
connectDynamic
-em $Emitter $Particles;
connectDynamic
-f $gravity $Particles;
connectDynamic
-f $turbulence $Particles;
connectDynamic
-f $vortex_top $Particles;
connectDynamic
-f $vortex $Particles;
//select -cl;
//select -r cloudParticles0;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add creation expressions the particles.
//
// opacity =0 means transparent
dynExpression -s (
"conserve=1;\n" +
"CPP=0;\n"+
"radiusPP=0.2;\n" +
"opacityPP=0.0;\n" +
"\n"
) -creation $particlesShape;
// Add runtime expressions for the particles.
//
dynExpression -s (
"vector $tmp_v; \n" +
"$tmp_v=position;\n" +
"string $P;\n"+
"int $result=0;\n"+
"float $x1,$y1,$z1,$x2,$z2;\n"+
"$x1=$tmp_v.x+rand(-0.5,0.5);\n"+
"$y1=$tmp_v.y;\n"+
"$z1=$tmp_v.z;\n"+
"$x2=$x1+0.7;\n"+
"$z2=$z1+0.7;\n"+
"if ($tmp_v.y>12&&$tmp_v.y<40)\n" +
"velocity=<<rand(-.5,.5),rand(4),noise(.5)>>;\n" +
"if($tmp_v.y>40)\n" +
"velocity=<<0,rand(3),0>>;\n" +
"if(time>21)\n" +
" {\n" +
" conserve=0;\n" +
" select -vis;\n"+
" velocity=<<0,0,0>>;\n"+
" }\n"+
// "else \n"+
// "{\n"+
" if($tmp_v.y>25)\n"+
" {\n"+
" if(radiusPP<3.0)\n"+
" {\n"+
" radiusPP+=abs(rand(0.05)*noise(0.007,0.005));\n" +
" }\n"+
" else \n"+
" {\n"+
" if($result<1&&CPP<1)\n"+
" {\n"+
" string $P[]=`selectedNodes`;\n"+
" string $P0=\"|cloudParticles0\";\n"+
// " print($P[0]);\n"+
" if($P[0]==$P0)\n"+
" {\n"+
" CloudId=0;\n"+
// " if(time<11)\n"+
" if(C<100)\n"+
" {\n"+
// " print(C+\" \");\n"+
" string $tmp[];\n"+
" string $PX,$PX_0,$PX_1;\n"+
" $PX=$PX_0=$PX_1=\" \";\n"+
" string $N=\" \";\n"+
" vector $velPP=velocity;\n"+
// " print(\"cloud \");\n"+
" int $kid_number=rand(1,5);\n"+
" radiusPP=radiusPP/$kid_number;\n"+
" $PX=\"kidP0\"+ particleId;\n"+
" $N=\"|emit\";\n"+
" $N=$N+$PX;\n"+
" emitter -pos $x1 $y1 $z1 -type direction -dx 0 -dy 1 -dz 0 -sp
0.20 -mxd 1.5 -mnd 0.5 -r 50 -spd 0 -n $N;\n"+
" float $vx,$vy,$vz;\n"+
" $vx=$velPP.x+1;\n"+
" $vy=$velPP.y;\n"+
" $vz=$velPP.z+1;\n"+
// " $vx=$vy=$vz=0;\n"+
" $tmp=`particle -n $PX`;\n"+
" $PX_0=$tmp[0];\n"+
" $PX_1=$tmp[0]+\"Shape\";\n"+
" hide $N;\n"+
" connectDynamic -em $N $PX_0;\n"+
" connectDynamic -f gravity $PX_0;\n"+
" connectDynamic -f cloudTopVortex $PX_0;\n"+
" connectDynamic -f cloudTurbulence $PX_0;\n"+
" setParticleAttr -at velocity -vv $vx $vy $vz $PX_1;\n"+
" setAttr ($PX_1+\".maxCount\") $kid_number;\n"+
" setAttr ($PX_1+\".dynamicsWeight\") 0.005;\n"+
" setAttr ($PX_1+\".renderType\") 8;\n"+
" addAttr -is true -ln \"radius\" -at \"float\" -min 0 -max 20 -dv
1
$PX_1;\n"+
" setAttr ($PX_1+\".radius\") 0.5;\n"+
" $result=$result+1;\n"+
" CPP=CPP+1.0;\n"+
" C=C+1;\n"+
" select -cl;\n"+
" select -r cloudParticles0;\n"+
" }\n"+
" }\n"+
" }\n"+
" }\n"+
" }\n"+
// "}\n"+
"if($tmp_v.y>10)\n"+
"{\n"+
"opacityPP+=0.05+rand(-0.05,0.2);\n"+
"}\n"+
"else ;//{opacityPP=0.0;}\n" +
"\n"
) -runtime $particlesShape;
}
//////////////////////////////// PLAYBACK ///////////////////////////////////////////////////////////////////////
// Find the current time and some playback option settings.
//
int $time = `currentTime -q`;
int $max = `playbackOptions -q -max`;
string $loop = `playbackOptions -q -loop`;
// Set the playback range to the length of the cloud from the
// current time.
//
playbackOptions
-max ($time + $playlen)
-loop once;
// Play the scene and then reset the current time.
// play -wait;
currentTime -e $time;
// Reset the playback options to what they were before.
//
playbackOptions
-max $max
-loop $loop;
/////////////////////////// DELETE /////////////////////////////////////////////////////////////////////////////
// Delete emitter, particles, and gravity
delete $emitter $particles $gravity $turbulence $vortex_top $vortex;
select -r ambientLight1 ;
delete;
waitCursor -state off;
}
/******************************************************************************/