View Single Post
  #10  
Old 11-27-2013, 11:13 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
I have tested it with the code below. With that code, the text appears when you enter the small red sphere.
Code:
import viz
import vizshape
import vizproximity

viz.go()
viz.MainView.setPosition([0,0.1,0])
#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)
#Increase the Field of View
viz.MainWindow.fov(60)
piazza = viz.add('piazza.osgb')

sphere = vizshape.addSphere(radius=0.2)
sphere.setPosition(0,0,20)
sphere.color(viz.RED)

text = viz.addText('radiation source',parent=sphere)
text.setPosition([-0.3,0.3,0])
text.setScale([0.2]*3)
text.color(viz.RED)
text.visible(viz.ON)

text_2D = viz.addText('radiation source area', viz.SCREEN )
text_2D.setPosition(0,0,20)
text_2D.color(viz.RED)
text_2D.visible(viz.OFF)

#Create proximity manager
manager = vizproximity.Manager()

#Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)
sensor = vizproximity.Sensor( vizproximity.CircleArea(0.1),source=sphere)
manager.addSensor(sensor)

#Change state of avatar to talking when the user gets near
def EnterProximity(e):
  text_2D.visible(viz.ON)
  print 'enter'

#Change state of avatar to idle when the user moves away
def ExitProximity(e):
  text_2D.visible(viz.OFF)
  print 'exit'

manager.onEnter(sensor,EnterProximity)
manager.onExit(sensor,ExitProximity)
Seems like your setup is a little more complicated than what I'm used to. So are we talking about three different computers connected with each other and communicating via a network? With 1 computer being the server, and 2 computers being the client?

Either way, the code for making the text appear should be on every party that needs to see the text. For instance, if the text has to appear on both clients, then both clients need the code for making the text visible and invisible. It seems like the condition to show the text on any machine is that one of the two clients enter the radiation zone. So in that case, you should at least communicate the state of each client to each other, and make the text appear when either one of them enters the radiation zone.

You could also let each client communicate to the server whether they are in the radiation zone or not, and if one of the clients enters the radiation zone, you could let the server send a message to both clients.

In both cases, you need a proximity sensor in client1 and client2, and somehow communicate the states of those clients to each other (either directly, or through the server).

Please elaborate more on your specific problem if these suggestions do not point you in the desired direction.
Reply With Quote