19
//Created by Amanda Squeo and Ashley LaButte //for VSFX 160 Introduction to Programming //Taken at Savannah College of Art & Design, May 2013. //Do not remove credits if script is used. global proc MakeWaterfallUI() { // These attributes are for the Mist only. global string $sMistEmitter; global string $sMistBaseRes; global string $sMistGravity; global string $sMistViscosity; global string $sMistFriction; global string $sMistDamp; global string $sMistDensity; global string $sMistBuoyancy; global string $sMColor1; global string $sMColor2; global string $sMColor3; global string $sMistShadeQuality; global string $sCollision; global string $sWaterfallEmitter; global string $sWaterfallViscosity; global string $sWaterfallFriction; global string $sWaterfallDamp; global string $sWaterfallRadius; global string $sWaterfallStickiness; global string $sWColor1; global string $sWColor2; global string $sWColor3; // The creation of the window and its naming. string $WaterfallWindow = `window -title "Waterfall Creation" -rtf true`; // The liquid emitter and mist emitter settings will be divided. // This marks the beginning of the Water Mist Settings section of the UI. columnLayout -adjustableColumn true -columnWidth 950; frameLayout -collapsable false -label "Waterfall"; columnLayout -adjustableColumn true -columnWidth 950; frameLayout -collapsable true -label "Mist Flow Settings";

Waterfall MEL Script

Embed Size (px)

DESCRIPTION

Created by Amanda Squeo and Ashley LaButte for VSFX 160 Introduction to Programming. Taken at Savannah College of Art & Design, May 2013. Do not remove credits if script is used.

Citation preview

Page 1: Waterfall MEL Script

//Created by Amanda Squeo and Ashley LaButte//for VSFX 160 Introduction to Programming//Taken at Savannah College of Art & Design, May 2013.//Do not remove credits if script is used.

