Material

Return to Introduction  Previous page  Next page

A material determines the color characteristics of a surface used in a mesh.  It is a basic type that can be created with the 'new' keyword.

 

Properties

 

ambient

A Color type representing the ambient light component of the material.

diffuse

A Color type representing the diffuse light component of the material.

specular

A Color type representing the specular light component of the material.

emissive

A Color type representing the emissive light component of the material.

specularSharpness

A floating point value determining how the specular light is reflected.

textureMap

A string that names the bitmap file in the resources to be used for the texture map.  Set to "" if no texture map.

opacityMap

A string that names the bitmap file in the resources to be used for the opacity map.  Set to \"\" if no opacity map.

bumpMap

A string that names the bitmap file in the resources to be used for the bump map.  Set to \"\" if no bump map.

specularMap

A string that names the bitmap file in the resources to be used for the specular map.  Set to \"\" if no specular map.

emissiveMap

A string that names the bitmap file in the resources to be used for the emissive map.  Set to \"\" if no emissive map.

environment

String identifier of an environment map for this material.

environmentOpacity

A floating point value between 0 and 1 determining the opacity of the reflected environment.

environmentGradient

A floating point value between 0 and 1 determining how much the environment reflection is reduced if the gradient between the viewer and the surface is shallow.

 

Methods

 

loadFromFile(filename)

Sets the material up from the given .dxmaterial file.  This may be a file on disk or a URL.

textureMapLoad(filename, inBackground)

Loads the texture map from the given file or URL.  Set inBackground to true to stream without pausing playback.

 

Examples

 

meshes.car.materials.paintwork.diffuse = new Color("#ff0000");  // sets the paintwork of the car to red.

 

meshes.car.materials.paintwork.loadFromFile("http://www.dxstudio.com/examples/grass.dxmaterial.zip");  // loads the material from a dxmaterial file on the web server (with zip extension as otherwise server may not serve file)

 

See Also

 

Script Reference



Copyright ©2004 Worldweaver Ltd. DX Studio Home