PDA

View Full Version : Problems with Multi User


zmm
02-14-2018, 06:54 AM
I am following the Multi User environment example to create a scene with a server and two clients, I am having two issues:

1. Shared environment: I want the users to inhabit the same environment so that if events happen in one all will see it. At the moment all users can see each others movements but if I want have something happen, such as a ball appearing, it only appears in the triggered frame, be that the server or client 1 or client 2, not all three. Is there a way to have both users see the same environment without having to program each object movement separately (there will be more than 20).

2. View point: I have my users inhabit either the male or female avatar however the view point is centered at the feet, which means when I set the mainview to what should be eye level the avatar is floating and when I set it to zero the view point is on the ground, how can I adjust this? (later I will connect the avatar to head trackers but at the moment I want it to work on two computers)

Thank you in advance for any help!

Jeff
02-14-2018, 09:02 PM
1. It's necessary to program the scene changes for each user when using Vizard's networking library. If you have multiple Vizard 5 Enterprise licenses and only one user will be manipulating the environment (e.g. grabbing objects, triggering events) using clustering (http://docs.worldviz.com/vizard/#What_is_a_cluster_.htm) and the co-presence feature maybe an option for you.

2. How are you setting this up, is there a link between the viewpoint and avatar?

Also, take a look at our Vizible (https://viz.worldviz.com/vizible/) software, which is designed for VR collaboration between two users.

zmm
02-16-2018, 09:45 AM
Thank you for your reply. I will try out what you suggest for the first point.

For the second point: In my code (see below for the core code), there is not a link to the avatar but selected from the object list, how do I link it to the head if I don't have the tracker?


###server###
import viz
import viznet
import steve
import random

viz.go()
viz.clearcolor(.2,.2,.4)

viz.MainWindow.fov(60)

viz.MainView.setPosition([0,1.5,-6])
viz.MainView.setEuler([0,0,0])

objectList = ['vcc_male.cfg','vcc_female.cfg']
maze = viz.add('piazza.osgb')

objects = {}

UPDATE = viznet.id('update')
CLIENT_DISCONNECTED = viznet.id('client_disconnected')
CHAT = viznet.id('chat')


viznet.server.start(port_in=14950,port_out=14951)

def onStartClient(e):
print '** Client joined with username:',e.username
viz.callback(viznet.CLIENT_CONNECT_EVENT,onStartCl ient)

def onStopClient(e):
print '** Client left with username:',e.username
viznet.server.send(CLIENT_DISCONNECTED,client=e.se nder,username=e.username)
objects[e.username].remove()
del objects[e.username]
viz.callback(viznet.CLIENT_DISCONNECT_EVENT,onStop Client)

def update(e):
try:
objects[e.username].setPosition(e.pos)
objects[e.username].setEuler(e.ori)
objects[e.username].state(e.state)
except KeyError:
objects[e.username] = viz.add(objectList[e.object],scale=[1,1,1],pos=e.pos,euler=e.ori)
objects[e.username].tooltip = e.username
objects[e.username].state(e.state)
viz.callback(UPDATE,update)

###client###
import viz
import viznet
import vizinfo
import vizinput

viz.go()
viz.clearcolor(.2,.2,.4)
maze = viz.add('piazza.osgb')
objects = {}

UPDATE = viznet.id('update')
CLIENT_DISCONNECTED = viznet.id('client_disconnected')
CHAT = viznet.id('chat')

SERVER_NAME='PC04720'

USER_NAME='client1'

while not viznet.client.connect(SERVER_NAME,port_in=14951,po rt_out=14950,username=USER_NAME):
if vizinput.ask('Could not connect to ' + SERVER_NAME + ' would you like to try another?'):
SERVER_NAME=vizinput.input('Enter Server Name')
else:
viz.quit()
break
objectList = ['vcc_male.cfg','vcc_female.cfg']
obj_choice=vizinput.choose('Connected. Select your character',objectList)

#set initial position
viz.MainView.setPosition([2, 0 ,0])
viz.MainView.setEuler([270,0,0])
currentState = 1

def sendUpdate():
ori= viz.MainView.getEuler()
pos = viz.MainView.getPosition()
viznet.client.sendAll(UPDATE,client=viz.getCompute rName(),object=obj_choice,pos=pos,ori=ori, state=currentState, username=USER_NAME)
vizact.ontimer(.05,sendUpdate)

def update(e):
if e.username != USER_NAME:
try:
objects[e.username].setPosition(e.pos)
objects[e.username].setEuler(e.ori)
except KeyError:
objects[e.username] = viz.add(objectList[e.object],scale=[1,1,1],pos=e.pos,euler=e.ori)
objects[e.username].tooltip = e.client
viz.callback(UPDATE,update)

def client_disconnected(e):
objects[e.username].remove()
del objects[e.username]
viz.callback(CLIENT_DISCONNECTED,client_disconnect ed)

def onExit():
viznet.client.disconnect(username=USER_NAME)
viz.callback(viz.EXIT_EVENT,onExit)

def onStopServer(e):
print 'Disconnected from server'
viz.quit()
viz.callback(viznet.SERVER_DISCONNECT_EVENT,onStop Server)

Jeff
02-19-2018, 09:15 PM
Here's example code of linking both the avatar and view to a virtual tracker. The link operators can be adjusted to change where the viewpoint is in relation to the avatar:

"""
forward='w',backward='s',left='a',right='d'
"""

import viz
import vizcam
import vizinfo

viz.go()
vizinfo.InfoPanel()

dojo = viz.addChild('dojo.osgb')
avatar = viz.addAvatar('vcc_male2.cfg')
avatar.state(2)

tracker = vizcam.addKeyboard6DOF(forward='w',backward='s',le ft=None,right=None,up=None,down=None,turnRight='d' ,turnLeft='a',pitchDown=None,pitchUp=None,rollRigh t=None,rollLeft=None)
avatarLink = viz.link(tracker,avatar)
viewLink = viz.link(tracker,viz.MainView)
viewLink.preTrans([0,2,-2])
viewLink.preEuler([0,10,0])