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.

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 load 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 [quiet:<bool>] 

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.

For details on the quiet: option available in 3ds Max 8 and higher, please see Quiet Mode.

   

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. Otherwise, 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 is 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 the 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 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>|<material>] <boolean> 

This provides control over the visibility of textures in the shaded viewport.

You can 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:

foo=box()
foo.material = standard diffuseMap:(checker()) showInViewport:true

showTextureMap foo.material foo.material.diffuseMap on
tm = checker()
mat = standardMaterial diffuseMap:tm
mm = multimaterial()
mm[1] = mat
foo.material = mm
showTextureMap mm[1] tm on

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

See showTextureMap() function for details.

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 using array indexing and iterate over them in a for loop.

The array can be indexed by a number, or by a 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 the material editor materials and root level maps using array indexing and iterate over them in a for loop.

The array can be indexed by a number to specify a slot number, name, or string to select by material and root level map name.

FOR EXAMPLE:

foo.material = meditMaterials[1]
meditMaterials[1].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 the scene materials and root level maps using array indexing and iterate over them in a for loop.

The array can be indexed by a number, or by a name or string to select by material or root level map name.

This variable is read-only.

See MaterialLibrary Values for more information.

   

activeMeditSlot 

MAXScript can access the active slot in the material editor.

The system global variable activeMeditSlot contains the index of the currently active Material Editor slot.

You can read this value to find the active slot, or assign an integer (between 1 and 24) to it to set the active slot.

EXAMPLE

activeMeditSlot = 5 -- set slot 5 to active slot
mtl = meditMaterials[activeMeditSlot] -- pick up active material/map

See Also