View Single Post
  #3  
Old 04-09-2009, 02:59 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Quote:
Originally Posted by Jeff View Post
You could send the orientation of the viewpoint from one machine and then grab the headbone of the avatar, and set its orientation to that. Something like this.
Code:
def sendData():
	target_mailbox.send(euler = viz.MainView.getEuler())
and on the other machine
Code:
head = avatar.getBone('Bip01 Head')
head.lock()
def onNetwork(e):
    head.setEuler(e.euler, viz.AVATAR_WORLD)
I tried that and I repeatedly get a few errors:

Code:
Traceback (most recent call last):
  File "Vizard16356785347376.py", line 51, in onNetwork
    person1.setPosition(e.pos)
AttributeError: 'NetworkEvent' object has no attribute 'pos'
Traceback (most recent call last):
  File "Vizard16356785347376.py", line 53, in onNetwork
    head.setEuler(e.euler, viz.AVATAR_WORLD)
AttributeError: 'NetworkEvent' object has no attribute 'euler'
My code is as follows; the beginning only has a few notes for me to get started and to work on. :

Code:
#This demo is for testing online interactions between two players.
#The players will spawn up and be able to see each other's avatars.
#Both players will be able to select an avatar by a dropdown menu
#similar to the one in quest.viz. 
#A chat will be enabled, the color of the inbox text will be light blue,
#and the color of the outbox text will be darker blue.
#The chat will reside on the right side of the screen. The dropdown menu
#will also be able to hide or show the chat by selecting the option
#similar again in quest.viz.
#I want to have it be a co-operative mission, where one person will talk
#to the patient and the other will be able to get supplies and hand them
#to the first person.
#Names are also something to look into. Maybe in the future,
#when you spawn up, there will be a floating name above your character.
#The prefix "Dr. " is desirable in the names.


################################################
#####       CURRENTLY NEEDING WORK:        #####
#####    dropdown menu to change avatar    #####
################################################


import viz
viz.go()

ground=viz.add('room.wrl')
person1=viz.add('male.cfg')

#subject = viz.input('What is your name?')
target_machine = viz.input('Enter the name of the other machine').upper()
target_mailbox = viz.addNetwork(target_machine) 
out_text = ''
def SendData(): 
    mat = viz.MainView.getMatrix()
   
#    mat.preEuler(180,0,0)
    mat.preTrans(0,-1.8,0)

    target_mailbox.send(euler = viz.MainView.getEuler())

    target_mailbox.send(quat=mat.getQuat(),pos=mat.getPosition(),message=out_text)

vizact.ontimer(0,SendData) 


head = person1.getBone('skel_Head')
head.lock()

def onNetwork(e):
    person1.setPosition(e.pos)
    person1.setQuat(e.quat)
    head.setEuler(e.euler, viz.AVATAR_WORLD)
    inbox.message(e.message)

viz.callback(viz.NETWORK_EVENT, onNetwork) 


draft_text = ' '

def mykeyboard(key):
    global out_text, draft_text

    if len(key) == 1:
        draft_text += key

    elif key == viz.KEY_RETURN:
        out_text = draft_text
        draft_text = ' '
    elif key == viz.KEY_BACKSPACE:
        draft_text = draft_text[:-1]
    if len(draft_text) == .5:
        draft_text += '\n '
    outbox.message(draft_text)

viz.callback(viz.KEYBOARD_EVENT,mykeyboard) 



##


import vizmenu
menu = vizmenu.add()
menu.setAlignment( vizmenu.LEFT )
ToolMenu = menu.add( 'Tools' )
OptiesMenu = menu.add( 'Options' )
DropDown = ToolMenu.add( viz.DROPLIST, 'Equip' )
DropDown.addItems( ['Empty Hands','Stethoscope', 'Anasthetic', 'Medicine', 'Scalpel'] )

DropDown.getSelection()
DropDown.getItems()[ DropDown.getSelection() ]

AviMenu = OptiesMenu.add( vizmenu.MENU, 'Avatar' )
Duck = AviMenu.add( viz.RADIO, 0, 'Red' )
Guy1 = AviMenu.add( viz.RADIO, 0, 'White' )
Guy2 = AviMenu.add( viz.RADIO, 0, 'Blue' )


import vizcam
vizcam.FlyNavigate()
viz.collision(viz.ON)
person1.disable(viz.COLLISION)
Reply With Quote