|
|||||||||||||||||
LISTING 18.5: The Dummy2 plug-in script (plugin_dummybox.ms) plugin helper dummybox name:”Dummy2” category:”Mastering 3D Studio MAX” classID:#(0x648ce72d, 0x935e7b3a) extends:Dummy replaceui:true ( parameters pblock rollout:params ( Length animatable:true type:#worldunits ui:d_length Width animatable:true type:#worldunits ui:d_width Height animatable:true type:#worldunits ui:d_height on height set val do delegate.boxsize.z = val on length set val do delegate.boxsize.x = val on width set val do delegate.boxsize.y = val ) rollout params “Parameters” ( spinner d_length “Length: “ range:[0,10000,0] type:#float spinner d_width “Width: “ range:[0,10000,0] type:#float spinner d_height “Height: “ range:[0,10000,0] type:#float ) tool create ( on mousePoint clickNo do ( if clickNo == 1 do nodeTM.translation = gridPoint if clickNo == 3 do #stop ) on MouseMove clickNo do ( if clickNo == 2 do ( length = abs(gridDist.x)*2 width = abs(gridDist.y)*2 ) if clickNo == 3 do height = sqrt(gridDist.y^2+gridDist.x^2) ) ) )
This script works the same way as the other ones youve made. Having a resizable dummy will be very helpful for you in future projects.
Extending Modifiers The Modifier plug-in script works the same way as our other scripts, but you will be working on modifiers. In addition, modifiers do not require a tool, because no mouse action will be required. Lets create two scripts. The first extends the Normalize Spline script, so you can use values below 1.0, since the plug-in itself doesnt allow you to do so. Another script extends the Optimize modifier, to easily set Low, Medium, or High Optimization values. Start a new script and type out Listing 18.6, or open plugin_normalize2.ms.
LISTING 18.6: The Normalize2 plug-in script (plugin_normalize2.ms) plugin modifier nspline2 name:”Normalize2” extends:normalize_spline replaceui:true classID:#(0x44398c3b, 0x29422aeb) ( parameters pblock rollout:params ( Length type:#float default:20 ui:length2 on Length set val do delegate.length = val ) rollout params “Parameters” ( spinner length2 “Length” range:[1,10000,1] type:#float checkbox onoff “Enable Small Values” checked:false enabled:false spinner mini “Mini-Length” range:[0.001,1,1] type:#float \ scale:0.001 enabled:false on length2 changed val do ( if length == 1.0 then onoff.enabled = true else onoff.enabled = false ) on onoff changed state do ( if state then ( mini.enabled = true length2.enabled = false mini.value = 1.0 ) else ( mini.value = 1.0 mini.enabled = false length2.enabled = true length = length2.value ) ) on mini changed val do ( length = val ) on params open do ( if length < 1.0 then ( onoff.enabled = true onoff.checked = true mini.enabled = true mini.value = length length2.enabled = false ) else ( if length == 1.0 then ( onoff.enabled = true length2.enabled = true ) ) ) ) )
This script uses many functions in the rollout. This is because the script will allow the user to define a normal value (above 1.0), and when the value is equal to 1.0, the mini spinner will be enabled, allowing the user to specify values below 1.0, as seen in Figure 18.7. This is really needed if you have very small shapes, but dangerous if you have big ones. Thats why we created a trigger that will enable one or another depending on what the user needs.
The script also needs to check the length value, when it is loaded, so it can display this value correctly in the UI. This is why you used the on params open event. Now write the Optimize2 plug-in script that will simplify the Optimize modifier. Start a new script and type out Listing 18.7, or open the file plugin_optimize2.ms on the CD. The result of this script is shown in Figure 18.8.
LISTING 18.7: The Optimize2 plug-in Script (plugin_optimize2.ms) plugin modifier optimize2 name:”Optimize2” extends:optimize replaceui:true classID:#(0x52ef94f8, 0xadb373cb) ( parameters pblock rollout:params ( power type:#integer default:1 ui:str on power set val do ( case val of ( 1: delegate.facethreshold1 = 0 2: delegate.facethreshold1 = 2.5 3: delegate.facethreshold1 = 5 4: delegate.facethreshold1 = 10 ) ) ) rollout params “Parameters” ( group “Optimize” ( radiobuttons str “Strength:” labels:#(“None”,”Low”,”Medium”,”High”) ) ) )
This script uses the strength parameter to store the radiobutton index, and then, depending on the index value, passes different values to the Optimize modifier. The user has no access to these parameters, unless they edit the script.
Extending Materials Materials, maps, render effects, and atmosphere plug-ins can be extended. Usually, you extend them to simplify the creation process and to ensure that all files in a project will have the same look. This is very useful when youre working in a large company and several animators are sharing the same files. You will now create a plug-in script that extends the standard material and allows the user to create a simple and fast Glass material. It will display three options to the user: the glass color, IOR, and transparency, as seen in Figure 18.9. The remaining options are cosmetic to the material, and others are predefined by the script.
Start a new script and enter the code from Listing 18.8, or open the file plugin_rayglass.ms on the CD.
© 2000, Frol (selection, edition, publication) |
|||||||||||||||||
|