WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-27-2013, 10:31 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
hi Frank,

thanx for ur replay. I made the text invisible. but now, the text does not appear at all.

am I doing something wrong?

one more thing. in my case I have 1 server and 2 clients, I want the text to appear when either one of the clients (or both) reaches the radiation source.

where do u recommend me to add the code for the proximity? (in client1 and client2 or in server side)?
Reply With Quote
  #2  
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
  #3  
Old 11-27-2013, 12:25 PM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
uh ok it's working. but, I wanted the text to appear when the avatar is for example 1 meter far from the radiation source. this is supposed to be a dangerous area and the message is there to warn the avatar that this is an affected area with radiation. so, he is not supposed to get close from it.

I am using only 1 PC, it is the server and the 2 clients at the same time.
there is a communication between server and clients:
1. server can communicate with client 1
2.server can communicate with client 2, but client 2 can't read its messages
3. client1 can communicate with client 2, but client 2 does not c the messages
4. client 1 communicate with 2, but again client2 can't c the messages

client 2 can't c messages sent by server and client 1.

mmm.. I think I will just add the text code in both clients and i want them to communicate with each other.

thanx
Reply With Quote
  #4  
Old 11-28-2013, 02:55 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Quote:
Originally Posted by maya View Post
uh ok it's working. but, I wanted the text to appear when the avatar is for example 1 meter far from the radiation source. this is supposed to be a dangerous area and the message is there to warn the avatar that this is an affected area with radiation. so, he is not supposed to get close from it
Simply change
Code:
sensor = vizproximity.Sensor( vizproximity.CircleArea(0.1),source=sphere)
to:
Code:
sensor = vizproximity.Sensor( vizproximity.CircleArea(1),source=sphere)
Now, the warning should appear whenever you approach the center of the sphere within 1 meter. If you want the warning area to be 1 meter surrounding the outside of the sphere, simply add the radius of the sphere to the number you pass to vizproximity.CircleArea().
Reply With Quote
  #5  
Old 11-28-2013, 03:15 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
Smile

Thanx a lot. It worked.
Reply With Quote
  #6  
Old 12-01-2013, 10:25 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
hi Frank,

I have one more question related to the proximity sensor.

I want the 2 clients (avatars) to see each other in the multi user environment.
also, I want to calculate the distance between the 2 clients and make them do some thing when they are 5 meters far from each other.

thanx.
I appreciate ur help.
Reply With Quote
  #7  
Old 12-02-2013, 07:57 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
I think you can just apply a vizproximity sensor with a circlearea of 5 (meters) to one (moving) avatar, and add a vizproximity target to the other (moving) avatar. When the avatars are within 5 meters from each other, the sensor (avatar1) should sense the target (avatar), and then you can respond to that event.

See the example below
Code:
import viz
import vizact
import vizshape
import vizproximity

viz.go()

sphere = vizshape.addSphere(radius=1)
sphere.setPosition(0,0,20)
sphere.color(viz.GREEN)

box = viz.add('box.wrl')
box.color(viz.ORANGE)

def moveObjects():
  boxPos = box.getPosition()
  boxPos[2] += .1
  box.setPosition(boxPos)
  spherePos = sphere.getPosition()
  spherePos[2] += .01
  sphere.setPosition(spherePos)

vizact.ontimer(.1, moveObjects)

manager = vizproximity.Manager()

target = vizproximity.Target(sphere)
manager.addTarget(target)
sensor = vizproximity.Sensor( vizproximity.CircleArea(5),source=box)
manager.addSensor(sensor)

def EnterProximity(e):
  print 'enter'

def ExitProximity(e):
  print 'exit'

manager.onEnter(sensor,EnterProximity)
manager.onExit(sensor,ExitProximity)
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
input from a text file dig Vizard 5 10-20-2013 01:20 AM
Lighting relevant text? knightgba Vizard 1 01-26-2011 05:33 PM
Informationboxes with text snoopy78 Vizard 3 07-16-2009 10:23 AM
Vizard tech tip: Text to Speech Jeff Vizard 1 01-15-2009 09:39 PM
3d Text with Transparent Borders vjosh Vizard 3 12-01-2004 10:50 AM


All times are GMT -7. The time now is 10:12 AM.


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