Holomatix

Log In / Register


Purchase
Material.setData()
Description

This method sets properties of the material that determines how the parts of the model using it are to be drawn.

Usage

setData(String, Number, String, Number)
setData(String, Number, String, String)

Parameters

  • The first parameter is a String which indicates the aspect of the material that is changing. It can have the value “colour” or “texture”.
  • The second parameter is a Number which indicates which material 'slot' is changing. There are up to four slots (numbered 0 to 3) where:
0 is an environment map
1 is a texture map (or colour)
2 is a bump map
3 is an additional map
  • The third parameter and fourth parameters indicate the specific properties of the aspect (specified by the first parameter) which is changing:
Colour changes
The third parameter has the value “r”, “g” or “b” The fourth parameter should be a Number between 0 and 255 for that colour channel.

Texture changes
The third parameter should be “name”
The fourth parameter should be the String name of the new texture.
Examples

To change a textured lampshade to use a different environment map (called “blurredmap.jpg”), you might write:

 shadeMaterial.setData(“texture”, 0, “name”, “blurredMap.jpg”);

To change a coloured light bulb to red, you might write:

bulbMaterial = mc1.table.lamp.bulb.model.getMaterial(“bulbTriangleSet”);
bulbMaterial.setData(“colour”, 1, “r”, 255);
bulbMaterial.setData(“colour”, 1, “g”, 255);
bulbMaterial.setData(“colour”, 1, “b”, 255);
 
< Prev   Next >


© Copyright 2000-2011 Holomatix Ltd. All rights reserved.