global proc MakeWaterfallUI(){ // These attributes are for the Mist only.global string $sMistEmitter;global string $sMistBaseRes;global string $sMistGravity;global string $sMistViscosity;global string $sMistFriction;global string $sMistDamp;global string $sMistDensity;global string $sMistBuoyancy;global string $sMColor1;global string $sMColor2; global string $sMColor3;global string $sMistShadeQuality;global string $sCollision;

global string $sWaterfallEmitter;global string $sWaterfallViscosity;global string $sWaterfallFriction;global string $sWaterfallDamp;global string $sWaterfallRadius;global string $sWaterfallStickiness;global string $sWColor1;global string $sWColor2; global string $sWColor3;

// The creation of the window and its naming.

string $WaterfallWindow = `window -title "Waterfall Creation" -rtf true`; // The liquid emitter and mist emitter settings will be divided.// This marks the beginning of the Water Mist Settings section of the UI.

columnLayout -adjustableColumn true -columnWidth 950;frameLayout -collapsable false -label "Waterfall";

columnLayout -adjustableColumn true -columnWidth 950;frameLayout -collapsable true -label "Mist Flow Settings";

Page 2: Waterfall MEL Script

string $sMistEmitter = `floatSliderGrp -label "Particle Emission Rate" -field true -minValue 1 -maxValue 300 -value 100`;

string $ButtonInfo = `text -label "Please Note: The higher the Base Resolution, the slower the waterfall runs. The resolution heavily influences detail quality and mist flow."`;

string $sMistBaseRes = `floatSliderGrp -label "Base Resolution" -field true -minValue 3 -maxValue 150 -value 13`;

string $sMistGravity = `floatSliderGrp -label "Gravity" -field true -minValue .01 -maxValue 30 -value 9.8`; string $sMistViscosity = `floatSliderGrp -label "Viscosity" -field true -minValue 0 -maxValue 1 -value 0`;

string $sMistFriction = `floatSliderGrp -label "Friction" -field true -minValue 0 -maxValue 20 -value 0`; string $sMistDamp = `floatSliderGrp -label "Damp" -field true -minValue 0.0 -maxValue 1.0 -value 0.0`;

string $sMistDensity = `floatSliderGrp -label "Density" -field true -minValue 0 -maxValue 40 -value 5`;

string $sMistBuoyancy = `floatSliderGrp -label "Buoyancy" -field true -minValue -30 -maxValue 30 -value -20`;

setParent ..;

Page 3: Waterfall MEL Script

columnLayout -adjustableColumn true -columnWidth 950;frameLayout -collapsable true -label "Mist Color and Shading";

columnLayout;

string $ButtonInfo2 = `text -label "Press the “Mist Color” button to preview the mist’s color in a new window."`;

// To view the mist’s color the user needs to press this button,// it brings up a small window with the chosen color as its background.// The procedure for the colorCheck option is found later on.

button -label "Mist Color" -command "colorCheckQ($sMColor1, $sMColor2, $sMColor3)";

separator; // The color selection is divided into three sliders because// the entry for any color value is separated into three values. string $sMColor1 = `colorSliderGrp -label "Red" -rgb 0.715 0 0`;string $sMColor2 = `colorSliderGrp -label "Green" -rgb 0 1 0`;string $sMColor3 = `colorSliderGrp -label "Blue" -rgb 0 0 0.9525`;

separator -height 10; string $sMistShadeQuality = `floatSliderGrp -label "Shade Quality" -field true -minValue 0 -maxValue 10 -value 1`; setParent..;

setParent..;

columnLayout -adjustableColumn true -columnWidth 950;frameLayout -collapsable true -label "Waterfall Flow Settings";

string $sWaterfallEmitter = `floatSliderGrp -label "Particle Emission Rate" -field true -minValue 1

Page 4: Waterfall MEL Script

-maxValue 2500 -value 100`;

string $sWaterfallViscosity = `floatSliderGrp -label "Viscosity" -field true -minValue 0 -maxValue 1 -value 0`; string $sWaterfallFriction = `floatSliderGrp -label "Friction" -field true -minValue 0 -maxValue 20 -value 0`; string $sWaterfallDamp = `floatSliderGrp -label "Damp" -field true -minValue 0.0 -maxValue 1.0 -value 0.0`; string $sWaterfallRadius = `floatSliderGrp -label "Radius" -field true -minValue 0.0 -maxValue 10.0 -value 0.3`; string $sWaterfallStickiness = `floatSliderGrp -label "Stickiness" -field true -minValue 0.0 -maxValue 1.0 -value 0.0`;

setParent ..;

setParent..;

columnLayout -adjustableColumn true -columnWidth 950;frameLayout -collapsable true -label "Waterfall Color and Shading";

columnLayout;

string $ButtonInfo7 = `text -label "Press the “Waterfall Color” button to preview the mist’s color in a new window."`;

// To view the mist’s color the user needs to press this button,// it brings up a small window with the chosen color as its background.// The procedure for the colorCheck option is found later on.

Page 5: Waterfall MEL Script

button -label "Waterfall Color" -command "colorCheckZ($sWColor1, $sWColor2, $sWColor3)";

separator; // The color selection is divided into three sliders because// the entry for any color value is separated into three values. string $sWColor1 = `colorSliderGrp -label "Red" -rgb 0.715 0 0`;string $sWColor2 = `colorSliderGrp -label "Green" -rgb 0 1 0`;string $sWColor3 = `colorSliderGrp -label "Blue" -rgb 0 0 0.9525`;

separator -height 10; string $sWaterfallShadeQuality = `floatSliderGrp -label "Shade Quality" -field true -minValue 0 -maxValue 10 -value 1`; setParent..;

setParent..;

string $ButtonInfo3 = `text -label "Create just the Waterfall and Mist Emitters"`;button -label "Create Waterfall" -command "createWaterfallButton($sMistEmitter, $sMistBaseRes, $sMistGravity, $sMistViscosity, $sMistFriction, $sMistDamp, $sMistDensity, $sMistBuoyancy, $sMColor1, $sMColor2, $sMColor3, $sMistShadeQuality,$sWaterfallEmitter, $sWaterfallViscosity, $sWaterfallFriction, $sWaterfallDamp, $sWaterfallRadius, $sWaterfallStickiness, $sWColor1, $sWColor2, $sWColor3)";

setParent..;

string $ButtonInfo4 = `text -label "Do you already have geometry you want the waterfall to collide with?"`;button -label "Create and Collide with Previous Geometry" -command "createWaterfallButton2($sMistEmitter, $sMistBaseRes, $sMistGravity, $sMistViscosity, $sMistFriction, $sMistDamp, $sMistDensity, $sMistBuoyancy, $sMColor1, $sMColor2, $sMColor3, $sMistShadeQuality,$sWaterfallEmitter, $sWaterfallViscosity, $sWaterfallFriction, $sWaterfallDamp, $sWaterfallRadius, $sWaterfallStickiness, $sWColor1, $sWColor2, $sWColor3)";

Page 6: Waterfall MEL Script

setParent..;

setParent..;

showWindow $WaterfallWindow;

}

