import vrml.external.field.*; import vrml.external.Node; import vrml.external.Browser; import vrml.external.exception.*; import netscape.javascript.JSObject; import improv.actor.*; import improv.actor.behavior.*; import improv.event.*; import improv.misc.*; import improv.util.gui.*; import improv.util.*; import java.util.*; import java.io.*; import java.net.*; import java.awt.Dialog; import java.awt.Frame; import java.applet.Applet; public final class demo extends Applet implements EventOutObserver,ImprovObserver { // The actor private 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 Vector eventOutVector = new Vector(); private EventOut eventOuts[] = new EventOut[1024]; private Vector eventOutReference = new Vector(); private Vector eventInVector = new Vector(); private LayerPanel panel; private ImprovEditor editor; private NYUSplashScreen splash; int numActors = 0; // Stuff to get a handle to the VRML scene private JSObject win; // The Netscape Window private Browser browser; // The VRML Browser // The vrml nodes private Node rootNode; private Node body; private Node head; private Node leftEyeStalk; private Node rightEyeStalk; private Node leftEye; private Node rightEye; private Node leftPupil; private Node rightPupil; private Node timeNode; // The VRML scene EventIns (modified by the channel values) private EventInSFVec3f rootTransEI; private EventInSFRotation rootRotEI; private EventInSFRotation bodyRotEI; private EventInSFRotation headRotEI; private EventInSFRotation leftEyeStalkRotEI; private EventInSFRotation rightEyeStalkRotEI; private EventInSFRotation leftEyeRotEI; private EventInSFRotation rightEyeRotEI; private EventInSFVec3f leftPupilScaleEI; private EventInSFVec3f rightPupilScaleEI; // The Improv channels private SFVec3fChannel rootTrans; private SFRotationChannel rootRot; private SFRotationChannel bodyRot; private SFRotationChannel headRot; private SFRotationChannel leftEyeStalkRot; private SFRotationChannel rightEyeStalkRot; private SFRotationChannel leftEyeRot; private SFRotationChannel rightEyeRot; private SFVec3fChannel leftPupilScale; private SFVec3fChannel rightPupilScale; // The Layers private Layer background,layer1,layer2; public void init() { browser = Browser.getBrowser(this); try { // Get Nodes from scene rootNode = browser.getNode("ROOT"); body = browser.getNode("Body"); head = browser.getNode("Head"); leftEyeStalk = browser.getNode("LeftEyeStalk"); rightEyeStalk = browser.getNode("RightEyeStalk"); leftEye = browser.getNode("LeftEye"); rightEye = browser.getNode("RightEye"); leftPupil = browser.getNode("LeftPupil"); rightPupil = browser.getNode("RightPupil"); splash = new NYUSplashScreen(this); // Create Actor actor = new Actor("Ned",splash); // Create Channels; rootTrans = new SFVec3fChannel("root translation"); rootTransEI = (EventInSFVec3f)rootNode.getEventIn("set_translation"); rootTrans.addObserver(this,rootTransEI); actor.addChannel(rootTrans); rootRot = new SFRotationChannel("root Rotation"); rootRotEI = (EventInSFRotation)rootNode.getEventIn("set_rotation"); rootRot.addObserver(this,rootRotEI); actor.addChannel(rootRot); bodyRot = new SFRotationChannel("body Rotation"); bodyRotEI = (EventInSFRotation)body.getEventIn("set_rotation"); bodyRot.addObserver(this,bodyRotEI); actor.addChannel(bodyRot); headRot = new SFRotationChannel("head Rotation"); headRotEI = (EventInSFRotation)head.getEventIn("set_rotation"); headRot.addObserver(this,headRotEI); actor.addChannel(headRot); leftEyeStalkRot = new SFRotationChannel("left eye stalk Rotation"); leftEyeStalkRotEI = (EventInSFRotation)leftEyeStalk.getEventIn("set_rotation"); leftEyeStalkRot.addObserver(this,leftEyeStalkRotEI); actor.addChannel(leftEyeStalkRot); rightEyeStalkRot = new SFRotationChannel("right eye stalk Rotation"); rightEyeStalkRotEI = (EventInSFRotation)rightEyeStalk.getEventIn("set_rotation"); rightEyeStalkRot.addObserver(this,rightEyeStalkRotEI); actor.addChannel(rootTrans); leftEyeRot = new SFRotationChannel("left eye Rotation"); leftEyeRotEI = (EventInSFRotation)leftEye.getEventIn("set_rotation"); leftEyeRot.addObserver(this,leftEyeRotEI); actor.addChannel(rightEyeStalkRot); rightEyeRot = new SFRotationChannel("right eye Rotation"); rightEyeRotEI = (EventInSFRotation)rightEye.getEventIn("set_rotation"); rightEyeRot.addObserver(this,rightEyeRotEI); actor.addChannel(rightEyeRot); leftPupilScale = new SFVec3fChannel("left pupil scale"); leftPupilScaleEI = (EventInSFVec3f)leftPupil.getEventIn("set_scale"); leftPupilScale.addObserver(this,leftPupilScaleEI); actor.addChannel(leftPupilScale); rightPupilScale = new SFVec3fChannel("right pupil scale"); rightPupilScaleEI = (EventInSFVec3f)rightPupil.getEventIn("set_scale"); rightPupilScale.addObserver(this,rightPupilScaleEI); actor.addChannel(rightPupilScale); // Add the layers State bg,def,lookLeft,lookRight,forward,eyesIn,eyesLeft,eyesRight; SFRotationFilter rot[] = new SFRotationFilter[7]; SFVec3fFilter vec[] = new SFVec3fFilter[3]; background = actor.addLayer("Background"); bg = new State("Background"); vec[0] = new SFVec3fFilter(rootTrans,0,0,0); rot[0] = new SFRotationFilter(rootRot,0,0,0); rot[1] = new SFRotationFilter(bodyRot,0,0,0); rot[2] = new SFRotationFilter(headRot,0,0,0); rot[3] = new SFRotationFilter(leftEyeStalkRot,0,0,0); rot[4] = new SFRotationFilter(rightEyeStalkRot,0,0,0); rot[5] = new SFRotationFilter(leftEyeRot,0,0,0); rot[6] = new SFRotationFilter(rightEyeRot,0,0,0); vec[1] = new SFVec3fFilter(leftPupilScale,1,1,1); vec[2] = new SFVec3fFilter(rightPupilScale,1,1,1); for(int i=0;i