#Filter Parmeter/KSCRIPT5
10-Apr-95 09:35:45
Sb: #163878-#Filter Parmeter/KSCRIPT5
Fm: Martin Doudoroff/KUB 74664,2144
To: Judy Weller 72662,536
Judy:
>> "ChooseNode "Select Parent Object", 127-NT_AMBIENT-NT_TARGET <<
Well, this line of code is kinda cute. The filter parameter reflects our
handling of what are known (in lower-level languages like C) as bit flags.
Since Keyscript and TSE don't do binary, we use integer values which, when
added together, produce completely unique values. In the case of object/node
types, you've got the following choices:
NT_OBJECT 1
NT_CAMERA 2
NT_TARGET 4
NT_LIGHT 8
NY_SPOTLIGHT 16
NT_AMBIENT 32
NT_DUMMY 64
The names, such as "NT_OBJECT" are merely constant names for the associated
value. If you PRINT NT_LIGHT, you'll get an "8". So, if you wanted to have an
object selection box appear which only listed the lights in the scene, you'd
use a line such as:
ChooseNode "Select a light", NT_LIGHT + NT_SPOTLIGHT + NT_AMBIENT
Which is the same as saying:
ChooseNode "Select a light", 56
because 8 + 16 + 32 = 56.
What the programmer has done in the line which is confusing you, is he's said
that he wants everything EXCEPT the ambient light and any spotlight targets to
appear in the node selection dialog. Hence he's added up all the values, and
SUBTRACTED the node types he doesn't want.
1 + 2 + 4 + 8 + 16 + 32 + 64 = 127
1 + 2 + 8 + 16 + 64 = 91
His approach is more efficient than this approach:
ChooseNode "Select parent object", NT_OBJECT + NT_CAMERA + NT_LIGHT +
NT_SPOTLIGHT + NT_DUMMY
-Martin