// The colorCheckQ and colorCheck procedures are borrowed// from the Waterfall script by Tyler Britton.

global proc colorCheckQ(string $CmMColor1, string $CmMColor2, string $CmMColor3){ vector $CoMColor1 = `colorSliderGrp -q -rgb $CmMColor1`; vector $CoMColor2 = `colorSliderGrp -q -rgb $CmMColor2`; vector $CoMColor3 = `colorSliderGrp -q -rgb $CmMColor3`;

colorCheck ($CoMColor1, $CoMColor2, $CoMColor3);}

global proc colorCheckZ(string $CmWColor1, string $CmWColor2, string $CmWColor3){

vector $CoWColor1 = `colorSliderGrp -q -rgb $CmWColor1`; vector $CoWColor2 = `colorSliderGrp -q -rgb $CmWColor2`; vector $CoWColor3 = `colorSliderGrp -q -rgb $CmWColor3`; colorCheck2 ($CoWColor1, $CoWColor2, $CoWColor3);}

// This procedure creates the small window that shows the color preview.

global proc colorCheck(float $CMColor1, float $CMColor2, float $CMColor3){confirmDialog -title "Mist Color Preview" -message "This is the Mist Color." -button "Exit this Window" -bgc $CMColor1 $CMColor2 $CMColor3;}

Page 7: Waterfall MEL Script

global proc colorCheck2(float $CWColor1, float $CWColor2, float $CWColor3){confirmDialog -title "Waterfall Color Preview" -message "This is the Waterfall Color." -button "Exit this Window" -bgc $CWColor1 $CWColor2 $CWColor3;}

//// Querying all the values within the UI.//// There are two because the user has a choice between using no geometry,//// or using their own geometry and having the emitter collide with it.

// Just the Mist Emitter procedure.

global proc createWaterfallButton(string $qMistEmitter, string $qMistBaseRes, string $qMistGravity,string $qMistViscosity, string $qMistFriction, string $qMistDamp, string $qMistDensity, string $qMistBuoyancy, string $qMColor1, string $qMColor2, string $qMColor3, string $qMistShadeQuality, string $qWaterfallEmitter,string $qWaterfallViscosity, string $qWaterfallFriction, string $qWaterfallDamp, string $qWaterfallRadius, string $qWaterfallStickiness, string $qWColor1, string $qWColor2, string $qWColor3){ float $MistEmitter = `floatSliderGrp -q -value $qMistEmitter`; float $MistBaseRes = `floatSliderGrp -q -value $qMistBaseRes`; float $MistGravity = `floatSliderGrp -q -value $qMistGravity`; float $MistViscosity = `floatSliderGrp -q -value $qMistViscosity`; float $MistFriction = `floatSliderGrp -q -value $qMistFriction`; float $MistDamp = `floatSliderGrp -q -value $qMistDamp`;

float $MistDensity = `floatSliderGrp -q -value $qMistDensity`; float $MistBuoyancy = `floatSliderGrp -q -value $qMistBuoyancy`;

Page 8: Waterfall MEL Script

vector $MColor1 = `colorSliderGrp -q -rgb $qMColor1`; vector $MColor2 = `colorSliderGrp -q -rgb $qMColor2`; vector $MColor3 = `colorSliderGrp -q -rgb $qMColor3`;

float $MistShadeQuality = `floatSliderGrp -q -value $qMistShadeQuality`; float $WaterfallEmitter = `floatSliderGrp -q -value $qWaterfallEmitter`; float $WaterfallViscosity = `floatSliderGrp -q -value $qWaterfallViscosity`; float $WaterfallFriction = `floatSliderGrp -q -value $qWaterfallFriction`; float $WaterfallDamp = `floatSliderGrp -q -value $qWaterfallDamp`; float $WaterfallStickiness = `floatSliderGrp -q -value $qWaterfallStickiness`; float $WaterfallRadius = `floatSliderGrp -q -value $qWaterfallRadius`; vector $WColor1 = `colorSliderGrp -q -rgb $qWColor1`; vector $WColor2 = `colorSliderGrp -q -rgb $qWColor2`; vector $WColor3 = `colorSliderGrp -q -rgb $qWColor3`; makeFallMist ($MistEmitter, $MistBaseRes, $MistGravity, $MistViscosity, $MistFriction, $MistDamp, $MistDensity, $MistBuoyancy, $MColor1, $MColor2, $MColor3, $MistShadeQuality, $WaterfallEmitter, $WaterfallViscosity, $WaterfallFriction, $WaterfallDamp, $WaterfallRadius, $WaterfallStickiness, $WColor1, $WColor2, $WColor3);

WaterBlinnMaterial();

}

