import vrml.*; import vrml.field.*; import vrml.node.*; public class switch3 extends Script { private SFInt32 switch_position; private int switch_state; public void initialize() { System.out.println("initialize()"); switch_state = 0; } public void processEvent (Event e) { switch_position = (SFInt32)getEventOut("switch_position"); System.out.println("processEvant: " + e.getName()); if (e.getName().equals("switch_touched")) { ConstSFBool v = (ConstSFBool)e.getValue(); if (v.getValue()) { System.out.println("switch_touched = true"); switch_state++; switch_state %= 3; switch_position.setValue(switch_state); } } } }