View Single Post
  #9  
Old 10-05-2006, 04:13 PM
pattie pattie is offline
Member
 
Join Date: Aug 2006
Posts: 32
Vizard and Networking

Ok, I have not been able to make the program (version beta2 to version beta2) work using a mailbox event instead of a network event. Again, the mailbox event never happens.
Below is the code I used. Did I forget something?

import viz
viz.go()
import vizinfo
vizinfo.add('This script demonstrates how to network an environment with another computer.\nEach computer is represented as a duck,and when you move\naround the other computer will see you move.')
BROADCAST = 1
TargetMailbox = viz.add(viz.MAILBOX,viz.input('Enter computer name or IP address of other machine'))
duck = viz.add('duck.wrl')
duck.scale(2,2,2)
maze = viz.add('tankmaze.wrl')
viz.clearcolor(.2,.2,.4)
def mytimer(num):
if num == BROADCAST:
#Retrieve my current orientation and position
yaw = viz.get(viz.HEAD_ORI);
pos = viz.get(viz.HEAD_POS);
#Convert message into string
message = str( [yaw[0], pos[0], pos[2]] )
print "in mytimer, message is: ",message
#Send the data to the target mailbox
TargetMailbox.send(message)
def mymail(message):
print "in mymail, message is: ", message
l = list(message)
yaw = l[0]
x = l[1]
z = l[2]
duck.translate(x, 0, z)
duck.rotate(0, 1, 0, yaw+180)
viz.callback(viz.TIMER_EVENT, mytimer)
viz.callback(viz.MAIL_EVENT,mymail)
viz.starttimer(BROADCAST, 0.01, -1)
Reply With Quote