// Collision with User’s Geometry procedure.

Page 9: Waterfall MEL Script

global proc createWaterfallButton2(string $qMistEmitter, string $qMistBaseRes, string $qMistGravity,string $qMistViscosity, string $qMistFriction, string $qMistDamp, string $qMistDensity, string $qMistBuoyancy, string $qMColor1, string $qMColor2, string $qMColor3, string $qMistShadeQuality, string $qWaterfallEmitter,string $qWaterfallViscosity, string $qWaterfallFriction, string $qWaterfallDamp, string $qWaterfallRadius, string $qWaterfallStickiness, string $qWColor1, string $qWColor2, string $qWColor3){ float $MistEmitter = `floatSliderGrp -q -value $qMistEmitter`; float $MistBaseRes = `floatSliderGrp -q -value $qMistBaseRes`; float $MistGravity = `floatSliderGrp -q -value $qMistGravity`; float $MistViscosity = `floatSliderGrp -q -value $qMistViscosity`; float $MistFriction = `floatSliderGrp -q -value $qMistFriction`; float $MistDamp = `floatSliderGrp -q -value $qMistDamp`;

float $MistDensity = `floatSliderGrp -q -value $qMistDensity`; float $MistBuoyancy = `floatSliderGrp -q -value $qMistBuoyancy`; vector $MColor1 = `colorSliderGrp -q -rgb $qMColor1`; vector $MColor2 = `colorSliderGrp -q -rgb $qMColor2`; vector $MColor3 = `colorSliderGrp -q -rgb $qMColor3`;

float $MistShadeQuality = `floatSliderGrp -q -value $qMistShadeQuality`; float $WaterfallEmitter = `floatSliderGrp -q -value $qWaterfallEmitter`; float $WaterfallViscosity = `floatSliderGrp -q -value $qWaterfallViscosity`; float $WaterfallFriction = `floatSliderGrp -q -value

Page 10: Waterfall MEL Script

$qWaterfallFriction`; float $WaterfallDamp = `floatSliderGrp -q -value $qWaterfallDamp`; float $WaterfallStickiness = `floatSliderGrp -q -value $qWaterfallStickiness`; float $WaterfallRadius = `floatSliderGrp -q -value $qWaterfallRadius`; vector $WColor1 = `colorSliderGrp -q -rgb $qWColor1`; vector $WColor2 = `colorSliderGrp -q -rgb $qWColor2`; vector $WColor3 = `colorSliderGrp -q -rgb $qWColor3`; makeFallMist ($MistEmitter, $MistBaseRes, $MistGravity, $MistViscosity, $MistFriction, $MistDamp, $MistDensity, $MistBuoyancy, $MColor1, $MColor2, $MColor3, $MistShadeQuality, $WaterfallEmitter, $WaterfallViscosity, $WaterfallFriction, $WaterfallDamp, $WaterfallRadius, $WaterfallStickiness, $WColor1, $WColor2, $WColor3);

// The presence of this procedure is what makes the difference.

collideWithPreGeo();

WaterBlinnMaterial();}

//// The creation of the Mist Emitter and its 3D Container. ////There is a long list of specific attributes that are associated with the Mist.//// Some are customizable, but a majority are not.//// Those that are customable within the User Interface have their strings//// declared within the very beginning of the Mist Emitter’s section.

// Pulling the values from the UI into the attributes of the new emitter.

