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 node’s fields, or by using tokens.
Setting the fields 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 specified, 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 fields, each of which is a class containing set(), get(),
and, optionally, other methods. The csAppearance node, for example, contains many
fields, some of which are Shininess, Material, and TranspEnable (enable transparency).
To define one of these fields, you use the appropriate set() method, such as
csMaterial *mtl->setShininess(ShininessValue);
ShininessValue = mtl->getShininess();
color = mtl->getDiffuseColor();
ShininessValue is a float. The first 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