// Creation Date: December-21-2001 // // Author: // ------------------------- // --------------------------- // Klaus Stangl // Student@TU Graz // Demoartist/Developer // Educator@Siliconstudio Graz // www.worldofmaya.com // office@worldofmaya.com // ----------------------------- // ------------------------------- // // // Script Name: // // tornadoMaker (version: 1.2) // // Description: // This script allows you to create a fully controllable // tornado to destroy some bits and bytes -) // // Put the script in your script-directory ($HOME/maya/scripts) // Create a shelf button with this command: // // source tornadoMaker.mel;tornadoMaker(); // // For more infos read the documentation on www.worldofmaya.com // // ! If you make changes/enhancements to the script ! // ! or cool anims with it please mail me ! // //-------------------------------------------------------------- // don't change these Variables //-------------------------------------------------------------- global string $winName = "Tornado_Control_Window"; global string $winName_lat = "Lattice_Control_Window"; global string $winName_del = "Object_delete"; global string $winName_emit = "Emmiter_Control_Window"; global string $winName_part = "Particle_Control_Window"; global string $winName_disp = "Display_Control_Window"; global string $winName_help = "Display_Help_Window"; global string $winName_prefs = "Preferences_Windows"; global string $not_avaible = "Not avaible by now!!!"; global int $q_confirm = 0; global string $help_about = "tornadoMaker V1.0\n\nProgrammed by Klaus Stangl\nCopyright 2001\n\nModify at your own risk.\n\nFor a detailed description please refer to\nthe HTML documentation.\n\nEmail: maya.user@gmx.net\nHomepage: http://www.worldofmaya.com"; global string $help_instructions = "\"Set name\" sets a new Name for the whole System!\n\n\"Lattice Divs\" sets the divisions of \n your latticebox\n\n\"Max Latt. Y\" sets the maximum scale value \n for the Y-scale-slider\n\n\"Max Latt.XZ\" just the same as before \n but for XY-scale\n\n\"Cyl. Spans\" sets the number of spans \n for your cylinder\n\n\"Cyl. Sections\" just the same as before \n but for the sections\n\n\"max. Color UP\" sets the number of controlpoints \n for the up speed, you can set more to refine \n your speedsettings\n\n\"max. Color Round\" just the same as before \n but for the round speed\n\n\"Default Up\" sets the default up speed\n\n\"Default Round\" just the same as before but \n for round speed\n\n\"Update\" sets the new values, but doesn't create \n a new tornado! If you have already created a \n tornadowith custom settins the script can't \n find your tornado because of the different names.\n Now you can set your own names and the choose \n update to link to your own tornado\n\n\"New Creates a new tornado system with \n your custom settings\n\n\"Cancel/Close\" closes the window without\n setting something..."; global string $tempString = ""; global string $new_main_Name = "tornado"; global int $new_rows = 5; global int $new_t_Spans = 6; global int $new_t_Sections = 8; global int $new_max_emitter_rate = 500; global int $new_max_lattice_xz_scale = 20; global int $new_max_lattice_y_scale = 5; global int $new_up_colorentry = 3; global int $new_round_colorentry = 3; global float $max_round_slider = 0.1; global float $max_up_slider = 0.1; global string $group_pre = "group_"; global string $zyl_pre = "_Surface"; global string $lat_pre = "_Lattice"; global string $emitter_pre = "_Emitter"; global string $particle_pre = "_Particle"; //-------------------------------------------------------------- // Variable to set by Prefs //-------------------------------------------------------------- global string $main_Name = "tornado"; global string $tornado_group_name; global string $zyl_name; global string $lat_name; global string $emitter_name; global string $particle_name; global int $rows = 5; global int $t_Spans = 6; global int $t_Sections = 8; global int $max_emitter_rate = 500; global int $max_lattice_xz_scale = 20; global int $max_lattice_y_scale = 5; global int $up_colorentry = 3; global int $round_colorentry = 3; global float $upSpeed = 0.005; global float $roundSpeed = 0.005; global float $max_round_slider = 0.1; global float $max_up_slider = 0.1; //-------------------------------------------------------------- proc string confirm_Dialog(string $title) { global int $q_confirm; if ($q_confirm==0) { string $button_re=`confirmDialog -message "Are you sure?" -button "Yes" -button "No" -defaultButton "No" -ma "center" -t $title -cancelButton "No" -dismissString "No"`; return($button_re); } else { return("Yes"); } } //-------------------------------------------------------------- proc searchObjectandDelete(string $search_String) { select -all -ado -hi; string $search_String; string $namerSel[] = `ls -sl`; int $namerSiz = `size $namerSel`; if ($namerSiz >0) { for ($i = 0;$i< $namerSiz;$i++) { if($namerSel[$i]==$search_String) { select $search_String; delete; $i=$namerSiz; } } } } //-------------------------------------------------------------- proc int searchObject(string $search_String) { select -all -ado -hi; string $search_String; string $namerSel[] = `ls -sl`; int $namerSiz = `size $namerSel`; int $found=0; if ($namerSiz >0) { for ($i = 0;$i< $namerSiz;$i++) { if($namerSel[$i]==$search_String) { select $search_String; $i=$namerSiz; $found=1; } } } return($found); } //-------------------------------------------------------------- // Mainprocedure //-------------------------------------------------------------- global proc tornadoMaker () { global string $winName; global int $rows; global string $not_avaible; global string $main_Name; global string $new_main_Name; global string $group_pre; global string $zyl_pre; global string $lat_pre; global string $emitter_pre; global string $particle_pre; global string $tornado_group_name; global string $zyl_name; global string $lat_name; global string $emitter_name; global string $particle_name; $tornado_group_name = $group_pre + $main_Name; $zyl_name = $main_Name + $zyl_pre; $lat_name = $main_Name + $lat_pre; $emitter_name = $main_Name + $emitter_pre; $particle_name = $main_Name + $particle_pre; string $main = "t_mainWindow"; proc_dir("check", $winName,0); if (searchObject($tornado_group_name)==0) { if ((confirm_Dialog("Create with default name?"))=="Yes") { proc_dir("createNewTornadoGroup", "",0); } else { //warning("No Tornado Group was found!!! Create a new Tornado first!!!"); proc_dir("enterSomething","No",1); proc_dir("update_Globals"," ",3); if (searchObject($tornado_group_name)==0) { proc_dir("createNewTornadoGroup", "",1); } } } select -cl; window -title "Tornadomaker" -wh 216 345 -menuBar true -menuBarVisible true $winName; menu -label "File" -tearOff 0; menuItem -label "Preferences" -c ("proc_dir(\"prefs_control_Window\",\" \",0);"); menuItem -label "Display Settings" -c ("proc_dir(\"display_Control\",\" \",0);"); menuItem -divider 1; menuItem -label "new Tornado" -c ("proc_dir(\"newTornado\" ,\" \",0);"); menuItem -label "delete Tornado" -c ("proc_dir(\"delTornado\" ,\" \",1);"); menu -label "Create" -tearOff 0; menuItem -label "Preferences" -c ("proc_dir(\"prefs_control_Window\",\" \",0);"); menuItem -divider 1; menuItem -label "new Tornado" -c ("proc_dir(\"newTornado\" ,\" \",0);"); menuItem -label "Create Cylinder" -c ("proc_dir(\"createCylinder\",\" \",0);"); menuItem -label "Create Lattice" -c ("proc_dir(\"createLattice\" ,\" \",0);"); menuItem -label "Create Emitter" -c ("proc_dir(\"createNewSurfaceEmitter\",\" \",0);"); menuItem -label "Create Particle" -c ("proc_dir(\"createNewParticle\" ,\" \",0);"); menu -label "Control" -tearOff 0; menuItem -label "Control Lattice" -c ("proc_dir(\"control_latt\" ,\" \",0);"); menuItem -label "Control Emitter" -c ("proc_dir(\"control_Emitter\" ,\" \",0);"); menuItem -label "Control Particle" -c ("proc_dir(\"control_Particle\" ,\" \",0);"); menu -label "Delete" -tearOff 0; menuItem -label "Delete Tornado" -c ("proc_dir(\"delTornado\" ,\" \",1);"); menuItem -label "Delete Lattice" -c ("proc_dir(\"delete_latt\" ,\" \",0);"); menuItem -label "Delete ALL Emitter" -c ("proc_dir(\"deleteAllEmitter\" ,\" \",1);"); menuItem -label "Delete ALL Particle" -c ("proc_dir(\"deleteAllParticle\" ,\" \",1);"); menu -label "Help" -tearOff 0; menuItem -label "Script Information" -c ("openHelp (\"About tornadoMaker()\", $help_about);"); menuItem -divider 1; menuItem -label "Visit my Homepage" -c "showHelp -a \"http://www.worldofmaya.com\""; columnLayout -adjustableColumn true; text -label "Tornado Functions:"; rowColumnLayout -nc 1 -cw 1 205 ($main); frameLayout -cll true -w 200 ("1. Make Tornado Surface"); rowColumnLayout -nc 2; button -label "Create Cylinder" -c ("proc_dir(\"createCylinder\",\" \",0);"); button -label "Create Lattice" -c ("proc_dir(\"createLattice\" ,\" \",0);"); button -label "Control Lattice" -c ("proc_dir(\"control_latt\" ,\" \",0);"); button -label "Delete Lattice" -c ("proc_dir(\"delete_latt\" ,\" \",0);"); setParent $main; frameLayout -cll true -w 200 ("2. Make Tornado Particles"); rowColumnLayout -nc 2; button -label "Create Emitter" -c ("proc_dir(\"createNewSurfaceEmitter\",\" \",0);"); button -label "Control Emitter" -c ("proc_dir(\"control_Emitter\" ,\" \",0);"); button -label "Create Particle" -c ("proc_dir(\"createNewParticle\" ,\" \",0);"); button -label "Control Particle" -c ("proc_dir(\"control_Particle\" ,\" \",0);"); button -label "Delete ALL Emitter" -c ("proc_dir(\"deleteAllEmitter\" ,\" \",1);"); button -label "Delete ALL Particle"-c ("proc_dir(\"deleteAllParticle\" ,\" \",1);"); setParent $main; frameLayout -cll true -w 200 ("3. Instance Particle/Geometry"); rowColumnLayout -nc 2; /* button -label "---------" -c ("warning($not_avaible);"); button -label "---------" -c ("warning($not_avaible);"); button -label "---------" -c ("warning($not_avaible);"); button -label "---------" -c ("warning($not_avaible);"); */ setParent $main; frameLayout -cll true -w 200 ("4. Delete/New/Save"); rowColumnLayout -nc 2; button -label "New Tornado" -c ("proc_dir(\"newTornado\" ,\" \",0);"); button -label "Delete Tornado" -c ("proc_dir(\"delTornado\" ,\" \",1);"); button -label "Preferences" -c ("proc_dir(\"prefs_control_Window\",\" \",0);"); button -label "Display" -c ("proc_dir(\"display_Control\",\" \",0);"); setParent $main; frameLayout -cll true -w 200 ("5. Exit"); button -l "close this Window..." -c ("headsUP(1, 1); headsUP(2, 1); deleteUI -window $winName;"); setParent $main; showWindow $winName; } //-------------------------------------------------------------- proc check (string $theName) { string $theName; if (`window -exists $theName`) { deleteUI $theName; } // checks and deletes the window if it's allready in memory // } //-------------------------------------------------------------- proc createCylinder () { global string $zyl_name; global string $tornado_group_name; global int $rows; global int $t_Spans=6; global int $t_Sections=8; if (searchObject($tornado_group_name)==0) { if ((confirm_Dialog("Create new Group?"))=="Yes") { proc_dir("createNewTornadoGroup", "",0); } else { warning("No Tornado Group was found!!! Create a new Tornado first!!!"); } } if (searchObject($tornado_group_name)==1) { if (searchObject($zyl_name)==0) { searchObjectandDelete($zyl_name); cylinder -name $zyl_name -p 0 1 0 -ax 0 1 0 -ssw 0 -esw 360 -r 1 -hr 2 -d 3 -ut 0 -tol 0.01 -s $t_Sections -nsp $t_Spans -ch 1; scale -r 2 5 2; rebuildSurface -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 1 -kc 0 -su 24 -du 3 -sv 36 -dv 3 -tol 0.01 -dir 2 $zyl_name; DeleteHistory; createDisplayLayer -name ("layer_"+$zyl_name) -number 1 -empty; layerEditorAddObjects ("layer_"+$zyl_name); setAttr ("layer_"+$zyl_name+".shading") 0; setAttr ($tornado_group_name+".Surface_already_created") 1; parent $zyl_name $tornado_group_name; select -cl; } else {warning("Cylinder already exists!!!");} } select -cl; } //-------------------------------------------------------------- proc createLattice () { global string $lat_name; global string $zyl_name; global string $tornado_group_name; global int $rows; global int $max_lattice_xz_scale; global int $max_lattice_y_scale; string $rowname= "|" + $lat_name + "LatticeGroup"; string $rowattr; if (searchObject($tornado_group_name)==0) { if ((confirm_Dialog("Create new Group?"))=="Yes") { proc_dir("createNewTornadoGroup", "",0); } else { warning("No Tornado Group was found!!! Create a new Tornado first!!!"); } } if (searchObject($zyl_name)==0) { if ((confirm_Dialog("Create Cylinder?"))=="Yes") { proc_dir("createCylinder", "",0); } else { warning("No Cylinder was found!!! Create a Cylinder first!!!"); } } if ((searchObject($zyl_name)==1)&&(getAttr($tornado_group_name+".Lattice_present")==0)) { if(getAttr($tornado_group_name+".Lattice_already_created")>0) { warning("Lattice has already been created!!! There could be problems when you scale it..."); } // Creates Latticebox select -r $zyl_name; lattice -divisions 2 $rows 2 -cp -objectCentered true -ldv 2 2 2 -n $lat_name; move 0 0 0 ($lat_name+"LatticeGroup"+".scalePivot") ($lat_name+"LatticeGroup"+".rotatePivot"); move 0 0 0 ($lat_name+"Lattice"+".scalePivot") ($lat_name+"Lattice"+".rotatePivot"); setAttr ($tornado_group_name+".Lattice_already_created") 1; setAttr ($tornado_group_name+".Lattice_present") 1; setAttr ($tornado_group_name+".Number_of_Rows") $rows; int $i; for ($i=1; $i<=$rows; $i++) { $rowattr=$rowname+".row"+$i; $rowattr2=$rowattr+"_"+($i+1); addAttr -ln ("row"+$i) -at double $rowname; setAttr -e -keyable true $rowattr; if ($i<=($rows-1)) { addAttr -ln ("row"+$i+"_"+($i+1)) -at double $rowname; setAttr -e -keyable true $rowattr2; } } // ScaleUP-Attribut int $ScaleY_value=`getAttr ($lat_name+"Lattice.scaleY")`; addAttr -ln ScaleUP -at double $rowname; setAttr -e -keyable true ($rowname+".ScaleUP"); setAttr ($lat_name+"LatticeGroup"+".ScaleUP") 0; setDrivenKeyframe -cd ($lat_name+"LatticeGroup"+".ScaleUP") ($lat_name+"Lattice.scaleY"); setAttr ($lat_name+"LatticeGroup"+".ScaleUP") 10; setAttr ($lat_name+"Lattice.scaleY") ($max_lattice_y_scale*$ScaleY_value); setDrivenKeyframe -cd ($lat_name+"LatticeGroup.ScaleUP") ($lat_name+"Lattice.scaleY"); setAttr ($lat_name+"LatticeGroup"+".ScaleUP") (-10); setAttr ($lat_name+"Lattice.scaleY") (0); setDrivenKeyframe -cd ($lat_name+"LatticeGroup.ScaleUP") ($lat_name+"Lattice.scaleY"); setAttr ($lat_name+"LatticeGroup"+".ScaleUP") 0; $rowname= $lat_name + "LatticeGroup"; string $points_1; string $points_2; float $y_Value; float $dy = 10.0 / ($rows-1); // Scale XZ-Attribut => .row1-$rows for ($i=1; $i<=$rows; $i++) { $points_1= $lat_name + "Lattice.pt[0:1]["+($rows-$i)+"][0]"; $points_2= $lat_name + "Lattice.pt[0:1]["+($rows-$i)+"][1]"; $y_Value =(10 - $dy * $i + $dy); setAttr ($rowname+".row"+$i) 0; setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".zValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".zValue"); setAttr ($rowname+".row"+$i) 50; select -r $points_1 $points_2; scale -r -p 0 $y_Value 0 50 0 50; setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".zValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".zValue"); setAttr ($rowname+".row"+$i) (-10); select -r $points_1 $points_2; scale -r -p 0 $y_Value 0 0 0 0; setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_1+".zValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".xValue"); setDrivenKeyframe -cd ($rowname+".row"+$i) ($points_2+".zValue"); setAttr ($rowname+".row"+$i) (0); select -cl; } // Scale Y-Attribut => .row1_2-$rows_$rows-1 for ($i=1; $i<=($rows-1); $i++) { $points_1= $lat_name + "Lattice.pt[0:1]["+($rows-$i-1)+":"+($rows-$i)+"][0:1]"; $y_Value =(10 - $dy * $i); setAttr ($rowname+".row"+$i+"_"+($i+1)) 0; setDrivenKeyframe -cd ($rowname+".row"+$i+"_"+($i+1)) ($points_1+".yValue"); setAttr ($rowname+".row"+$i+"_"+($i+1)) 10; select -r $points_1; scale -r -p 0 $y_Value 0 0 $max_lattice_xz_scale 0; setDrivenKeyframe -cd ($rowname+".row"+$i+"_"+($i+1)) ($points_1+".yValue"); setAttr ($rowname+".row"+$i+"_"+($i+1)) -10; select -r $points_1; scale -r -p 0 $y_Value 0 0 ($max_lattice_xz_scale*-1) 0; setDrivenKeyframe -cd ($rowname+".row"+$i+"_"+($i+1)) ($points_1+".yValue"); setAttr ($rowname+".row"+$i+"_"+($i+1)) (0); select -cl; } // Set Keytangent Flat!!! for ($i=0; $i<($rows*4); $i++) { selectKey -add -k -f 0 ($lat_name + "LatticeShape_controlPoints_"+$i+"__xValue"); selectKey -add -k -f 0 ($lat_name + "LatticeShape_controlPoints_"+$i+"__yValue"); selectKey -add -k -f 0 ($lat_name + "LatticeShape_controlPoints_"+$i+"__zValue"); keyTangent -itt flat -ott flat; select -cl; } parent ($lat_name+"LatticeGroup") $tornado_group_name; select -cl; } else { warning("Latticebox present!!! Delete it firsst!!!"); select -cl; } } //-------------------------------------------------------------- proc control_latt () { global string $winName_lat; global string $lat_name; global int $rows; global string $tornado_group_name; string $main = "m_mainWindow"; if (searchObject($lat_name)==0) { if ((confirm_Dialog("Create Lattice?"))=="Yes") { proc_dir("createLattice", "",0); } else { warning("No Latticebox was found!!! Create a Latticebox first!!!"); } } if (searchObject($lat_name)==1) { proc_dir("check", $winName_lat,0); window -t "Control the Tornado-Shape" -wh 466 275 $winName_lat; scrollLayout -hst 0 -vst 16 -childResizable true -w 455; columnLayout -adjustableColumn true; text -label "Emitter Control Functions:"; rowColumnLayout -nc 1 -cw 1 355 ($main); rowColumnLayout -cw 1 300 -cw 2 50 -nc 2; attrFieldSliderGrp -l ("Scale Up/Down") -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min (-10) -max 10 -at ($lat_name+"LatticeGroup"+".ScaleUP"); button -w 50 -label ("Set Key") -c ("setKeyframe "+$lat_name+"LatticeGroup"+".ScaleUP;"); int $i; for ($i=1; $i<=(getAttr ($tornado_group_name+".Number_of_Rows")); $i++) { attrFieldSliderGrp -l ("Scale Row "+$i) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min (-10) -max 50 -at ($lat_name+"LatticeGroup.row"+$i); button -w 50 -label ("Set Key") -c ("setKeyframe "+$lat_name+"LatticeGroup.row"+$i+";"); } for ($i=1; $i<=(getAttr ($tornado_group_name+".Number_of_Rows")-1); $i++) { attrFieldSliderGrp -l ("Scale Row "+$i+" up/down") -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min (-10) -max 10 -at ($lat_name+"LatticeGroup.row"+$i+"_"+($i+1)); button -w 50 -label ("Set Key") -c ("setKeyframe "+$lat_name+"LatticeGroup.row"+$i+"_"+($i+1)+";"); } setParent $main; button -l "close this Window..." -c "deleteUI -window $winName_lat"; showWindow $winName_lat; } } //-------------------------------------------------------------- proc delete_latt () { global string $zyl_name; global string $tornado_group_name; if ((confirm_Dialog("Delete Lattice Box?"))=="Yes") { select -r $zyl_name; delete -ch; select -cl; setAttr ($tornado_group_name+".Surface_already_History_deleted") 1; setAttr ($tornado_group_name+".Lattice_present") 0; } } //-------------------------------------------------------------- proc createNewTornadoGroup(int $del) { global string $tornado_group_name; global string $main_Name; global int $rows; if($del==1) { searchObjectandDelete($tornado_group_name); } if (searchObject($tornado_group_name)==0) { // Default Group for Tornado CreateEmptyGroup; //group; xform -os -piv 0 0 0; string $namerSel[] = `ls -sl`; int $namerSiz = `size $namerSel`; rename $namerSel[0] $tornado_group_name; select -cl; // spaceLocator -n ($main_Name+"_locator") -p 0 0 0; // parent ($main_Name+"_locator") $tornado_group_name; addAttr -ln Lattice_already_created -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Lattice_present -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Lattice_already_up_scaled -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Lattice_Divisions -at long -dv $rows ("|"+$tornado_group_name); addAttr -ln Surface_already_created -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Surface_already_History_deleted -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Number_of_Emitters -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Number_of_Particles -at long -dv 0 ("|"+$tornado_group_name); addAttr -ln Number_of_Rows -at long -dv 0 ("|"+$tornado_group_name); } } //-------------------------------------------------------------- proc createNewSurfaceEmitter() { global string $tornado_group_name; global string $zyl_name; global string $emitter_name; global string $particle_name; float $emitter_rate=5.0; string $n_emitter=$emitter_name+"_"+getAttr($tornado_group_name+".Number_of_Emitters"); string $n_part=$particle_name+"_"+getAttr($tornado_group_name+".Number_of_Particles"); string $n_partS=$particle_name+"_Shape_"+getAttr($tornado_group_name+".Number_of_Particles"); if (searchObject($tornado_group_name)==0) { warning("make Step 1 first!!!!"); } else if (searchObject($zyl_name)==0) { warning("make Step 1 first!!!!"); } else { select -r $zyl_name; emitter -type surface -name $n_emitter -r $emitter_rate -sro 1 -nuv 1 -cye none -cyi 1 -spd 5 -srn 0 -nsp 1 -tsp 0 -mxd 0 -mnd 0 -dx 1 -dy 0 -dz 0 -sp 0 ; addAttr -ln "position_to_emit_Particle" -at double -min 0.005 -max 1 -dv 0.005 ("|"+$tornado_group_name+"|"+$zyl_name+"|"+$n_emitter); setAttr -e -keyable true ("|"+$tornado_group_name+"|"+$zyl_name+"|"+$n_emitter+".position_to_emit_Particle"); setAttr ($tornado_group_name+".Number_of_Emitters") (getAttr($tornado_group_name+".Number_of_Emitters")+1); setAttr ($n_emitter+".enableTextureRate") 1; shadingNode -asTexture -n ("ramp_"+$n_emitter) ramp; shadingNode -asUtility -n ("place2dTexture_"+$n_emitter) place2dTexture; connectAttr ("place2dTexture_"+$n_emitter+".outUV") (("ramp_"+$n_emitter)+".uv"); connectAttr ("place2dTexture_"+$n_emitter+".outUvFilterSize") (("ramp_"+$n_emitter)+".uvFilterSize"); connectAttr -f (("ramp_"+$n_emitter)+".outColor") ($n_emitter+".textureRate"); setAttr ("ramp_"+$n_emitter+".type") 1; setAttr ("ramp_"+$n_emitter+".interpolation") 0; removeMultiInstance -break true ("ramp_"+$n_emitter+".colorEntryList[2]"); setAttr ("ramp_"+$n_emitter+".colorEntryList[1].position") (getAttr($n_emitter+".position_to_emit_Particle")); setAttr ("ramp_"+$n_emitter+".colorEntryList[1].color") -type double3 0 0 0; setAttr ("ramp_"+$n_emitter+".colorEntryList[0].color") -type double3 1 1 1; connectAttr -f ($n_emitter+".position_to_emit_Particle") ("ramp_"+$n_emitter+".colorEntryList[1].position"); } } //-------------------------------------------------------------- proc control_Emitter() { global string $winName_emit; global string $emitter_name; global string $tornado_group_name; global int $max_emitter_rate; string $n_emitter; int $i; if ((searchObject($tornado_group_name)==0)||(getAttr($tornado_group_name+".Number_of_Emitters")==0)) { warning("Make other steps first!!!"); } else { proc_dir("check", $winName_emit,0); string $main = "e_mainWindow"; window -t "Control the Emitter" -wh 466 185 $winName_emit; scrollLayout -hst 0 -vst 16 -childResizable true; columnLayout -adjustableColumn true; text -label "Emitter Control Functions:"; rowColumnLayout -nc 1 -cw 1 437 ($main); for ($i=0; $i<(getAttr($tornado_group_name+".Number_of_Emitters")); $i++) { $n_emitter = $emitter_name+"_"+$i; // if ($i==0) {frameLayout -cll true -cl false $n_emitter;} // else {frameLayout -cll true -cl true $n_emitter;} frameLayout -cll true -cl false $n_emitter; rowColumnLayout -cw 1 380 -cw 2 50 -nc 2; attrFieldSliderGrp -l ("Emitter "+$i+" Rate") -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min (0) -max $max_emitter_rate -at ($n_emitter+".rate"); button -w 50 -label ("Set Key") -c ("setKeyframe "+$n_emitter+".rate;"); attrFieldSliderGrp -l ("Max for "+$i) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max 1 -at ($n_emitter+".position_to_emit_Particle"); button -w 50 -label ("Set Key") -c ("setKeyframe "+$n_emitter+".position_to_emit_Particle;"); setParent $main; } button -l "close..." -c ("deleteUI -window "+$winName_emit+";"); showWindow $winName_emit; } } //-------------------------------------------------------------- proc control_Particle() { global string $winName_part; global string $emitter_name; global string $tornado_group_name; global string $particle_name; global int $up_colorentry; global int $round_colorentry; global float $max_round_slider; global float $max_up_slider; global float $upSpeed; global float $roundSpeed; float $max_round_slider1 = 0.1; float $max_up_slider1 = 0.1; /*if ((`about -v`)=="4.0.1") { $max_round_slider1 = $max_round_slider; $max_up_slider1 = $max_up_slider; } else { $max_round_slider1 = 0.1; $max_up_slider1 = 0.1; } */ int $i; int $m; string $n_emitter; string $n_part=$particle_name+"_"+getAttr($tornado_group_name+".Number_of_Particles"); if ((searchObject($tornado_group_name)==0)||(getAttr($tornado_group_name+".Number_of_Particles")==0)) { warning("Make other steps first!!!"); } else { proc_dir("check", $winName_part,0); string $main = "p_mainWindow"; window -t "Control the Particlesystem" -wh 431 455 $winName_part; scrollLayout -hst 0 -vst 16 -childResizable true -w 415; columnLayout -adjustableColumn true; text -label "Particle Control Functions:"; rowColumnLayout -nc 1 -cw 1 400 ($main); for ($i=0; $i<(getAttr($tornado_group_name+".Number_of_Particles")); $i++) { $n_part = $particle_name+"_"+$i; // if (($i==0)&&(getAttr($tornado_group_name+".Number_of_Particles")<=3)) {frameLayout -cll true -cl false $n_part;} // else {frameLayout -cll true -cl true $n_part;} frameLayout -cll true -cl false $n_part; rowColumnLayout -cw 1 395 -nc 1; button -w 250 -label ("Set Initial State") -c ("saveInitialState "+$particle_name+"_"+$i+";"); rowColumnLayout -cw 1 340 -cw 2 50 -nc 2; attrFieldSliderGrp -l ("GoalPP P"+$i) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max 1 -at ($n_part+".control_GoalPP"); button -w 50 -label ("Set Key") -c ("setKeyframe \""+$n_part+".control_GoalPP\";"); attrFieldSliderGrp -l ("Goal Smooth P"+$i) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max 10 -at ($n_part+"Shape.goalSmoothness"); button -w 50 -label (""); for ($m = 0;$m<=($round_colorentry-1);$m++) { attrFieldSliderGrp -l ("Speed P"+$i+"/"+$m) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max $max_round_slider1 -at ($n_part+".roundSpeed"+$m); //$max_round_slider button -w 50 -label ("Set Key") -c ("setKeyframe "+$n_part+".roundSpeed"+$m+";"); } for ($m = 0;$m<=($round_colorentry-1);$m++) { attrFieldSliderGrp -l ("Postion P"+$i+"/"+$m) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max 1 -at ("ramp_"+$n_part+"_vInc.colorEntryList["+$m+"].position"); button -w 50 -label ("Set Key") -c ("setKeyframe ramp_"+$n_part+"_vInc.colorEntryList["+$m+"].position;"); } for ($m = 0;$m<=($up_colorentry-1);$m++) { attrFieldSliderGrp -l ("Up Speed P"+$i+"/"+$m) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max $max_up_slider1 -at ($n_part+".upSpeed"+$m); //$max_up_slider button -w 50 -label ("Set Key") -c ("setKeyframe "+$n_part+".upSpeed"+$m+";"); } for ($m = 0;$m<=($up_colorentry-1);$m++) { attrFieldSliderGrp -l ("Up Postion P"+$i+"/"+$m) -adjustableColumn 3 -columnAlign 1 "right" -columnWidth 1 84 -columnWidth 4 1 -min 0 -max 1 -at ("ramp_"+$n_part+"_uInc.colorEntryList["+$m+"].position"); button -w 50 -label ("Set Key") -c ("setKeyframe ramp_"+$n_part+"_uInc.colorEntryList["+$m+"].position;"); } setParent $main; } button -l "close..." -c ("deleteUI $winName_part;"); showWindow $winName_part; } } //-------------------------------------------------------------- proc createNewParticle() { global string $tornado_group_name; global string $zyl_name; global string $emitter_name; global string $particle_name; global int $up_colorentry; global int $round_colorentry; global float $upSpeed; global float $roundSpeed; string $n_emitter=$emitter_name+"_"+((getAttr($tornado_group_name+".Number_of_Emitters")-1)); string $n_part=$particle_name+"_"+getAttr($tornado_group_name+".Number_of_Particles"); string $n_partS=$particle_name+"_"+(getAttr($tornado_group_name+".Number_of_Particles"))+"Shape"; if (searchObject($tornado_group_name)==0) { warning("make Step 1 first!!!!"); } else if (searchObject($zyl_name)==0) { warning("make Step 1 first!!!!"); } else if (searchObject($n_emitter)==0) { warning("First create an emitter!!!"); } else { particle -n $n_part; connectDynamic -em $n_emitter $n_part; parent $n_part $tornado_group_name; setAttr ($tornado_group_name+".Number_of_Particles") (getAttr($tornado_group_name+".Number_of_Particles")+1); setAttr ($n_partS+".lifespanMode") 3; goal -w 1 -utr 0 -g $zyl_name $n_part; addAttr -ln ("control_GoalPP") -at double -min 0.0 -max 1.0 -dv 1 ("|"+$tornado_group_name+"|"+$n_part); setAttr -e -keyable true ("|"+$tornado_group_name+"|"+$n_part+".control_GoalPP"); for ($m = 0;$m<=($up_colorentry-1);$m++) { addAttr -ln ("upSpeed"+$m) -at double -min 0.0 -max 1 -dv $roundSpeed ("|"+$tornado_group_name+"|"+$n_part); setAttr -e -keyable true ("|"+$tornado_group_name+"|"+$n_part+".upSpeed"+$m); } for ($m = 0;$m<=($round_colorentry-1);$m++) { addAttr -ln ("roundSpeed"+$m) -at double -min 0.0 -max 1 -dv $roundSpeed ("|"+$tornado_group_name+"|"+$n_part); setAttr -e -keyable true ("|"+$tornado_group_name+"|"+$n_part+".roundSpeed"+$m); } // Add custom Attribut addAttr -ln goalU -dt doubleArray $n_partS; addAttr -ln goalU0 -dt doubleArray $n_partS; addAttr -ln goalV -dt doubleArray $n_partS; addAttr -ln goalV0 -dt doubleArray $n_partS; addAttr -ln parentU -dt doubleArray $n_partS; addAttr -ln parentU0 -dt doubleArray $n_partS; addAttr -ln parentV -dt doubleArray $n_partS; addAttr -ln parentV0 -dt doubleArray $n_partS; addAttr -ln uInc0 -dt doubleArray $n_partS; addAttr -ln uInc -dt doubleArray $n_partS; setAttr -e -keyable true ($n_partS+".uInc"); addAttr -ln vInc0 -dt doubleArray $n_partS; addAttr -ln vInc -dt doubleArray $n_partS; setAttr -e -keyable true ($n_partS+".vInc"); // Add Creation and Runtime Expression cycleCheck -e off; string $creation_String = $n_partS + ".goalV=" + $n_partS + ".parentV;\r\n" + $n_partS + ".goalU=" + $n_partS + ".parentU;"; string $creation_Name = "creation_"+((getAttr($tornado_group_name+".Number_of_Particles"))-1); dynExpression -n $creation_Name -s $creation_String -c $n_partS; string $runtime_String= $n_partS+".goalV+="+$n_partS+".vInc;\r\n"+$n_partS+".goalU+="+$n_partS+".uInc;\r\nif("+$n_partS+".goalV>1)"+$n_partS+".goalV-=1;\r\n"+$n_partS+".goalU=max("+$n_partS+".goalU, "+$n_partS+".uInc);\r\nif("+$n_partS+".goalU>1)"+$n_partS+".lifespanPP=0;"; connectAttr -f ($n_part+".control_GoalPP") ($n_partS+".goalWeight[0]") ; string $runtime_Name = "runtime_"+((getAttr($tornado_group_name+".Number_of_Particles"))-1); dynExpression -n $runtime_Name -s $runtime_String -r $n_partS; // Add U/V-Inc-Ramp shadingNode -asTexture -n ("ramp_"+$n_part+"_uInc") ramp; shadingNode -asUtility -n ("place2dTexture_"+$n_emitter+"_uInc") place2dTexture; shadingNode -asTexture -n ("ramp_"+$n_part+"_vInc") ramp; shadingNode -asUtility -n ("place2dTexture_"+$n_emitter+"_vInc") place2dTexture; arrayMapper -target $n_partS -destAttr uInc -inputU goalU -inputV ageNormalized -mt ("ramp_"+$n_part+"_uInc"); arrayMapper -target $n_partS -destAttr vInc -inputU goalU -inputV ageNormalized -mt ("ramp_"+$n_part+"_vInc"); setAttr ("ramp_"+$n_part+"_uInc.type") 1; setAttr ("ramp_"+$n_part+"_vInc.type") 1; setAttr ("ramp_"+$n_part+"_uInc.colorEntryList[0].color") -type double3 $upSpeed $upSpeed $upSpeed; setAttr ("ramp_"+$n_part+"_vInc.colorEntryList[0].color") -type double3 $roundSpeed $roundSpeed $roundSpeed; removeMultiInstance -break true ("ramp_"+$n_part+"_uInc.colorEntryList[2]"); removeMultiInstance -break true ("ramp_"+$n_part+"_uInc.colorEntryList[1]"); removeMultiInstance -break true ("ramp_"+$n_part+"_vInc.colorEntryList[2]"); removeMultiInstance -break true ("ramp_"+$n_part+"_vInc.colorEntryList[1]"); for ($m = 1;$m<=($up_colorentry-1);$m++) { setAttr ("ramp_"+$n_part+"_uInc.colorEntryList["+$m+"].color") -type double3 $upSpeed $upSpeed $upSpeed; setAttr ("ramp_"+$n_part+"_uInc.colorEntryList["+$m+"].position") ((1.0/($up_colorentry-1))*$m); } for ($m = 1;$m<=($round_colorentry-1);$m++) { setAttr ("ramp_"+$n_part+"_vInc.colorEntryList["+$m+"].color") -type double3 $roundSpeed $roundSpeed $roundSpeed; setAttr ("ramp_"+$n_part+"_vInc.colorEntryList["+$m+"].position") ((1.0/($round_colorentry-1))*$m); } for ($i=0; $i<=$up_colorentry-1; $i++) { connectAttr -f ($n_part+".upSpeed"+$i) ("ramp_"+$n_part+"_uInc.colorEntryList["+$i+"].colorR") ; connectAttr -f ($n_part+".upSpeed"+$i) ("ramp_"+$n_part+"_uInc.colorEntryList["+$i+"].colorG") ; connectAttr -f ($n_part+".upSpeed"+$i) ("ramp_"+$n_part+"_uInc.colorEntryList["+$i+"].colorB") ; } for ($i=0; $i<=$round_colorentry-1; $i++) { connectAttr -f ($n_part+".roundSpeed"+$i) ("ramp_"+$n_part+"_vInc.colorEntryList["+$i+"].colorR") ; connectAttr -f ($n_part+".roundSpeed"+$i) ("ramp_"+$n_part+"_vInc.colorEntryList["+$i+"].colorG") ; connectAttr -f ($n_part+".roundSpeed"+$i) ("ramp_"+$n_part+"_vInc.colorEntryList["+$i+"].colorB") ; } } } //-------------------------------------------------------------- proc deleteAllEmitter(int $question) { global string $emitter_name; global string $tornado_group_name; global int $q_confirm; string $n_emitter; int $question; if ($question==0) { $q_confirm=1; } if ((searchObject($tornado_group_name)==0)||(getAttr($tornado_group_name+".Number_of_Emitters")==0)) { warning("There are no Emitter"); } else { if ((confirm_Dialog("Delete ALL Emitter?"))=="Yes") { for ($i = 0;$i<(getAttr($tornado_group_name+".Number_of_Emitters"));$i++) { $n_part=$emitter_name+"_"+$i; select $n_part; delete; select ("ramp_"+$n_part); delete; select ("place2dTexture_"+$n_part); delete; select -cl; } setAttr ($tornado_group_name+".Number_of_Emitters") 0; } } $q_confirm=0; } //-------------------------------------------------------------- proc deleteAllParticle(int $question) { global string $particle_name; global string $tornado_group_name; global int $q_confirm; string $n_part; int $question; if ($question==0) { $q_confirm=1; } if ((searchObject($tornado_group_name)==0)||(getAttr($tornado_group_name+".Number_of_Particles")==0)) { warning("There are no Particles"); } else { if ((confirm_Dialog("Delete ALL Particles?"))=="Yes") { for ($i = 0;$i<(getAttr($tornado_group_name+".Number_of_Particles"));$i++) { $n_part=$particle_name+"_"+$i; select $n_part; delete; select ("ramp_"+$n_part+"_uInc"); delete; select ("ramp_"+$n_part+"_vInc"); delete; } setAttr ($tornado_group_name+".Number_of_Particles") 0; } } $q_confirm=0; } //-------------------------------------------------------------- proc newTornado() { global string $tornado_group_name; if ((confirm_Dialog("New Tornado?"))=="Yes") { if (searchObject($tornado_group_name)==1) { proc_dir("delTornado", "",0); } proc_dir("createNewTornadoGroup", "",0); } } //-------------------------------------------------------------- proc delTornado(int $question) { global string $emitter_name; global string $tornado_group_name; global int $q_confirm; global string $zyl_name; string $n_emitter; int $question; int $i; if ($question==0) { $q_confirm=1; } if ((confirm_Dialog("Delete Tornado?"))=="Yes") { headsUP(1, 1); headsUP(2, 1); if (searchObject($zyl_name)==1) { layerEditorDeleteLayer ("layer_"+$zyl_name); } proc_dir("deleteAllParticle" , "",0); proc_dir("deleteAllEmitter" , "",0); // Delete Torndao-Group select -r $tornado_group_name; delete; // performCleanUpScene; warning("You should open a new Scene or perform a File / Optimize Scene Size !!!!"); } $q_confirm=0; } //-------------------------------------------------------------- proc toggle_some() { //toggleUIComponentVisibility "Command Line"; toggleUIComponentVisibility "Help Line"; toggleUIComponentVisibility "Status Line"; toggleUIComponentVisibility "Shelf"; //toggleUIComponentVisibility "Range Slider"; //toggleUIComponentVisibility "Time Slider"; updatePrefsMenu; } //-------------------------------------------------------------- proc toggleDisplayObj() { string $namerSel[] = `ls -sl`; if (getAttr($namerSel[0]+".visibility")==1) { HideSelectedObjects; } else { setAttr ($namerSel[0]+".visibility") 1; } select -cl; } //-------------------------------------------------------------- proc toggleShadingObj() { global string $zyl_name; if (getAttr ("layer_"+$zyl_name+".shading")==1) { setAttr ("layer_"+$zyl_name+".shading") 0; } else { setAttr ("layer_"+$zyl_name+".shading") 1; } } //-------------------------------------------------------------- proc toggleWireshadingObj() { global string $zyl_name; select $zyl_name; string $panel = `getPanel -wf`; modelEditor -e -wos ( !`modelEditor -q -wos $panel` ) $panel; select -cl; } //-------------------------------------------------------------- proc toggleSmoothObj() { global string $zyl_name; select -r $zyl_name; displaySmoothness -divisionsU 3 -divisionsV 3 -pointsWire 16 -pointsShaded 4; subdivDisplaySmoothness -smoothness 3; select -cl; } //-------------------------------------------------------------- proc toggleNSmoothObj() { global string $zyl_name; select -r $zyl_name; displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1; subdivDisplaySmoothness -smoothness 1; select -cl; } //-------------------------------------------------------------- proc display_Control () { global string $winName_disp; global string $particle_name; global string $tornado_group_name; global string $zyl_name; string $main = "t_mainWindow"; string $checkBox_Emit; string $checkBox_Part; proc_dir("check", $winName_disp,0); if(searchObject($tornado_group_name)==1) { window -title "Display Control Window" -wh 220 239 $winName_disp; columnLayout -adjustableColumn true; text -label "Tornado Functions:"; rowColumnLayout -nc 1 -cw 1 210 ($main); frameLayout -cll true -w 210 ("1. UI-Controls"); rowColumnLayout -nc 2; button -label "Hide UI" -c ("proc_dir(\"toggle_some\",\" \",0);"); button -label "Attribute Editor" -c "ToggleAttributeEditor;"; button -label "ToolSettings" -c "ToggleToolSettings;"; button -label "Channelbox" -c "ToggleChannelsLayers;"; setParent $main; frameLayout -cll true -w 210 ("2. Heads-UP-Displays"); rowColumnLayout -nc 2; if (eval("headsUpDisplay -ex \"HUD_Emitter\";")==1) { $checkBox_Emit = `checkBox -v on -cc ("headsUP(1,0)") -label "toggle Emitter"`; } else { $checkBox_Emit = `checkBox -v off -cc ("headsUP(1,0)") -label "toggle Emitter"`; } if (eval("headsUpDisplay -ex \"HUD_Particle\";")==1) { $checkBox_Part = `checkBox -v on -cc ("headsUP(2,0)") -label "toggle Particle"`; } { $checkBox_Part = `checkBox -v off -cc ("headsUP(2,0)") -label "toggle Particle"`; } $checkBox_Frame = `checkBox -cc ("ToggleFrameRate;") -label "toggle Framerate"`; setParent $main; if(searchObject($zyl_name)==0) { frameLayout -vis off -cll true -w 210 ("3. Controls to toggle"); rowColumnLayout -nc 2; checkBox -label ("Toggle Shading") -cc ("proc_dir(\"toggleShadingObj\",\" \",0);"); checkBox -label ("Toggle Wire") -cc ("proc_dir(\"toggleWireshadingObj\",\" \",0);"); button -label ("Smooth") -c ("proc_dir(\"toggleSmoothObj\",\" \",0);"); button -label ("Less Smooth") -c ("proc_dir(\"toggleNSmoothObj\",\" \",0);"); for ($i = 0;$i<(getAttr($tornado_group_name+".Number_of_Particles"));$i++) { checkBox -label ("Hide Particle "+$i) -cc ("select "+$particle_name+"_"+$i+"; proc_dir(\"toggleDisplayObj\" ,\" \",0);"); } setParent $main; } else { frameLayout -vis on -cll true -w 210 ("3. Controls to toggle"); rowColumnLayout -nc 2; checkBox -label ("Toggle Shading") -cc ("proc_dir(\"toggleShadingObj\",\" \",0);"); checkBox -label ("Toggle Wire") -cc ("proc_dir(\"toggleWireshadingObj\",\" \",0);"); button -label ("Smooth") -c ("proc_dir(\"toggleSmoothObj\",\" \",0);"); button -label ("Less Smooth") -c ("proc_dir(\"toggleNSmoothObj\",\" \",0);"); for ($i = 0;$i<(getAttr($tornado_group_name+".Number_of_Particles"));$i++) { checkBox -label ("Hide Particle "+$i) -cc ("select "+$particle_name+"_"+$i+"; proc_dir(\"toggleDisplayObj\" ,\" \",0);"); } setParent $main; } button -l "close this Window..." -c "deleteUI -window $winName_disp"; showWindow $winName_disp; } else { warning("No Tornadogroup found!!! Name should be: "+$tornado_group_name); } } //-------------------------------------------------------------- global proc openHelp (string $title, string $text) { global string $winName_help; int $uiWidth = 250; if ( `window -exists $winName_help` ) deleteUI $winName_help; window -maximizeButton false -resizeToFitChildren false -title $title //"About tornadoMaker" -wh 290 238 -iconName $title $winName_help; //"About tornadoMaper" string $help_form = `formLayout -numberOfDivisions 100`; string $help_scroll = `scrollLayout -hst 16 -vst 16 -childResizable true -minChildWidth $uiWidth`; columnLayout -adjustableColumn true -rowSpacing 6; rowLayout -numberOfColumns 1 -cat 1 "left" 5; text text_in; setParent ..; setParent ..; setParent ..; string $help_button = `button -label "Close" -command ("deleteUI "+$winName_help)`; // set form layouts formLayout -edit -attachForm $help_scroll "top" 4 -attachForm $help_scroll "left" 4 -attachControl $help_scroll "bottom" 4 $help_button -attachForm $help_scroll "right" 4 -attachNone $help_button "top" -attachForm $help_button "left" 4 -attachForm $help_button "bottom" 4 -attachForm $help_button "right" 4 $help_form; text -e -label $text text_in; showWindow $winName_help; } //-------------------------------------------------------------- global proc int[] nr_Emitter () { global string $tornado_group_name; global string $emitter_name; int $value[1]; $value[0]=getAttr($tornado_group_name+".Number_of_Emitters"); $value[1]=0; if ($value[0]>0) { for($i=0; $i <= ($value[0]-1); $i++) { $value[1]=$value[1]+getAttr($emitter_name+"_"+$i+".rate"); } } return ($value); } //-------------------------------------------------------------- global proc int[] nr_Particle () { global string $tornado_group_name; global string $particle_name; int $value[]; $value[0]=getAttr($tornado_group_name+".Number_of_Particles"); if ($value[0]>0) { for($i=0; $i <= ($value[0]-1); $i++) { $value[1]+=getAttr($particle_name+"_"+$i+"Shape.count"); } } return ($value); } //-------------------------------------------------------------- global proc headsUP (int $which, int $off) { if($off==1) { headsUpDisplay -rp 4 0; headsUpDisplay -rp 4 1; } else { if ($which==1) { if (eval("headsUpDisplay -ex \"HUD_Emitter\";")==0) { headsUpDisplay -rp 4 0; headsUpDisplay -section 4 -block 0 -blockSize "small" -label "Emitter" -labelFontSize "small" -command "nr_Emitter()" -event "SelectionChanged" HUD_Emitter; } else { headsUpDisplay -rp 4 0; } } else if ($which==2) { if (eval("headsUpDisplay -ex \"HUD_Particle\";")==0) { headsUpDisplay -rp 4 1; headsUpDisplay -section 4 -block 1 -blockSize "small" -label "Particle" -labelFontSize "small" -command "nr_Particle()" -event "timeChanged" HUD_Particle; } else { headsUpDisplay -rp 4 1; } } } } //-------------------------------------------------------------- proc showStatus (string $whereTOwrite, string $whatTOwrite) { textField -edit -text $whatTOwrite $whereTOwrite; //Window | ColumnLayoutName | StatusLineName; } //-------------------------------------------------------------- proc string ask_for_String (string $forwhat, string $ifnot) { string $answere; string $result = `promptDialog -tx $ifnot -message $forwhat -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString $ifnot`; if ($result == "OK") { $answere = `promptDialog -q`; } else { $answere = $ifnot; } return $answere; } //-------------------------------------------------------------- proc enterSomething(string $temp_string, int $which) { global string $winName_prefs; global string $tempString; global string $new_main_Name; global int $new_rows; global int $new_t_Spans; global int $new_t_Sections; global int $new_max_emitter_rate; global int $new_max_lattice_xz_scale; global int $new_max_lattice_y_scale; global int $new_up_colorentry; global int $new_round_colorentry; global float $new_upSpeed; global float $new_roundSpeed ; global float $new_max_round_slider; global float $new_max_up_slider; global string $main_Name; global int $rows; global int $t_Spans; global int $t_Sections; global int $max_emitter_rate; global int $max_lattice_xz_scale; global int $max_lattice_y_scale; global int $up_colorentry; global int $round_colorentry; global float $upSpeed; global float $roundSpeed; global float $max_round_slider; global float $max_up_slider; switch ($which) { case 1: { $new_main_Name = ask_for_String("Enter name:", $main_Name); if (($new_main_Name!=$main_Name)&&($temp_string!="No")) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New Name: \""+$new_main_Name+"\"! Press Update or New!")); } } break; case 2: { $new_rows = ask_for_String("Enter Lattic Divisions:", $rows); if (($new_rows!=$rows)&&($new_rows>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New Lattice Divs: \""+$new_rows+"\"! Press Update or New!")); } else if ($new_rows==0) { $new_rows=$rows; } } break; case 3: { $new_max_lattice_y_scale = ask_for_String("Enter max Scale Y:", $max_lattice_y_scale); if (($new_max_lattice_y_scale!=$max_lattice_y_scale)&&($new_max_lattice_y_scale>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_max_lattice_y_scale+"\"! Press Update or New!")); } else if ($new_max_lattice_y_scale==0) { $new_max_lattice_y_scale=$max_lattice_y_scale; } } break; case 4: { $new_max_lattice_xz_scale = ask_for_String("Enter max Scale XZ:", $max_lattice_xz_scale); if (($new_max_lattice_xz_scale!=$max_lattice_xz_scale)&&($new_max_lattice_xz_scale>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_max_lattice_xz_scale+"\"! Press Update or New!")); } else if ($new_max_lattice_xz_scale==0) { $new_max_lattice_xz_scale=$max_lattice_xz_scale; } } break; case 5: { $new_t_Spans = ask_for_String("Enter Cylinder Spans:", $t_Spans); if (($new_t_Spans!=$t_Spans)&&($new_t_Spans>3)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_t_Spans+"\"! Press Update or New!")); } else if (($new_t_Spans==0)||($new_t_Spans<=3)) { $new_t_Spans=$t_Spans; } } break; case 6: { $new_t_Sections = ask_for_String("Enter Cylinder Sections:", $t_Sections); if (($new_t_Sections!=$t_Sections)&&($new_t_Sections>3)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_t_Sections+"\"! Press Update or New!")); } else if (($new_t_Sections==0)||($new_t_Sections<=3)) { $new_t_Sections=$t_Sections; } } break; case 7: { $new_up_colorentry = ask_for_String("Enter max Colorentry UP:", $up_colorentry); if (($new_up_colorentry!=$up_colorentry)&&($new_up_colorentry>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New UP Entry: \""+$new_up_colorentry+"\"! Press Update or New!")); } else if ($new_up_colorentry==0) { $new_up_colorentry=$up_colorentry; } } break; case 8: { $new_round_colorentry = ask_for_String("Enter max Colorentry Round:", $round_colorentry); if (($new_round_colorentry!=$round_colorentry)&&($new_round_colorentry>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New UP Entry: \""+$new_round_colorentry+"\"! Press Update or New!")); } else if ($new_round_colorentry==0) { $new_round_colorentry=$round_colorentry; } } break; case 9: { $new_upSpeed = ask_for_String("Enter Default UP Speed:", $upSpeed); if (($new_upSpeed!=$upSpeed)&&($new_upSpeed>0.0)&&($new_upSpeed<1.0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_upSpeed+"\"! Press Update or New!")); } else if (($new_upSpeed==0)||($new_upSpeed>1.0)) { $new_upSpeed=$upSpeed; } } break; case 10: { $new_roundSpeed = ask_for_String("Enter Default Round Speed:", $roundSpeed); if (($new_roundSpeed!=$roundSpeed)&&($new_roundSpeed>0.0)&&($new_roundSpeed<1.0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New max Y: \""+$new_roundSpeed+"\"! Press Update or New!")); } else if (($new_roundSpeed==0)||($new_roundSpeed>1.0)) { $new_roundSpeed=$roundSpeed; } } break; case 11: { $new_max_emitter_rate = ask_for_String("Enter max Emitterrate:", $max_emitter_rate); if (($new_max_emitter_rate!=$max_emitter_rate)&&($new_max_emitter_rate>0)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New Rate: \""+$new_max_emitter_rate+"\"! Press Update or New!")); } else if ($new_max_emitter_rate==0) { $new_max_emitter_rate=$max_emitter_rate; } } break; case 12: { $tempString= "New - Old"+"\n\n"+ "Name: "+$new_main_Name+" - "+$main_Name+"\n"+ "Rows: "+$new_rows+" - "+$rows+"\n"+ "Lattice Y Scale: "+$new_max_lattice_y_scale+" - "+$max_lattice_y_scale+"\n"+ "Lattice XY Scale: "+$new_max_lattice_xz_scale+" - "+$max_lattice_xz_scale+"\n"+ "Cylinder Spans: "+$new_t_Spans+" - "+ $t_Spans+"\n"+ "Cylinder Sections: "+$new_t_Sections +" - "+ $t_Sections+"\n"+ "UP Entrys: "+$new_up_colorentry+" - "+$up_colorentry+"\n"+ "Round Entrys: "+$new_round_colorentry+" - "+$round_colorentry+"\n"+ "Max UP Slider: "+$new_max_up_slider+" - "+$max_up_slider+"\n"+ "Max Round Slider: "+$new_max_round_slider+" - "+$max_round_slider+"\n"+ "Up Speed: "+$new_upSpeed+" - "+$upSpeed+"\n"+ "Round Speed: "+$new_roundSpeed+" - "+$roundSpeed+"\n"+ "Emitter Rate: "+$new_max_emitter_rate+" - "+$max_emitter_rate; openHelp ("New/Old Values", $tempString); } break; //global float $max_round_slider; //global float $max_up_slider; case 13: { $new_max_up_slider = ask_for_String("Enter max value for UP-Speed Slider:", $max_up_slider); if (($new_max_up_slider!=$max_up_slider)&&($new_max_up_slider>0.0)&&($new_max_up_slider<0.5)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New UP Slider: \""+$new_max_up_slider+"\"! Press Update or New!")); } else if (($new_max_up_slider==0)||($new_max_up_slider>0.5)) { $new_max_up_slider=$max_up_slider; } } break; case 14: { $new_max_round_slider = ask_for_String("Enter max value for UP-Speed Slider:", $max_round_slider); if (($new_max_round_slider!=$max_round_slider)&&($new_max_round_slider>0.0)&&($new_max_round_slider<0.5)) { showStatus($winName_prefs+"|prefs_ColumnLayout|tornado_name", ("New UP Slider: \""+$new_max_round_slider+"\"! Press Update or New!")); } else if (($new_max_round_slider==0)||($new_max_round_slider>0.5)) { $new_max_round_slider=$max_round_slider; } } break; } } //-------------------------------------------------------------- proc update_Globals (int $question) { // New! global string $new_main_Name; global int $new_rows; global int $new_t_Spans; global int $new_t_Sections; global int $new_max_emitter_rate; global int $new_max_lattice_xz_scale; global int $new_max_lattice_y_scale; global int $new_up_colorentry; global int $new_round_colorentry; global float $new_upSpeed; global float $new_roundSpeed ; global float $new_max_round_slider; global float $new_max_up_slider; // active Globals global string $main_Name; global int $rows; global int $t_Spans; global int $t_Sections; global int $max_emitter_rate; global int $max_lattice_xz_scale; global int $max_lattice_y_scale; global int $up_colorentry; global int $round_colorentry; global float $upSpeed; global float $max_round_slider; global float $max_up_slider; // pre global string $group_pre; global string $zyl_pre; global string $lat_pre; global string $emitter_pre; global string $particle_pre; // names global string $tornado_group_name; global string $zyl_name; global string $lat_name; global string $emitter_name; global string $particle_name; // set to new values!!! if($question==1) { if ((confirm_Dialog("Really Update?"))=="Yes") { $main_Name = $new_main_Name ; $rows = $new_rows ; $t_Spans = $new_t_Spans ; $t_Sections = $new_t_Sections ; $max_emitter_rate = $new_max_emitter_rate ; $max_lattice_xz_scale = $new_max_lattice_xz_scale ; $max_lattice_y_scale = $new_max_lattice_y_scale ; $up_colorentry = $new_up_colorentry ; $round_colorentry = $new_round_colorentry ; $upSpeed = $new_upSpeed ; $max_round_slider = $new_max_round_slider ; $max_up_slider = $new_max_up_slider ; $tornado_group_name = $group_pre + $main_Name; $zyl_name = $main_Name + $zyl_pre; $lat_name = $main_Name + $lat_pre; $emitter_name = $main_Name + $emitter_pre; $particle_name = $main_Name + $particle_pre; } } else if($question==2) { if ((confirm_Dialog("New Tornado?"))=="Yes") { $main_Name = $new_main_Name ; $rows = $new_rows ; $t_Spans = $new_t_Spans ; $t_Sections = $new_t_Sections ; $max_emitter_rate = $new_max_emitter_rate ; $max_lattice_xz_scale = $new_max_lattice_xz_scale ; $max_lattice_y_scale = $new_max_lattice_y_scale ; $up_colorentry = $new_up_colorentry ; $round_colorentry = $new_round_colorentry ; $upSpeed = $new_upSpeed ; $max_round_slider = $new_max_round_slider ; $max_up_slider = $new_max_up_slider ; $tornado_group_name = $group_pre + $main_Name; $zyl_name = $main_Name + $zyl_pre; $lat_name = $main_Name + $lat_pre; $emitter_name = $main_Name + $emitter_pre; $particle_name = $main_Name + $particle_pre; if (searchObject($tornado_group_name)==1) { proc_dir("delTornado", "",0); } proc_dir("createNewTornadoGroup", "",0); } } else if($question==3) { $main_Name = $new_main_Name ; $rows = $new_rows ; $t_Spans = $new_t_Spans ; $t_Sections = $new_t_Sections ; $max_emitter_rate = $new_max_emitter_rate ; $max_lattice_xz_scale = $new_max_lattice_xz_scale ; $max_lattice_y_scale = $new_max_lattice_y_scale ; $up_colorentry = $new_up_colorentry ; $round_colorentry = $new_round_colorentry ; $upSpeed = $new_upSpeed ; $max_round_slider = $new_max_round_slider ; $max_up_slider = $new_max_up_slider ; $tornado_group_name = $group_pre + $main_Name; $zyl_name = $main_Name + $zyl_pre; $lat_name = $main_Name + $lat_pre; $emitter_name = $main_Name + $emitter_pre; $particle_name = $main_Name + $particle_pre; } } //-------------------------------------------------------------- proc prefs_control_Window () { global string $winName_prefs; global string $main_Name; //Def: "tornado"; global string $group_pre; //Def: "group_"; global string $zyl_pre; //Def: "_Surface"; global string $lat_pre; //Def: "_Lattice"; global string $emitter_pre; //Def: "_Emitter"; global string $particle_pre; //Def: "_Particle"; global string $tornado_group_name; // $tornado_group_name = $group_pre + $main_Name; global string $zyl_name; // $zyl_name = $main_Name + $zyl_pre; global string $lat_name; // $lat_name = $main_Name + $lat_pre; global string $emitter_name; // $emitter_name = $main_Name + $emitter_pre; global string $particle_name; // $particle_name = $main_Name + $particle_pre; proc_dir("check", $winName_prefs,0); window -title "Prefs for tornadoMaker" -wh 224 252 $winName_prefs; columnLayout prefs_ColumnLayout; text -label "!!! Handle settings with care !!!"; frameLayout -labelVisible false -marginWidth 5 -marginHeight 5; rowColumnLayout -numberOfColumns 2; button -label "Set Name" -c ("proc_dir(\"enterSomething\",\" \",1);"); button -label "Latice Divs" -c ("proc_dir(\"enterSomething\",\" \",2);"); button -label "Max Latt. Y" -c ("proc_dir(\"enterSomething\",\" \",3);"); button -label "Max Latt. XZ" -c ("proc_dir(\"enterSomething\",\" \",4);"); button -label "Cyl. Spans" -c ("proc_dir(\"enterSomething\",\" \",5);"); button -label "Cyl. Sections" -c ("proc_dir(\"enterSomething\",\" \",6);"); button -label "max C-Entry UP" -c ("proc_dir(\"enterSomething\",\" \",7);"); button -label "max C-Entry Round" -c ("proc_dir(\"enterSomething\",\" \",8);"); /* button -label "max Slider UP" -c ("proc_dir(\"enterSomething\",\" \",13);"); button -label "max Slider Round" -c ("proc_dir(\"enterSomething\",\" \",14);"); button -label "Default UP" -c ("proc_dir(\"enterSomething\",\" \",9);"); button -label "Default Round" -c ("proc_dir(\"enterSomething\",\" \",10);"); */ button -label "max Emitter Rate" -c ("proc_dir(\"enterSomething\",\" \",11);"); button -label "show All" -c ("proc_dir(\"enterSomething\",\" \",12);"); setParent ($winName_prefs+"|prefs_ColumnLayout"); frameLayout -labelVisible false -marginWidth 5 -marginHeight 5; rowColumnLayout -numberOfColumns 2; button -label "Update" -c ("proc_dir(\"update_Globals\",\" \",1);"); button -label "New" -c ("proc_dir(\"update_Globals\",\" \",2);"); button -label "Help!" -c ("openHelp (\"Preferences Help\", $help_instructions);"); button -label "Close" -c("deleteUI $winName_prefs;"); setParent ($winName_prefs+"|prefs_ColumnLayout"); textField -text ("Name by now: \""+$main_Name+"\"") -editable false -width 215 tornado_name; showWindow $winName_prefs; } //-------------------------------------------------------------- global proc proc_dir(string $which_proc, string $temp_string, int $temp_int) { if ($which_proc=="check") { check ($temp_string) ; } else if ($which_proc=="createCylinder") { createCylinder () ; } else if ($which_proc=="createLattice") { createLattice () ; } else if ($which_proc=="control_latt") { control_latt () ; } else if ($which_proc=="delete_latt") { delete_latt () ; } else if ($which_proc=="createNewTornadoGroup") { createNewTornadoGroup ($temp_int) ; } else if ($which_proc=="createNewSurfaceEmitter"){ createNewSurfaceEmitter () ; } else if ($which_proc=="control_Emitter") { control_Emitter () ; } else if ($which_proc=="control_Particle") { control_Particle () ; } else if ($which_proc=="createNewParticle") { createNewParticle () ; } else if ($which_proc=="deleteAllEmitter") { deleteAllEmitter ($temp_int) ; } else if ($which_proc=="deleteAllParticle") { deleteAllParticle ($temp_int) ; } else if ($which_proc=="newTornado") { newTornado () ; } else if ($which_proc=="delTornado") { delTornado ($temp_int) ; } else if ($which_proc=="toggle_some") { toggle_some () ; } else if ($which_proc=="toggleDisplayObj") { toggleDisplayObj () ; } else if ($which_proc=="toggleShadingObj") { toggleShadingObj () ; } else if ($which_proc=="toggleWireshadingObj") { toggleWireshadingObj () ; } else if ($which_proc=="toggleSmoothObj") { toggleSmoothObj () ; } else if ($which_proc=="toggleNSmoothObj") { toggleNSmoothObj () ; } else if ($which_proc=="display_Control") { display_Control () ; } else if ($which_proc=="prefs_control_Window") { prefs_control_Window () ; } else if ($which_proc=="enterSomething") { enterSomething ($temp_string, $temp_int); } else if ($which_proc=="update_Globals") { update_Globals ($temp_int) ; } } //--------------------------------------------------------------