Title: Adding Functionality To WebBased VR
1Adding Functionality To Web-Based VR
- Basic Concepts
- Client server model
- Client-side static
- Client-side scripting
- Server-side scripting
2Web / Network Structure
- Web consists of a series of interlinked data
repositories - Linked via hubs and routers
- Use telephone network, satellite links, private
links - Connected using IP addresses
- IP addresses mapped to location by DNS
3Client /Server
- Aserver refers to a computer that offers a
service that can be obtained over the network - workstation becomes a client'' when it sends a
request to a server and waits for a response
4The World Wide Web
- Many Clients
- Many Servers
- Many means of linking
5Overall WWW Client - Server model
6HTTP Protocol
- The protocol is basically stateless, a
transaction consists of - Connection - The establishment of a connection by
the client to the server - Request - The sending, by the client, of a
request message to the server - Response - The sending, by the server, of a
response to the client - Close - The closing of the connection by either
both parties.
7Dynamic v Static
Server
Server
Server sends data - data cached locally
Client sends request
Client sends request
Server sends data cached locally - contains
variable data
Client
Client
Client handles input by user browser invokes
actions
8Client side processing
- Static Web page
- HTML
- Cached Locally
- Dynamic Web Page
- DHTML, XML, vrmlscript, javascript
- Java Applets
- Flash, Shockwave
- Cached locally
- Browser deals with locally
9Server Side processing
- Client sends request back to server with user
request - Server interprets reconfigures data
- Returns new client-interpretable instructions for
browser to refresh local copy - CGI, ASP, Java Servlets
10Teleprocessing
- Request from client changes underlying data on
server - Web 3D model changed for other users
- Database update e.g.
- User 1 looks up book - 3 copies orders 1
- User 2 looks up book 2 copies
11Adding action to 3D worlds
- Communicate changes form one state to another
- Execution model
- Java uses a class structure to show
- state
- Behaviour
- The state in 3D is the geometry etc.
- Behaviour is defined by the events
12Requirements
- VRML to store geometry
- Java to drive the behaviours
- How do we link them together?
13Scene Graph
- VRML file has a a set of nodes organised into set
of hierarchies - Nodes
- Nodes exist to define geometry and to control the
scene - Use Routes to link nodes together
14Static v Dynamic
- VRML enables changes of state where a route is
pre-defined and non-variable I.e. static - Activation is required to create a dynamic scene
- VRML provides simple methods of activation via a
sensor
15Dynamic Behaviours
- To create real dynamic worlds a bridge between
VRML and Java is required - Script Node
16What is a dynamic behaviour
- Behaviours involving
- Query state
- make decisions based on state
- change scene based on decisions
- E.g. If door is open go thro else turn left (or
right !!) - Script node allows arbitrary plugging of code
into the VRML scene
17Script Node
Script exposedField MFString url
field SFBool directOutput
FALSE field SFBool mustEvaluate
FALSE And any number of eventIn
eventTypeName eventName field
fieldTypeName fieldName initialValue eventOut
eventTypeName eventName
18Setting Up a script node
- Must have a pointer to the sourc e file
containing the program code - URL to allow web handling
- Script
- url httpbob.home/ExampleClient.class"
- eventIn SFRotation orientation
- field SFNode target USE TARGET
19- Also contains
- user-defined fields
- Event in fields pass control to the referenced
class - Any field referenced can be altered by the code
referred to in the class - Event out generates an event to be sent to
connected nodes
20Script Node is a messenger
- Events sent to script are
- packaged
- sent to script (java class)
- script updates script node fields
- out fields of script node route event to other
nodes in the usual way
21Event Class
- Gets information about the incoming event
- getName (name of event field in script node
- getValue (reference to VRML field)
- getTimeStamp (time at which event was generated
in VRML field)
22Example
- VRML V2.0 utf8
- Transform
- children
- DEF TS TouchSensor TouchSensor
- Shape
- appearance Appearance
- material DEF SphereColor Material
diffuseColor 1 0 0 red -
- geometry Sphere
-
-
23Contd.
- DEF ColorScript Script
- url "ChangeColor.class"
- eventIn SFBool clicked
- eventOut SFColor newColor
- field SFBool on FALSE
-
- Routing
- ROUTE TS.isActive TO ColorScript.clicked
- ROUTE ColorScript.newColor TO SphereColor.set_diff
useColor
24Java Class
- import vrml.
- import vrml.field.
- import vrml.node.
- public class ChangeColor extends Script
- private SFBool on // status of on-off
- float red 1, 0, 0 // RGB(Red)
- float blue 0, 0, 1 // RGB(Blue)
- private SFColor newColor
- public void initialize()
- newColor (SFColor) getEventOut("newColor")
- on (SFBool) getField("on")
-
public void processEvent(Event e)
ConstSFBool v (ConstSFBool)e.getValue()
if(v.getValue()) if (on.getValue())
newColor.setValue(red) // set red to
'newColor' else
newColor.setValue(blue) // set blue to
'newColor' on.setValue(!on.getValue(
)) // !on.getValue()
25Using JavaScript with VRML
- The Script
- DEF toggle Script
- field SFBool active FALSE
- eventIn SFBool isClicked
- eventOut SFBool click_changed
- url "vrmlscript
- function isClicked()
- if (active 0)
- active 1
- else
- active 0
- click_changed active
-
- "
Uses Script Node