A SERVICE OF

logo

Setting the Values in Scene Graph Nodes
61
Setting the Values in Scene Graph Nodes
Cosmo 3D allows you to set the values for nodes in two ways: either using the set()
method in each of the nodes elds, or by using tokens.
Setting the elds is different depending on whether or not the variable has a single or
multiple value. If the variable has a single value, the variable can be set directly; if it has
multiple values, the particular value in the set of values must be specied, as shown in
Figure 4-2.
Figure 4-2 Setting Single and Multiple-Value Variables
Using set() and get() Methods to Set and Get Single-Value Fields
Nodes are composed of one or more elds, each of which is a class containing set(), get(),
and, optionally, other methods. The csAppearance node, for example, contains many
elds, some of which are Shininess, Material, and TranspEnable (enable transparency).
To dene one of these elds, you use the appropriate set() method, such as
csMaterial *mtl->setShininess(ShininessValue);
ShininessValue = mtl->getShininess();
color = mtl->getDiffuseColor();
ShininessValue is a oat. The rst line of code sets the shininess value of the csMaterial,
mtl. The following lines return an atomic, single value, ShininessValue, and a composite,
single value, color. A composite, single value is a set of numbers that represent a single
feature, for example, RGB values represent one feature: color
Single value field Multiple value field
Must specify
one of these
values to set