|
Mastering
3D Studio MAX R3 |
LISTING 18.8: The Raytraced Glass plug-in script (plugin_rayglass.ms)
plugin material rayGlass
name:Raytraced Glass
classID:#(0x82b2cdc2, 0x4f77873e)
extends:Standard replaceUI:true
(
parameters main rollout:params
(
Transparency type:#float default:90 ui:trans
IOR type:#float default:1.6 ui:refrac
Color type:#color default:white ui:col
on Transparency set val do
delegate.refractionmapamount = val/2+50
on IOR set val do
delegate.ior = val
on Color set val do
(
delegate.diffuse = val
delegate.filtercolor = val/2
delegate.ambient = val*2/5
)
)
rollout params Parameters
(
group Glass Parameters
(
spinner trans Transp.: fieldwidth:45 offset:[-90,0]
spinner refrac IOR: fieldwidth:45 offset:[0,-20]
colorpicker col Glass color: align:#left offset:[0,-25]
)
group Raytracing Parameters
(
checkbox aa Local Antialiasing
checkbox atn Attenuation offset:[120,-20]
Spinner st Start: fieldwidth:50 align:#left offset:[120,0] \
range:[0,10000,0]
spinner ed End: fieldwidth:50 align:#left offset:[210,-20] \
range:[0,10000,100]
)
on aa changed state do
delegate.reflectionmap.parameters.Options__Antialiasing_Enable = state
on atn changed state do
(
local atnx
if state then atnx = 1 else atnx = 0
delegate.reflectionmap.parameters.Attenuation_Mode = atnx
delegate.refractionmap.parameters.Attenuation_Mode = atnx
if atnx == 1 then (st.enabled = true; ed.enabled = true)
else (st.enabled = false; ed.enabled = false)
)
on st changed val do
(
delegate.reflectionmap.parameters.Attenuation_Start = val
delegate.refractionmap.parameters.Attenuation_Start = val
)
on ed changed val do
(
delegate.reflectionmap.parameters.Attenuation_End = val
delegate.refractionmap.parameters.Attenuation_End = val
)
on params open do
(
aa.state = \ delegate.reflectionmap.parameters.Options__Antialiasing_Enable
if delegate.reflectionmap.parameters.Attenuation_Mode == 1 then
atn.checked = true else atn.checked = false
if atn.checked then (st.enabled = true; ed.enabled = true)
else (st.enabled = false; ed.enabled = false)
) )
on create do
(
delegate.reflectionmap = raytrace()
delegate.reflectionmapamount = 15
delegate.refractionmap = raytrace()
delegate.shaderType = 4
delegate.specularLevel = 78
delegate.glossiness = 45
delegate.Soften = 0.3
delegate.twoSided = on
)
)
Evaluate this script and select the newly created Raytraced Glass material
in the Material Editor.
The script defines all basic parameters in the on create
event. Then, the script defines a series of parameters and events that
will set the object color, transparency, and IOR; and the Raytrace Map
parameters, such as Local Antialiasing and Attenuation.
The values used to create the material in this script are completely
predefined, not following any rule or math. MAX allows you to assign the
original object as a sub-material of this material, so you can modify
it as you wish. You can turn off the Raytrace Maps, and even change them
to other maps.
Building Geometry
Using Plug-ins
Besides extending existing plug-ins, you can also write plug-ins from
scratch. These plug-ins are divided in two categories: plug-in systems,
which work just like systems, creating other objects without allowing
the user to modify them after being created; and the plug-ins that actually
create data from scratch.
Only 3D geometry, render effects, and modifiers can be created from scratch.
Creating a System-like Plug-in
You can create system-like plug-in scripts, like the Ring Array System
object. It creates a series of boxes and allows us to adjust and specify
parameters, but after the objects are created, you can no longer manipulate
those values.
These plug-in scripts are another way you can create a series of objects,
the same way you can with a tool. They also allow you to create a rollout
that will adjust the creation parameters, but later the objects will behave
as if they had no relationship with each other.
You will now create a script that will draw a dummy handthe same
hand you used in Chapter 15 to animate the fingers movementas
seen in Figure 18.10.
FIGURE
18.10 Dummy hand
Start a new script and type in Listing 18.9, or open the file titled
plugin_hand.ms on the CD.
© 2000, Frol (selection,
edition, publication)
|