HighDots Forums  

QUESTION: VRMLscript

Javascript JavaScript language (comp.lang.javascript)


Discuss QUESTION: VRMLscript in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christian Langis
 
Posts: n/a

Default QUESTION: VRMLscript - 09-25-2003 , 09:53 AM






Hi all.

My question is about the Silicon Graphics implementation of the
"VRMLScript Parser and Interpreter", a addon library used to parse the
javascript in a VRML script node.

So for those of you who used it already:

This library was the missing block to my personnal implementation of a
VRML viewer. Since there is no user manual to it, I started to dig in
the source code. I must say that it has been written quite admirably.

I tried the demo test and it worked. So far so good. This test example
feeds a parameter to a function which returns either a string or a
number. Since in VRML the function return values are irrelevant, I
modified the test example and the test script so that the script updates
a global script variable (the equivalent of a VRML script node
eventOut). Again, it worked.

So I moved on to another example, which is my problem case (from the
VRML2.0 source book):

DEF CycleSelector Script {
url "javascript:
function set_boolean (bool, eventTime) {
if ( bool == false ) { return; }
whichChoice++ ;
if (whichChoice>2) { whichChoice = 0 ; }
if (whichChoice==0) { choice0_changed = true ; }
else if (whichChoice==1) { choice1_changed = true ; }
else if (whichChoice==2) { choice2_changed = true ; }
}"
field SFInt32 whichChoice 0
eventIn SFBool set_boolean
eventOut SFBool choice0_changed
eventOut SFBool choice1_changed
eventOut SFBool choice2_changed
}

I guess you don't see any problem with this. Indeed, this is a perfectly
legal VRML script. The eventIn has an associated function of the same
name and a parameter of the same type. This is pretty straightforward.
The problem however stems from the fact that the library is a closed
"black box". We know that when we call a function, it can modify none,
one, many or all of the script node's eventOuts, but which ones?

In this case, each 3 eventOuts are connected to the set_bind eventIn of
3 background nodes:

DEF Back0 Background {...}
DEF Back1 Background {...}
DEF Back2 Background {...}
ROUTE CycleSelector.choice0_changed TO Back0.set_bind
ROUTE CycleSelector.choice1_changed TO Back1.set_bind
ROUTE CycleSelector.choice2_changed TO Back2.set_bind

So since we don't know which single eventOut was turned TRUE when the
script eventIn came in, the only solution is to send ALL 3 eventOuts
once the script function has returned. But doing so will bind
successively all 3 backgrounds and obviously, only the last (third) will
remain bound (instead of looping between the 3). Obviously, we want to
avoid sending the eventOuts that were not triggered in the function...

Therefore the question is: How can we know for sure which script global
variable(s) was assigned a value during the function execution? How can
the library tell reveal which global variable it has assigned a new
value after the last function call?

Thanks (answers by Email please)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.