#VRML V2.0 utf8 WorldInfo { title "VRML: ScriptNodeEventOutControl.wrl" info [ "Author: Don Brutzman" "Revised: 11 October 99" "Script: ScriptNodeEventOutControl.java, .class" "Location: http://www.stl.nps.navy.mil/~brutzman/vrml/examples/course/" "Purpose: Experiment with ROUTEs from Script node eventOuts" ] } Group { children [ Viewpoint { # keep Viewpoint inside scene graph hierarchy in case of Inline later # [default] position 0 0 10 # [default] orientation 0 0 1 0 description "First Viewpoint" } DEF ClickTextToTest TouchSensor { } DEF InterfaceScriptNode Script { mustEvaluate TRUE # FALSE can delay sending eventIns to script # directOutput FALSE # TRUE if writing values to field nodes, use # FALSE if only sending eventOuts to nodes eventIn SFTime startTime # fields cannot be "routed" to the scene, use eventIn/eventOut ROUTEs eventOut MFString ChangedText # no default allowed eventOut SFVec3f ChangedPosition # no default allowed url [ "ScriptNodeEventOutControl.class" "c:\vrtp\mil\navy\nps\testing\ScriptNodeEventOutControl.class" "d:\vrtp\mil\navy\nps\testing\ScriptNodeEventOutControl.class" "http://devo.stl.nps.navy.mil/~brutzman/vrml/examples/course/ScriptNodeEventOutControl.class" ] } DEF TextPosition Transform { # [default] translation 0 0 0 # updated by DIS_position eventOut children [ Shape { appearance Appearance { # DEF MyGreen material Material { diffuseColor .2 .9 .2 shininess .9 } } geometry DEF MessageToUser Text { string [ "Text node default in VRML scene," "to be replaced by Java initialize" "via Script node using EventOut control." "" "If you see this text, Java via" "Script node is not working..." ] fontStyle FontStyle { size 0.8 justify [ "MIDDLE" ] } } } ] } # # The VRML 2.0 Sourcebook ####################################### # Copyright [1997] By # Andrea L. Ames, David R. Nadeau, and John L. Moreland # Debugger script excerpt modified from 30fig04.wrl, pp. 595..598 DEF DebugScript Script { url "javascript: function initialize( ) { string_changed[0] = label + ':'; } function set_SFVec3f ( translation, ts ) { string_changed[0] = label + ': ' + translation; }" field SFString label "TextPosition Trace" eventIn SFVec3f set_SFVec3f eventOut MFString string_changed }, Transform { translation 0.0 0.5 -0.15 children Shape { appearance Appearance { material Material { diffuseColor 1.0 1.0 1.0 emissiveColor 1.0 1.0 1.0 } } geometry DEF DebugMessage Text { fontStyle FontStyle { size 0.5 justify "MIDDLE" } } } } # end Debugger script excerpt ################################### ] ROUTE ClickTextToTest.touchTime TO InterfaceScriptNode.startTime ROUTE InterfaceScriptNode.ChangedText TO MessageToUser.set_string ROUTE InterfaceScriptNode.ChangedPosition TO TextPosition.set_translation ROUTE InterfaceScriptNode.ChangedPosition TO DebugScript.set_SFVec3f ROUTE DebugScript.string_changed TO DebugMessage.set_string }