media @ VU
[]
readme
course
preface
I
1
2
II
3
4
III
5
6
7
IV
8
9
10
V
11
12
afterthoughts
appendix
references
examples
resources
_
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
<phrase dir=b turn=0 id=_ level=_ right="haven t~nI seen this~nbefore?"/>
<phrase dir=b turn=0 id=_ level=_ left="I am glad~nyou re paying~nattention!!">
<gesture dir=b id=_ level=_ right=0 pause=500/>
<gesture dir=b id=_ level=_ left=0 pause=600/>
<a href=index.html target=_top> [] </a>
<a href=readme.html>readme</a>
<a href=course.html>course</a>
<a href=preface.html> preface </a>
<a href=part-i.html>I</a>
<a href=1.html> 1 </a>
<a href=2.html> 2 </a>
<a href=part-ii.html>II</a>
<a href=3.html> 3 </a>
<a href=4.html> 4 </a>
<a href=part-iii.html>III</a>
<a href=5.html> 5 </a>
<a href=6.html> 6 </a>
<a href=7.html> 7 </a>
<a href=part-iv.html>IV</a>
<a href=8.html> 8 </a>
<a href=9.html> 9 </a>
<a href=10.html> 10 </a>
<a href=part-v.html>V</a>
<a href=11.html> 11 </a>
<a href=12.html> 12 </a>
<a href=after.html>afterthoughts</a>
<a href=appendix.html>appendix</a>
<a href=refs.html>references</a>
<a href=examples.html>examples</a>
<a href=resources.html>resources</a>
<a href=java-bar.html>_</a>
(C) A. Eliëns
9/8/2006
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.