global proc makeFallMist(float $MistEmitter, float $MistBaseRes, float $MistGravity, float $MistViscosity, float $MistFriction, float $MistDamp, float $MistDensity,

Page 11: Waterfall MEL Script

float $MistBuoyancy, float $MColor1, float $MColor2, float $MColor3, float $MistShadeQuality, float $WaterfallEmitter, float $WaterfallViscosity, float $WaterfallFriction, float $WaterfallDamp, float $WaterfallRadius, float $WaterfallStickiness, float $WColor1, float $WColor2, float $WColor3){ //file -f -new;

playbackOptions -max 500;

playbackOptions -e -playbackSpeed 0 -maxPlaybackSpeed 0;

////Emitter and Container creation and connecting.

// Creation of Mist's emitter and its 3D fluid container. fluidEmitter;create3DFluid 10 10 10 10 10 10;

// The emitter is renamed to avoid conflictions with// previously created waterfalls or emitters.// This also so the user can distinguish between the // liquid emitter and the mist emitter.

string $FluidShape[] = `ls -sl -dag`;rename $FluidShape[1] MistFluidShape;rename fluidEmitter1 MistEmitter;

// Connection of the emitter to the 3D fluid container.

connectDynamic -em MistEmitter MistFluidShape;

// Base Resolution controls the resolution of the mist stream.// The higher the resolution, the better the mist looks,// the slower it runs.

setAttr "MistFluidShape.baseResolution" $MistBaseRes;

// Contents Method, preset attributes.

setAttr "MistFluidShape.densityMethod" 2;setAttr "MistFluidShape.velocityMethod" 2;setAttr "MistFluidShape.temperatureMethod" 0;setAttr "MistFluidShape.fuelMethod" 0;setAttr "MistFluidShape.colorMethod" 0;setAttr "MistFluidShape.falloffMethod" 0;

// Display, preset attributes.

setAttr "MistFluidShape.shadedDisplay" 1;

Page 12: Waterfall MEL Script

setAttr "MistFluidShape.slices" 1;setAttr "MistFluidShape.voxelQuality" 2;setAttr "MistFluidShape.boundaryDraw" 0;setAttr "MistFluidShape.numericDisplay" 0;setAttr "MistFluidShape.wireframeDisplay" 2;

//// Dynamic Simulation

// Customizable

setAttr "MistFluidShape.gravity" $MistGravity;setAttr "MistFluidShape.viscosity" $MistViscosity;setAttr "MistFluidShape.friction" $MistFriction;setAttr "MistFluidShape.velocityDamp" $MistDamp;

// Preset Attributes

setAttr "MistFluidShape.solver" 1;setAttr "MistFluidShape.highDetailSolve" 3;setAttr "MistFluidShape.substeps" 1;setAttr "MistFluidShape.solverQuality" 20;setAttr "MistFluidShape.startFrame" 1;setAttr "MistFluidShape.simulationRateScale" 1;setAttr "MistFluidShape.gridInterpolator" 0;setAttr "MistFluidShape.forwardAdvection" 1;setAttr "MistFluidShape.conserveMass" 1;setAttr "MistFluidShape.collide" 1;setAttr "MistFluidShape.doEmission" 1;setAttr "MistFluidShape.doFields" 1;setAttr "MistFluidShape.emitInSubsteps" 0;

// Liquids, preset to OFF.

setAttr "MistFluidShape.enableLiquidSimulation" 0;

// Auto Resize, preset attributes.

setAttr "MistFluidShape.autoResize" 1;setAttr "MistFluidShape.resizeClosedBoundaries" 1;setAttr "MistFluidShape.resizeInSubsteps" 1;setAttr "MistFluidShape.resizeToEmitter" 1;setAttr "MistFluidShape.maxResolution" 300;setAttr "MistFluidShape.dynamicOffsetX" 0;setAttr "MistFluidShape.dynamicOffsetY" 0;setAttr "MistFluidShape.dynamicOffsetZ" 0;setAttr "MistFluidShape.autoResizeThreshold" 0.001;setAttr "MistFluidShape.autoResizeMargin" 0;

// Self Attraction and Repulsion, preset to OFF.

setAttr "MistFluidShape.selfForce" 0;

//// Content Details

Page 13: Waterfall MEL Script

// Density, some customable attributes, majority are preset.

setAttr "MistFluidShape.densityScale" $MistDensity;setAttr "MistFluidShape.densityBuoyancy" $MistBuoyancy;setAttr "MistFluidShape.densityDissipation" 1;setAttr "MistFluidShape.densityPressure" 0;setAttr "MistFluidShape.densityPressureThreshold" 1;setAttr "MistFluidShape.densityNoise" 0;setAttr "MistFluidShape.densityTension" 0;setAttr "MistFluidShape.tensionForce" 0;setAttr "MistFluidShape.densityGradientForce" 0;

// Velocity, preset attributes.

setAttr "MistFluidShape.velocityScaleX" 1;setAttr "MistFluidShape.velocityScaleY" 1;setAttr "MistFluidShape.velocityScaleZ" 1;setAttr "MistFluidShape.velocitySwirl" 0;setAttr "MistFluidShape.velocityNoise" 0;

// Turbulence, preset attributes.

setAttr "MistFluidShape.turbulenceStrength" 0;setAttr "MistFluidShape.turbulenceFrequency" 1.198;setAttr "MistFluidShape.turbulenceSpeed" 0.757;

// Grids Cache, preset attributes.

setAttr "MistFluidShape.loadDensity" 1;setAttr "MistFluidShape.loadVelocity" 1;setAttr "MistFluidShape.loadTemperature" 1;setAttr "MistFluidShape.loadReaction" 1;setAttr "MistFluidShape.loadColor" 1;setAttr "MistFluidShape.loadTextureCoordinates" 1;setAttr "MistFluidShape.loadFalloff" 1;

// Surface, preset to Volume Render.

setAttr MistFluidShape.surfaceRender 0;setAttr "MistFluidShape.surfaceThreshold" 0.01;

// Output Mesh, preset attributes.

setAttr "MistFluidShape.meshMethod" 0;setAttr "MistFluidShape.meshResolution" 2;setAttr "MistFluidShape.meshSmoothingIterations" 0;setAttr "MistFluidShape.colorPerVertex" 0;setAttr "MistFluidShape.incandescencePerVertex" 0;setAttr "MistFluidShape.uvwPerVertex" 0;setAttr "MistFluidShape.opacityPerVertex" 0;setAttr "MistFluidShape.useGradientNormals" 0;setAttr "MistFluidShape.velocityPerVertex" 1;

Page 14: Waterfall MEL Script

// Shading, transparency only customizable.

setAttr "MistFluidShape.transparency" -type double3 0.322683 0.322683 0.322683;setAttr "MistFluidShape.glowIntensity" 0;setAttr "MistFluidShape.dropoffShape" 0;

// Color, actual color of mist is customizable.

setAttr "MistFluidShape.color[0].color_Color" -type double3 $MColor1 $MColor2 $MColor3;

// Opacity, preset attribute.

setAttr "MistFluidShape.opacityInputBias" 0.3;

// Matte Opacity, preset attribute.

setAttr "MistFluidShape.matteOpacity" 1;

// Shading Quality, only quality is customizable.

setAttr "MistFluidShape.quality" $MistShadeQuality;setAttr "MistFluidShape.contrastTolerance" 0.01;setAttr "MistFluidShape.sampleMethod" 3;setAttr "MistFluidShape.renderInterpolator" 0;

// Textures, preset attributes.

setAttr "MistFluidShape.colorTexture" 0;setAttr "MistFluidShape.incandTexture" 0;setAttr "MistFluidShape.opacityTexture" 0;setAttr "MistFluidShape.textureType" 0;setAttr "MistFluidShape.coordinateMethod" 0;

// Lighting, preset attributes.

setAttr "MistFluidShape.selfShadowing" 1;setAttr "MistFluidShape.hardwareSelfShadow" 1;setAttr "MistFluidShape.shadowOpacity" 0.5;setAttr "MistFluidShape.shadowDiffusion" 1;setAttr "MistFluidShape.lightType" 1;setAttr "MistFluidShape.lightBrightness" 1.188;setAttr "MistFluidShape.fluidLightColor" -type double3 1 1 1 ;setAttr "MistFluidShape.ambientBrightness" 0.298;setAttr "MistFluidShape.ambientDiffusion" 2.320 ;setAttr "MistFluidShape.ambientColor" -type double3 0.494 0.6964 1 ;setAttr "MistFluidShape.realLights" 1;setAttr "MistFluidShape.directionalLightX" 1;setAttr "MistFluidShape.directionalLightY" 0.3;setAttr "MistFluidShape.directionalLightZ" 0.2;

Page 15: Waterfall MEL Script

// Render Stats, preset attributes.

setAttr "MistFluidShape.castsShadows" 1;setAttr "MistFluidShape.receiveShadows" 1;setAttr "MistFluidShape.primaryVisibility" 1;setAttr "MistFluidShape.smoothShading" 1;setAttr "MistFluidShape.visibleInReflections" 0;setAttr "MistFluidShape.visibleInRefractions" 0;

//// MistEmitter Settings

// The following settings are changes to the emitter.

// Basic Emitter Attributes

setAttr "MistEmitter.emitterType" 4;setAttr "MistEmitter.rate" $MistEmitter;setAttr "MistEmitter.cycleEmission" 0;

// Fluid Attributes

setAttr "MistEmitter.densityMethod" 1;setAttr "MistEmitter.fluidDensityEmission" 2;setAttr "MistEmitter.heatMethod" 1;setAttr "MistEmitter.fluidHeatEmission" 1;setAttr "MistEmitter.fuelMethod" 1;setAttr "MistEmitter.fluidFuelEmission" 1;setAttr "MistEmitter.fluidDropoff" 0;

// Emission Speed Attributes

setAttr "MistEmitter.speedMethod" 2;setAttr "MistEmitter.inheritVelocity" 2;setAttr "MistEmitter.alongAxis" 0;setAttr "MistEmitter.aroundAxis" 0;setAttr "MistEmitter.directionalSpeed" 0;setAttr "MistEmitter.directionX" 1;setAttr "MistEmitter.directionY" 0;setAttr "MistEmitter.directionZ" 0;

// Fluid Emission Turbulence

setAttr "MistEmitter.turbulenceType" 0;setAttr "MistEmitter.turbulence" 1.497;setAttr "MistEmitter.turbulenceSpeed" 1;setAttr "MistEmitter.turbulenceFrequencyX" 1;setAttr "MistEmitter.turbulenceFrequencyY" 1;setAttr "MistEmitter.turbulenceFrequencyZ" 1;setAttr "MistEmitter.turbulenceOffsetX" 0;setAttr "MistEmitter.turbulenceOffsetY" 0;setAttr "MistEmitter.turbulenceOffsetZ" 0;setAttr "MistEmitter.detailTurbulence" 0;

// Volume Emitter Attributes

Page 16: Waterfall MEL Script

setAttr "MistEmitter.volumeShape" 1;setAttr "MistEmitter.volumeOffsetX" 0;setAttr "MistEmitter.volumeOffsetY" 0;setAttr "MistEmitter.volumeOffsetZ" 0;setAttr "MistEmitter.volumeSweep" 360;setAttr "MistEmitter.normalizedDropoff" 1;

// Create an emiter for the waterfall using nParticles

emitter -pos 0 0 0 -type volume;nParticle;

// The emitter is renamed to avoid conflictions with// previously created waterfalls or emitters.// This also so the user can distinguish between the // waterfall emitter and the mist emitter.

string $nParticleShape[] = `ls -sl -dag`;rename $nParticleShape[1] WaterfallnParticleShape;rename emitter1 WaterfallEmitter;

// Connection of the emitter to the 3D fluid container.

connectDynamic -em WaterfallEmitter WaterfallnParticleShape;

//Lifespan

setAttr "WaterfallnParticleShape.lifespanMode" 0;

//Particle SizesetAttr "WaterfallnParticleShape.radius" $WaterfallRadius;setAttr "WaterfallnParticleShape.radiusScale[0].radiusScale_Position" 0;setAttr "WaterfallnParticleShape.radiusScale[0].radiusScale_FloatValue" 1;setAttr "WaterfallnParticleShape.radiusScale[0].radiusScale_Interp" 0;setAttr "WaterfallnParticleShape.radiusScaleInput" 6;setAttr "WaterfallnParticleShape.radiusScaleInputMax" 1;setAttr "WaterfallnParticleShape.radiusScaleRandomize" 0.132;

//Collisions

setAttr "WaterfallnParticleShape.collide" 1;setAttr "WaterfallnParticleShape.collideStrength" 1;setAttr "WaterfallnParticleShape.collisionLayer" 0;setAttr "WaterfallnParticleShape.collideWidthScale" 0.5;

Page 17: Waterfall MEL Script

setAttr "WaterfallnParticleShape.selfCollideWidthScale" 1;setAttr "WaterfallnParticleShape.solverDisplay" 0;setAttr "WaterfallnParticleShape.bounce" 0;setAttr "WaterfallnParticleShape.friction" $WaterfallFriction;setAttr "WaterfallnParticleShape.stickiness" $WaterfallStickiness;setAttr "WaterfallnParticleShape.maxSelfCollisionIterations" 4;

//// Dynamic Simulation

//Dynamic Properties

setAttr "WaterfallnParticleShape.dynamicsWeight" 1;setAttr "WaterfallnParticleShape.conserve" 1;setAttr "WaterfallnParticleShape.damp" $WaterfallDamp;setAttr "WaterfallnParticleShape.drag" 0;setAttr "WaterfallnParticleShape.pointMass" 1;setAttr "WaterfallnParticleShape.ignoreSolverGravity" 0;

//Mass Scale

setAttr "WaterfallnParticleShape.massScale[0].massScale_Position" 0;setAttr "WaterfallnParticleShape.massScale[0].massScale_FloatValue" 1;setAttr "WaterfallnParticleShape.massScaleInputMax" 1;setAttr "WaterfallnParticleShape.massScaleRandomize" 0;

// Liquids, preset to ON.

setAttr "WaterfallnParticleShape.enableSPH" 1;setAttr "WaterfallnParticleShape.incompressibility" 1;setAttr "WaterfallnParticleShape.restDensity" 2;setAttr "WaterfallnParticleShape.radiusScaleSPH" 0.65;setAttr "WaterfallnParticleShape.viscosity" $WaterfallViscosity;

//Output mesh

setAttr "WaterfallnParticleShape.meshMethod" 0;setAttr "WaterfallnParticleShape.threshold" 0.86;setAttr "WaterfallnParticleShape.blobbyRadiusScale" 1;setAttr "WaterfallnParticleShape.motionStreak" 0;setAttr "WaterfallnParticleShape.meshTriangleSize" 0.5;

//Shading

setAttr "WaterfallnParticleShape.particleRenderType" 7;setAttr "WaterfallnParticleShape.opacity" 0.083;

Page 18: Waterfall MEL Script

setAttr "WaterfallnParticleShape.color[0].color_Color" -type double3 $WColor1 $WColor2 $WColor3;

// Render Stats, preset attributes.

setAttr "WaterfallnParticleShape.castsShadows" 1;setAttr "WaterfallnParticleShape.receiveShadows" 1;setAttr "WaterfallnParticleShape.primaryVisibility" 1;setAttr "WaterfallnParticleShape.visibleInReflections" 1;setAttr "WaterfallnParticleShape.visibleInRefractions" 1;

//// Waterfall Emitter Settings

// The following settings are changes to the emitter.

// Basic Emitter Attributes

setAttr "WaterfallEmitter.emitterType" 4;setAttr "WaterfallEmitter.rate" $WaterfallEmitter;setAttr "WaterfallEmitter.cycleEmission" 0;

//Distance/Direction Attributes

setAttr "WaterfallEmitter.directionX" 1;setAttr "WaterfallEmitter.directionY" 0;setAttr "WaterfallEmitter.directionZ" 0;

// Emission Speed Attributes

setAttr "WaterfallEmitter.speedRandom" 0;

// Volume Emitter Attributes

setAttr "WaterfallEmitter.volumeShape" 1;setAttr "WaterfallEmitter.volumeOffsetX" 0;setAttr "WaterfallEmitter.volumeOffsetY" 0;setAttr "WaterfallEmitter.volumeOffsetZ" 0;setAttr "WaterfallEmitter.volumeSweep" 360;}

