import vrml.external.field.*; import vrml.external.Node; import vrml.external.Browser; import vrml.external.exception.*; import improv.actor.*; import improv.actor.behavior.*; import improv.event.*; import improv.misc.*; import improv.util.gui.*; import improv.util.*; import java.util.Hashtable; import java.applet.Applet; public class demo extends Applet implements EventOutObserver,ImprovObserver { // The actor Actor actor; private Hashtable actorTable; private EventOut time; private Applet applet; private boolean initialized = false; // The EventOuts. These allow users to set filter values from the VRML scene. private LayerPanel panel; private ImprovEditor editor; private NYUSplashScreen splash; int numActors = 0; // Stuff to get a handle to the VRML scene Browser browser; // The VRML Browser // The vrml nodes private Node timeNode; // The Layers public void init() { browser = Browser.getBrowser(this); try { splash = new NYUSplashScreen(this); defBehavior(); timeNode = browser.getNode("Time"); time = timeNode.getEventOut("time"); time.advise(this,null); } catch(InvalidNodeException e) { System.out.println("Problem: "+e); } } public void setBehavior(String state) { actor.setBehavior(state); } public void setProperty(String property, float value) { actor.setProperty(property,value); } public void showPanel() { panel = new LayerPanel(actor); panel.show(); } public void showEditor() { editor = new ImprovEditor(actor); editor.show(); } /** Implemented as part of the ImprovObserver interface. This is called by any ImprovObservable object to which this VRMLManager is an observer. This is usually not called directly, but is used by Improv to update the VRML scene. */ public void handleImprovEvent(ImprovEvent evt) { switch(evt.id) { case ImprovTypes.SFObjectCHANNEL: ((EventInSFNode)evt.arg).setValue((Node)(((SFObjectChannel)evt.target).getValue())); break; case ImprovTypes.SFStringCHANNEL: ((EventInSFString)evt.arg).setValue(((SFStringChannel)evt.target).getValue()); break; case ImprovTypes.SFBoolCHANNEL: ((EventInSFBool)evt.arg).setValue(((SFBoolChannel)evt.target).getValue()); break; case ImprovTypes.SFFloatCHANNEL: ((EventInSFFloat)evt.arg).setValue(((SFFloatChannel)evt.target).getValue()); break; case ImprovTypes.SFInt32CHANNEL: ((EventInSFInt32)evt.arg).setValue(((SFInt32Channel)evt.target).getValue()); break; case ImprovTypes.SFVec2fCHANNEL: ((EventInSFVec2f)evt.arg).setValue(((SFVec2fChannel)evt.target).getValue()); break; case ImprovTypes.SFVec3fCHANNEL: if(evt.arg instanceof EventInSFVec3f) ((EventInSFVec3f)evt.arg).setValue(((SFVec3fChannel)evt.target).getValue()); else ((EventInSFColor)evt.arg).setValue(((SFVec3fChannel)evt.target).getValue()); break; case ImprovTypes.SFRotationCHANNEL: SFRotationChannel chan = (SFRotationChannel)evt.target; ((EventInSFRotation)evt.arg).setValue(chan.getValue()); if(chan.xyzArg!=null) ((EventInSFVec3f)chan.xyzArg).setValue(chan.getXYZ()); break; case ImprovTypes.MFObjectCHANNEL: Object nodes[] = ((MFObjectChannel)evt.target).getValue(); for(int i=0;i