WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-07-2009, 03:50 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Mainview head connection

I've been trying networking scripts lately, and it seems whenever I look around on one computer, the avatar that's shown in the second computer moves the same direction as the mouse is looking.
Is there any way I can make it so that instead of the whole avatar moving the direction of the mouse, just the head moves? So they can actually look around without, say, looking up and having the whole body lift off the ground and face upwards...?
Reply With Quote
  #2  
Old 04-08-2009, 03:12 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
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)
Reply With Quote
  #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
  #4  
Old 04-09-2009, 05:11 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You either have to send all that data with one send command or you need to check in the network callback function that the data is valid. The way it is there, sometimes there is no pos value sent and sometimes there in no euler value sent, but in onNetwork you are looking for both.
Reply With Quote
  #5  
Old 04-09-2009, 11:27 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
As Jeff pointed out, the message receiver needs to do different things depending on the message type.

For flexibility, try adding a 'messageType' variable to all your <mailbox>.send() calls. That way you can check the 'messageType' in your 'onNetwork' function then access the variables you know come with specific message types.

Code:
CREATE_PERSON_NETWORK_EVENT = 1
UPDATE_PERSON_NETWORK_EVENT = 2

def personJoined():
    mailbox.send(messageType=CREATE_PERSON_NETWORK_EVENT, avatarFileName='blabla.cfg')

def sendPersonData(person):
    mailbox.send(messageType=UPDATE_PERSON_NETWORK_EVENT, euler=...


def onNetwork(e):
    if e.messageType == CREATE_PERSON_NETWORK_EVENT:
        viz.add(e.avatarFileName)
        ....
    elif e.messageType == UPDATE_PERSON_NETWORK_EVENT:
        otherPerson.setEuler(e.euler)
Also, the viznet.py module will help you create more robust networked applications.

Jeff or Farshizo can you post that *sweet* viznet demo with the boxes and springs?
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #6  
Old 05-05-2009, 01:37 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
Sounds a bit confusing... looks like I've got some things to look into.
What is the example you speak of with springs and such?
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with getting head bone rotation right Enlil Vizard 2 02-13-2009 10:24 AM
Awkward neck/shoulder connection when adding custom head to vcc model. vEsotu Vizard 5 10-09-2008 05:07 PM
problems adding a custom morph head to a custom body Greenwu Vizard 1 07-27-2006 10:32 AM
avatar head texture issues rconrey Vizard 3 11-17-2004 04:05 PM
How to simply texture an avatar's head with a jpeg graphic? vr_boyko Vizard 3 10-26-2004 10:44 AM


All times are GMT -7. The time now is 03:34 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC