media @ VU
template-rif-avatarmonitor.vr
template-rif-avatarmonitor.vr
(wrl
)
[ flux /
bitmanagement /
cortona /
octaga
]
DEF AVATARMONITOR
Script {
eventIn MFNode avatars_added
field MFString avatar_names [ "" ]
eventIn MFNode avatars_removed
eventIn SFString
beamTo
field SFNode Zone USE SharedZone
eventOut SFString avatar_added
eventOut SFString avatar_removed
url "vrmlscript:
function scanForNickname(node) {
if(node) {
if(n=node.getEventOut('nickname')) {return n;}
if(n=findNickname(node.getEventOut('children')))
{return n;}
if(n=findNickname(node.getEventOut('choice'))) {return n;}
}
return false;
}
function findNickname(children)
{
if(children) {
i = 0;
length = children.length;
for(i=0;i<length;i++) {
nickname = scanForNickname(children[i]);
if(nickname) { return nickname; }
}
}
return false;
}
function avatars_added(value,time) {
if(nickname = scanForNickname(value[0]))
{
Browser.print('Avatar added :' + nickname);
avatar_added = nickname;
}
}
function avatars_removed(value,time) {
if(nickname
= scanForNickname(value[0])) {
Browser.print('Avatar removed :' + nickname);
avatar_removed = nickname;
}
}
function
scanForTransform(node) {
if(node) {
if(node.getEventOut('rotation')) {
if(node.getEventOut('position')) {
return
node;
}
}
if(n=findTransform(node.getEventOut('children'))){return n;}
if(n=findTransform(node.getEventOut('choice')))
{return n;}
}
return false;
}
function findTransform(children) {
if(children) {
i = 0;
length = children.length;
for(i=0;i//Browser.print('transform = ' + transform);
// Really only want the mode, but this seems the only way to gat it as an int...
mode = 0;
position = new SFVec3f();
rotation = new SFRotation();
Browser.getViewpointByValue(position,rotation,mode);
position = transform.getEventOut('position');
rotation = transform.getEventOut('rotation');
distance = Zone.beamToDistance;
//Browser.print('distance = ' +distance);
trans = new SFVec3f(0,0,distance);
//Browser.print('trans = ' + trans);
trans = rotation.multVec(trans);
//Browser.print('trans = ' + trans);
rotation.multiply(new SFRotation(0,1,0,3.14));
position = position.add(trans);
//Browser.print('position = ' + position);
//Browser.print('rotation = ' + rotation);
Browser.setViewpointByValue(position,rotation,mode);
}
}
}
}
function beamTo(value,time)
{
// Problem here :: Avatar nicknames are NOT unique !!!
// thus this selection technique might not work...
Browser.print('Beam to : ' + value);
getLocationFor(value);
}
"
}
ROUTE SharedZone.avatars_added TO AVATARMONITOR.avatars_added
ROUTE
SharedZone.avatars_removed TO AVATARMONITOR.avatars_removed
(C) A. Eliëns
21/5/2007
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.