CompuServe Thread

#Filter Parmeter/KSCRIPT5

6 messages in this thread
#163878From: Judy WellerApr 10, 1995 6:50 AM
I have a question on the "FIlter" parameter. I was looking at K-Script5 and the following statement appears: "ChooseNode "Select Parent Object", 127-NT_AMBIENT-NT_TARGET The value of the filter is 91 – why does 91 give you a list of all the objects, plus the camera and the ambient light? WHat is the purpose of the 127? COuld this have been coded another way? Judy
#163897From: Martin Doudoroff/KUBApr 10, 1995 9:35 AM
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
#164049From: DAVID CAMPApr 10, 1995 10:45 PM
> 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 No wonder I'm having trouble getting my scripts to work <g> David
#164139From: Martin Doudoroff/KUBApr 11, 1995 11:11 AM
>> No wonder I'm having trouble getting my scripts to work <g> << I will be the first to admit that our approach to bitmasks is somewhat un- intuitive. Real bit masks (a la C) are conceptually intuitive (if you understand what a bit is), but even still, they are a little technical for normal use. In this case we were face with a no-win situation: we either went with an integer extrapolation of a bitmask, or we added a huge heap of variables onto the system. Martin
#164204From: DAVID CAMPApr 11, 1995 4:58 PM
>…. or we added a huge heap of variables onto the system. I'm not complaining ( well not much anyway <g> ) I'm learning, little by little. The farther I get, the more I appreciate your approach to the Script prog. language. David
#164103From: Judy WellerApr 11, 1995 8:54 AM
Thanks Martin. I thought it was something like that but I kept trying to work at the Bit level – I just never even thought of the plain integer – I was down there trying to match up bits with the various objects 🙁 Judy