Simple Shared events using Chat Commands
Click here to see simpleAnimationActivatedByClicking
Click here to see oneChatCommand in a multi user world
Click here to see twoChatCommands in a multi user world
To try out the examples upload all of the files from the
simpleChatCommands.zip to the web and set your browser to go to the contact.htm file.
First look at simpleAnimationActivatedByClicking.wrl and the code for it.
6 steps to make simpleAnimationActivatedByClicking.wrl activated by a chat command so that we end up with our example oneChatCommand.wrl
1/ Add the blaxxun PROTO BlaxxunZone containing the field groupChat
PROTO BlaxxunZone [
exposedField
MFString groupChat ""
]
{
Group {}
}
2/ Make an instance of the PROTO BlaxxunZone and DEFine it as SharedZone
DEF SharedZone BlaxxunZone {
}
3/ Add a script node that has a function for receiving the public chat
DEF script Script {
eventIn MFString receiveChat
eventOut SFTime chatTime
url "vrmlscript:
function receiveChat (str, time) {
if (str[0]=='rotate blue bar'){
chatTime=time;
}
}
"
}
4/ We need a ROUTE that sends all the public chat said by any one using the public chat window to the receiveChat function
ROUTE SharedZone.groupChat TO script.receiveChat
5/ Remove the line that is no longer needed
DEF touchSensor TouchSensor {}
6/ Replace the ROUTE
ROUTE touchSensor.touchTime TO timeSensor.startTime
with
ROUTE script.chatTime TO timeSensor.startTime
Chat commands achieve the same results as shared events. Because all the people in the world receive the chat at the same time everyone's computers processes the commands that activate the animations at the same time.
Implementing shared events using chat commands can be simpler than using shared events that need the user to click on something. no objects have to be added to a world just to do the trivial task of activating a shared event and we need only one BlaxxunZone node to activate any number of events. To add more shared events to our world
all we need to add is:
else if (str[0]=='?'){/*do something*\}
to our receiveChat function which is demonstrated in twoChatComands.wrl
Variations of the Above Example
These files must of course be set up as multi user chat worlds to work.
changeBackgroundColor.wrl first checks to see if the chat line looks like a url.
If it does it send the url to the background texture urls
changeBackgroundTexture.wrl changes the colors of the background by saying the commands red, green or blue.
More colors and commands can be easilly added to the code.
Chat command related links
Chat Recognition download
Send String To Chat download
Avatar Acknowledgement download
Download | Forum | Home | Worlds | Avatars | Links | Thyme | Email
Copyright © 2000-2006
Graham Perrett thyme@seamless3d.com