|
Mastering
3D Studio MAX R3 |
Editable Splines and FFDs
All rules valid for editable meshes are valid for FFDs and editable splines.
It differs only in the way to access the vertex information.
In editable splines, you can use obj.spline_n___vertex_m,
where n is the spline number and m is the
vertex number. (Yes, there are three underscores between spline_n
and vertex_m.) Alternatively, you can use obj[4][1][2].
Since the editable spline allows animation of the vertices and the tangents,
the vertices will be every third index, starting on 2. To understand it
better, look at the Master track in an editable spline (such as the one
in Figure 16.8).
In FFDs, you can use ffd.control_point_n, where n is the
vertex number. You can also access it using indices, but each FFD will
have a different index for the Master track. To know which is the Master
track, you can run a script and use GETSUBANIMNAME to check it. Heres
an example:
f = ffd_2x2x2()
for i in 1 to f.numsubs do
if getsubanimname f i == #Master do format FFD 2x2x2 Master is %\n. i
f2 = ffdbox()
for i in 1 to f2.numsubs do
if getsubanimname f2 i == #Master do format FFD Box Master is %\n. i
These will show us that the FFD 2x2x2 Master Track is in subanim 3 and
FFD Box Master Track is in subanim 6.
FIGURE
16.8 The tracks of an editable splines
vertices
Manipulating Rendering
Results
One important advantage to using MAXScript is its ability to manipulate
the rendered result with MAXScript. MAXScript also accesses the G-Buffer
(Geometry Buffer, which means Z-Buffer, Object ID, etc.) channels, allowing
you to manipulate them or output them to disk as bitmap masks.
The first step in working with the renderer is to adjust the Render Scene
dialog parameters. You can adjust the width, height, output file, anti-alias
filter, and some other options.
RENDERER allows you to define whether the renderer is the Production
or the Draft renderer. To define which one will be used, you need to specify
renderer = #production or renderer = #draft.
You can use RENDERWIDTH, RENDERHEIGHT, AND RENDERPIXELASPECT to adjust
these characteristics of the renderer. As an example you can use:
renderwidth = 752
renderheight = 480
renderpixelaspect = 0.85
RENDERDISPLACEMENTS and RENDEREFFECTS enable or disable Displacements
and Render Effects. This is the same as turning these options on or off
in the Render dialog window. You can use them as follows:
renderdisplacements = false
rendereffects = true
RENDOUTPUTFILENAME defines the filename and path to save the rendered
image in (note that this is REND..., not RENDER...).
The extension specified in the filename will define the file type, and
the default settings will be used for that file. If you want to specify
different settings, you can use SELECTSAVEBITMAP() to select a filename:
rendoutputfilename = selectsavebitmap()
And remember to use the \\ symbol correctly, as in this
example:
rendoutputfilename = d:\\3dsmax3\\images\\proj01.tga
If the renderer is the MAX Default Scanline Renderer, you can also set
the anti-alias filter. This is done using scanlinerender.antialiasfilter
= filter, where filter can be any anti-alias plug-in
filter. As an example:
scanlinerender.antialiasfilter = catmull_rom()
Using all the commands above, together with the RENDER() command, its
almost possible to rewrite the entire Render Scene dialog box using MAXScript.
Rendering
Images
You can use the RENDER() command to render images. This command has many
options. Lets see some of these options in our examples.
For instance, you can make a script to render a series of MAX files with
each anti-alias filter, for comparison:
aa = #(area,blackman, blendfilter,catmull_rom, cook_variable, \
cubic, mitchell_netravali, quadratic, sharp_quadratic, \
soften, video)
for i in 1 to aa.count do
(
scanlinerender.antialiasfilter = execute (aa[i] + ())
render outputfilename:(aa[i] + .tga) outputwidth:320 outputheight:240 \
vfb:off
)
The outputfilename option defines the name of the rendered
file. The outputwidth and outputheight options
define the image size. The vfb:off option turns off the
Virtual Framebuffer.
Manipulating Bitmaps with
MAXScript
Youll need to use bitmaps to store the rendered information. MAXScript
also allows us to manipulate the bitmap, and even to manipulate animated
files such as AVIs or FLCs.
You can create a bitmap using variable = bitmap width height.
This command must include the width and height parameters. For instance,
you can create an empty bitmap using empty = bitmap 640 480.
You can create bitmaps to store the rendered image. This can be done
in two ways, the first being:
b = bitmap 640 480
render outputwidth:640 outputheight:480 to:b
The option to: will specify that the rendered output will
be stored in the specified bitmap.
You can also use:
b = render outputwidth:640 outputheight:480
This will render and automatically output the bitmap to the variable
b.
Bitmaps have several properties, such as .height and .width
to return the height and width of a bitmap. The property .numframes
will show how many frames exist in an animated bitmap, such as an AVI,
MOV, or image sequence bitmap.
© 2000, Frol (selection,
edition, publication)
|