//Add a blinn texture to the waterfall particles

global proc WaterBlinnMaterial(){ shadingNode -asShader blinn;sets -renderable true -noSurfaceShader true -empty -name blinn1SG;connectAttr -f blinn1.outColor blinn1SG.surfaceShader;rename blinn1 "WaterBlinn" ;

defaultNavigation -createNew -destination "WaterBlinn.transparency";createRenderNode -allWithTexturesUp "defaultNavigation -force true -connectToExisting -source %node -destination

Page 19: Waterfall MEL Script

WaterBlinn.transparency" "";defaultNavigation -defaultTraversal -destination "WaterBlinn.transparency";shadingNode -asUtility particleSamplerInfo;defaultNavigation -force true -connectToExisting -source particleSamplerInfo1 -destination WaterBlinn.transparency; window -e -vis false createRenderNodeWindow;rename particleSamplerInfo1 "WaterparticleSamplerInfo" ;

select -r nParticle1 ;hyperShade -assign blinn1SG;sets -e -forceElement blinn1SG;}

//// Collision with present objects in scene.//// This procedure is only activated when the appropriate button//// is pressed within the UI.

global proc collideWithPreGeo(){// Establishes that all geometry will collide with the Mist.select -all;select -d WaterfallEmitter nParticle1 nucleus1;doMakeCollideFluid 1 { "200" } ;select -all;select -d WaterfallEmitter nParticle1 nucleus1 MistEmitter fluid1 nucleus1;makeCollideNCloth; }