Material Editor

The following functions are specific to materials and the use of materials with the Material Editor:

getMeditMaterial <slot_index>

you can get the materials in the material editor slots 1 through 24. For example:

        foo = getMeditMaterial 3

setMeditMaterial <slot_index> <material>

complements the getMeditMaterial function allowing you to place a material into the numbered material editor slots. Accepts either materials or texture maps as <material>.

loadDefaultMatLib()

Loads the default 3ds max material library file.

loadMaterialLibrary <filename_string>

Loads the named 3ds max material library file, which becomes the current material library. If the file name does not have a fully specified directory path, the function searches through all the currently configured bitmap paths. Returns true if the loads succeeds, false if it fails.

saveMaterialLibrary <filename_string>

Saves the current material library into the named file. Returns true if the save succeeds, false if it fails.

fileOpenMatLib()

This method displays the File Open dialog and allows the user to select a material library to load.

fileSaveAsMatLib()

Displays the standard Save File As dialog to allow the user to save the current material library.

fileSaveMatLib()

If the current material library has been saved previously (has been named) this method saves the material library to the same file. Otherwise it displays the standard Save File As dialog to allow the user to save the current material library.

getMatLibFileName()

Returns the current material library file name as a String value.

renderMap <textureMap> [ into:<bitmap> ]           \

                       [ size:<point2> ]           \

                       [ filename:<string> ]       \

                       [ scale:<float> ]           \

                       [ filter:<boolean> ]        \

                       [ display:<boolean> ]

provides access to the Render Map function available in the Material Editor. The function returns a Bitmap value containing a rendering of the given texture map. If you specify the optional into: argument, the function renders the map into the supplied bitmap, taking size and other attributes from the existing bitmap. If you don't, a new bitmap value is created using the size: and fileName: arguments in its creation. If the into: and size: parameters are not specified, the default size in [200,200].

The scale: argument is a scale factor applied to 3D TextureMaps. This is the scale of the surface in 3d space that is mapped to UV and controls how much of the texture appears in the bitmap representation.

If the filter: argument is true, the bitmap is filtered. It is quite a bit slower to rescale bitmaps with filtering on. Defaults to false.

If the display: argument is true, the resulting bitmap is displayed using the virtual frame buffer; otherwise it is not. Defaults to false.

Example:

rm = renderMap $foo.material.diffuseMap size:[640,480] \

fileName:"foodif.bmp"

save rm

close rm

The above will render a map to a bitmap and save it as a .bmp file.

showTextureMap <material> <texmap> <boolean>

This provides control over the visibility of textures in the shaded viewport. You specify the material containing the texture map, the texture map in that material to be controlled and a boolean to turn the display on or off, for example:

Example:

showTextureMap $foo.material $foo.material.diffuseMap on

tm = checker()

mat = standardMaterial diffuseMap:tm

mm = multimaterial()

mm[1] = mat

$box01.material = mm

showTextureMap mm[1] tm on

Note that for multimaterials, you need to specify the appropriate sub-material (using [] indexing, for example).

The following 3ds max system global variables are applicable to the Material Editor:

currentMaterialLibrary

Contains a virtual array of materials and root level maps corresponding to the currently opened material library. You can get library materials via array indexing and iterate over them in a for loop. The array can be indexed by number, or by name or string to select by material name. This variable is read-only. See MaterialLibrary Values for more information.

meditMaterials

Contains a virtual array of materials and root level maps corresponding to the slots in the material editor. You can access material editor materials and root level maps via array indexing and iterate over them in a for loop. The array can be indexed by number to specify slot number or name or string to select by material and root level map name. For example:

$foo.material = meditMaterials[1]

meditMaterials["foo mat"].diffuse = red

for m in meditMaterials do print m.diffuseMap

meditMaterials[1]=standard()

print meditMaterials.count -- number of slots

This variable is read-only, but the elements (the materials in the slots) are assignable. See MaterialLibrary Values for more information.

sceneMaterials

Contains a virtual array of materials and root level maps corresponding to the materials and root level maps present in the scene. You can get scene materials and root level maps via array indexing and iterate over them in a for loop. The array can be indexed by number, or by name or string to select by material or root level map name. This variable is read-only. See MaterialLibrary Values for more information.