Given by Wojtek Furmanski and Balaji Natarajan at UC Web Applications Certificate on July 24 1997. Foils prepared 5 August 97
Outside Index
Summary of Material
This describes use of Java for VRML97(VRML2) Nodes |
Accessing a VRML97 world from a Java Application(Applet)
|
Link to LiveConnect from Netscape |
Comments on NPAC-IBM Televirtual reality project |
Java Shared Data Architecture(JSDA) |
Outside Index Summary of Material
Scripting in VRML `97 |
Part I - Java Node and |
External Authoring Interface |
Balaji Natarajan |
balaji@npac.syr.edu |
Script Nodes essentially give logic and state management to a VRML world. |
Key feature of the execution model is that time advances in a VRML'97 scene in virtual units |
Each time unit in the scene has an associated time value , called a timestamp. |
Start of an Event Cascade signifies creation of a timestamp and attaching it to an event. |
The syntax of a Script Node in a VRML'97 file : |
Script{ |
exposedField MFString url [] |
eventIn eventTypeName eventName |
eventOut eventTypeName eventName |
field SFBool directOutput FALSE |
} |
Location of Script Node in the scene graph has no effect on its operation |
Script Nodes can either receive eventIns through ROUTE statements or directly access the exposed Fields of the respective nodes when the directOutput Field is set to TRUE |
Script Nodes by themselves cannot have exposed Fields. |
The blending of Java and VRML enables true multimedia ,experiential and dynamic content on the Web. |
Both Java and VRML are cross - platform standards. |
The powerful networking classes of Java can be optimally used with VRML to provide for Collaborative virtual environments. |
VRML with Java is a powerful combination that results in executable content, optimized for today's low bandwidth environments. |
Simplistic 3-D programming of complex front-ends possible using well-defined nodes in VRML'97 specifications. |
Huge bandwidth savings possible by using a VRML world animated by a Java applet - rather than a 2D GIF/JPEG image animated by Java. |
In VRML'97, Script nodes allows to design nodes that are described by Java classes using the VRML - Java API. |
Using External Authoring Interface and Netscape's LiveConnect architecture,a VRML world can be directly controlled by a Java applet inside a HTML page. |
The whole VRML browser can be written in Java - having a set of Java classes that implement the VRML specifications . |
In VRML'97,Script Nodes facilitate development of nodes that are described by Java classes using the VRML - Java API |
Typical fields in a Java Script Node: |
url : This field specifies the location of the Java class |
eventIn : for getting the actual event in VRML world |
eventOut : for sending the received event to the Java class |
VRML'97 specs allow for trapping of events in scene using Sensors. |
Trapped Event is routed as the eventIn or input event to the Script Node using ROUTE statement |
Events arriving at an eventIn field automatically cause the browser to pass the event to the program referred to in the url field of the Script node.This mechanism is called Event Dispatching. |
Java program on receiving the eventIn calls the eventProcessed method |
Events are classified here and corresponding computation is performed . |
The result of the computation will be sent as an EventOut or an output event to the VRML file. |
The output event is then routed to the required nodes in the scene through a ROUTE statement |
This class will extend the Script class defined in the vrml package - a part of the VRML - Java API. |
Contains an initialize method for getting eventOuts and exposedFields from the VRML file. |
Contains a processEvent method for getting details about the event and processing it. |
Contains a shutdown method - this method is automatically called when Script node is deleted |
PC Platform : |
SGI's CosmoPlayer 1.0 beta3a |
Sony's Community Place |
IRIX Platform: |
SGI's CosmoPlayer 1.0 beta3a |
Solaris Platform: |
DimensionX's Liquid Reality |
IICM's VRWave |
#VRML V2.0 utf8 |
Transform { |
children [ DEF TS TouchSensor {} |
Shape { appearance Appearance { |
material DEF SphereColor material { diffuseColor 1 0 0 } |
} geometry Sphere {} |
} ] } |
DEF ColorScript Script { |
url "ChangeColor.class" |
eventIn SFBool clicked |
eventOut SFColor newColor |
field SFBool on FALSE} |
ROUTE TS.isActive TO ColorScript.clicked |
ROUTE ColorScript.newColor TO SphereColor.set_diffuseColor |
Public class Changecolor extends Script { |
private SFColor newColor ; |
float red[] = {1,0,0}; |
float blue[] = {0,0,1}; |
public void initialize() { |
newColor = (SFColor) |
getEventOut ("newColor"); } |
Public void processEvent(Event e) { |
ConstSFBool v = (ConstSFBool)e.getValue(); |
if(v.getValue()) { |
if(on.getValue()){ |
newColor.setValue(red); |
} else { newColor.setValue(blue); |
} |
on.setValue(!on.getValue()); } } } |
Defines a set of functions on the VRML browser that the external environment can perform to affect the VRML world |
Using EAI, Java applets can interact with the VRML scene by accessing nodes in it using the existing VRML event model |
Java applet communicates with the VRML world by obtaining an instance of the Browser class or by using the JSObject class in netscape's liveconnect package |
Then applet gets instance of node using the getNode() method of Browser class |
getEventIn() and getEventOut() methods of the Node class return relevant eventIn's and eventOut's respectively |
To receive an eventOut notification,applet implements the EventOutObserver interface - implementing the callback method. |
An instance of the eventoutobserver is passed to the advise() method of EventOut. |
Whenever an event is generated,for that eventOut the callback() method is executed and passed the value and timestamp of the event. |
Public class MyObserver implements EventOutObserver { |
public void callback(EventOut value,double timestamp) { |
//cast the obtained value here into an EventOutSFVec3f |
} } |
............. |
MyObserver observer = new MyObserver; |
mover.getEventOut("translation_changed").advise(observer,null); |
When the eventOut from translation occurs,observer.callback() is executed. |
Method of obtaining a Node pointer from inside the VRML scene is different.Script Node gets a pointer using USE construct.EAI uses getNode() method |
EventOut notification done through Routing in case of Script Node,in EAI - applet calls the CALLBACK method - when the eventOut generates an event |
Using EAI, the Java applet controlling the VRML world can be on the same HTML page on a different frame as illustrated in Fig1 |
Using Script Node,the Java class controlling the world can popup a separate frame window as illustrated in Fig2 |
Java applet,Javascript and VRML plugin interaction possible using Netscape's LiveConnect architecture. |
Handle to the plugin object got from inside the java program using netscape's javascript package |
VRML 2.0 Browser currently employing the LiveConnect architecture is CosmoPlayer 1.0 |
PC Platform: |
SGI's CosmoPlayer 1.0 (shipped with Netscape Communicator 4.0) |
Intervista's WorldView browser |
IRIX Platform: |
SGI's CosmoPlayer 1.0 |
Dynamic Generation of VRML nodes at Runtime. |
Dynamic Generation of VRML routes at Runtime. |
Development of Collaborative Virtual Environments |
#VRML V2.0 utf8 |
DEF GEN_ROOT Transform{ |
children[ DEF GEN_TOUCH TouchSensor {} |
Shape { geometry Sphere{} } ] } |
DEF GENSCRIPT Script { |
url "DynamicGen.class" |
eventIn SFTime touched |
eventOut MFNode addSphere } |
ROUTE GEN_TOUCH.touchTime TO GENSCRIPT.touched |
ROUTE GENSCRIPT.addSphere TO GEN_ROOT.addChildren |
Public class DynamicGenerator extends Script { |
MFNode addSphere ; |
Random randomNumGenerator = new Random(); |
float posX = 0.0f; |
public void initialize() { |
addSphere = (MFNode)getEventOut("addSphere"); } |
public void processEvent(Event e) { |
String sphereDesc1 = "Transform { translation 0.0 0.0 "; |
String sphereDesc2 = "children[ Shape geometry Sphere{}"; |
String sphereDesc3 = "appearance Appearance { material Material { diffuseColor"; |
String sphereDesc4 = "} } } ] } "; |
Float red = randomNumGenerator.nextFloat(); |
float green = randomNumGenerator.nextFloat(); |
float blue = randomNumGenerator.nextFloat(); |
Browser browser = getBrowser(); |
BaseNode baseNodes[]; |
posX += 3.0f ; // X coordinate of new node. |
try { |
baseNodes = browser.createVrmlFromString(sphereDesc1+ |
posX+ sphereDesc2+ sphereDesc3 +red+green+blue+sphereDesc4); |
addSphere.setValue(baseNodes); |
} |
catch(Exception ex) { ex.printStackTrace() ; |
} } } } |
The left browser window shows only the existing node in the world i.e. a sphere.The right browser window shows the dynamically created node also |
Made possible using Java's powerful networking classes |
Users represented as Avatars in shared spaces. |
Concept of Shared Behaviors has to be implemented to achieve realism in these environments. |
The visual element of a shared environment also provides a vehicle for enhancing the tools available in a workplace , such as scientific data visualization and process simulation |
For example , a team of engineers who design an aerospace engine by testing different parts online from different locations can benefit from a display of results that show cause and effect relationships in a multi-user space. |
A joint project between Syracuse University(NPAC/CASE) and IBM T.J.Watson Research Center. |
Scalable spaces served by multi-web servers for efficient load -balancing. |
Based on the Collaborative Framework - Java Shared Data Architecture(JSDA) being under development at JavaSoft Corporation. |
Compatible with both EAI and Script Node method of Java-VRML interaction |
Compatible with SGI's CosmoPlayer 1.0 and Sony's Community Place Browser |
Collaborative framework based on JSDA(Java Shared Data Architecture) |
Java Script Node in the client world references a Java class which is a client in the JSDA framework |
JSDA server accepts connection from client and spawns dispatch threads to handle any information from client regarding updates in position and orientation of the client's avatar |
Clients in turn spawn Receiver threads to handle the information received from Server-side thread |
Appropriate methods on the client-side class is called to set the updated values of all the other avatars |
Updated values are routed to the VRML world - consistency in avatar movement in all the client browsers is maintained. |
Data Objects shared over specific instances of Channels - between two or more Clients |
If interested,Client joins a Session of which the Channel is a part of and then joins the Channel itself. |
Contains objects which encapsulate management policies - The Session Manager object authenticates clients and their veracity to join a session |
Functionality supported by JSDA Channel: |
Session Communication: send message to all clients in a specific session |
Peer: Send message to a specific Client in a certain session |
List Client,Consumer : List all the Clients and respective Consumers who have registered interest in a certain Channel |