WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-31-2014, 09:28 AM
roobert roobert is offline
Member
 
Join Date: May 2014
Location: Pachuca, Hidalgo, México
Posts: 34
Send a message via Skype™ to roobert
Question Information associated with a model

Can I associate information to a model? so when I go in, this information is displayed

I use sensor proximity.

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)

#Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)

#MODEL
newTarget=viz.add('model/objeto.dae', pos=[0,0,0])
newTarget.collideBox()
newTarget.alpha(0.8)
sensor = vizproximity.addBoundingSphereSensor(newTarget,sca le=2)
manager.addSensor(sensor)

#ACTIVE SENSOR
def EnterProximity(e):
print "SHOW INFORMATION"

#OFF SENSOR
def ExitProximity(e):
print "HIDDEN INFORMATION"
Reply With Quote
  #2  
Old 07-31-2014, 11:34 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
There's a similar thread where you can find the answer: http://forum.worldviz.com/showthread...ight=proximity. I don't know what kind of information you want to show, but if you make a 2D text object of that information, you can toggle the visibility of the text while entering or leaving the proximity sensor area.
Reply With Quote
  #3  
Old 07-31-2014, 04:03 PM
roobert roobert is offline
Member
 
Join Date: May 2014
Location: Pachuca, Hidalgo, México
Posts: 34
Send a message via Skype™ to roobert
It correct but when I'll have more of one model the text is variable, how come I can do?

import vizmat
import vizact
import vizproximity
import vizdlg

viz.go()
viz.setMultiSample(4)
viz.fov(60)
viz.clearcolor(viz.SKYBLUE)
viz.collision(viz.ON)

ground = viz.add('tut_ground.wrl') # PISO
ground.collidePlane()

COMPLEJO01 = viz.addChild('sky_day.osgb')
COMPLEJO01.collideMesh()

viz.MainView.move([0,0,-5]) #Mi primera posición

#GRAVEDAD
viz.phys.enable()
viz.phys.setGravity(0,-9.8,0)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)

#Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)

##############PANEL DE INFORMACIÓN#########
myPanel = vizdlg.Panel()
viz.link(viz.CenterCenter,myPanel,offset=(-350,50,0))
myPanel.enable()

##############ACCIONES DEL SENSOR###################
#CREANDO ACCIÓN CUANDO ENTRE ACTIVO EL SENSOR
def EnterProximity(e):
global myPanel
myPanel.reset()
myPanel.visible(viz.ON)
model=e.sensor.getSourceObject()
posicion=str(model.getPosition())
posicion=viz.addText('Posición: '+posicion)
#I would like the text will be variable
#The text panel is cleaned before it appears
text1.visible(viz.ON)
myPanel.addItem(posicion,align=vizdlg.ALIGN_CENTER )
myPanel.addItem(text1,align=vizdlg.ALIGN_CENTER)
##############I WOULD LIKE THAT TEXT1 WILL BE VARIABLE#######

#CAMBIANDO LA ACCIÓN CUANDO EL USUARIO SE ALEJA
def ExitProximity(e):
global myPanel
myPanel.visible(viz.OFF)
text1.visible(viz.OFF)

#MODELOS ESTÁTICOS
house1=viz.add('box.wrl', pos=[-10,0,-20])
house1.collideBox()
text1=viz.addText('house1',parent=house1)
text1.visible(viz.OFF)
sensor1 = vizproximity.addBoundingSphereSensor(house1,scale= 1)
manager.addSensor(sensor1)
manager.onEnter(sensor1,EnterProximity)
manager.onExit(sensor1,ExitProximity)

house2=viz.add('ball.wrl', pos=[0,0,0])
house2.collideBox()
text2=viz.addText('house2',parent=house2)
text2.visible(viz.OFF)
sensor2 = vizproximity.addBoundingSphereSensor(house2,scale= 1)
manager.addSensor(sensor2)
manager.onEnter(sensor2,EnterProximity)
manager.onExit(sensor2,ExitProximity)

house3=viz.add('duck.wrl', pos=[10,0,20])
house3.collideBox()
text3=viz.addText('house3',parent=house3)
text3.visible(viz.OFF)
sensor3 = vizproximity.addBoundingSphereSensor(house3,scale= 1)
manager.addSensor(sensor3)
manager.onEnter(sensor3,EnterProximity)
manager.onExit(sensor3,ExitProximity)
Reply With Quote
  #4  
Old 08-01-2014, 02:10 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
When posting code, please use the code tags by clicking the hashtag symbol (#), as it keeps indentation which is essential for python code. This should do the trick, every sensor has it's own text that becomes visible when entering the sensor area:
Code:
import vizmat
import vizact
import vizproximity
import vizdlg

viz.go()
viz.setMultiSample(4)
viz.fov(60)
viz.clearcolor(viz.SKYBLUE)
viz.collision(viz.ON)

ground = viz.add('tut_ground.wrl') # PISO
ground.collidePlane()

COMPLEJO01 = viz.addChild('sky_day.osgb')
COMPLEJO01.collideMesh()

viz.MainView.move([0,0,-5]) #Mi primera posición

#GRAVEDAD
viz.phys.enable()
viz.phys.setGravity(0,-9.8,0)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)

#Add main viewpoint as proximity target
target = vizproximity.Target(viz.MainView)
manager.addTarget(target)

##############PANEL DE INFORMACIÓN#########
myPanel = vizdlg.Panel()
viz.link(viz.CenterCenter,myPanel,offset=(-350,50,0))
myPanel.enable()

##############ACCIONES DEL SENSOR###################
#CREANDO ACCIÓN CUANDO ENTRE ACTIVO EL SENSOR
def EnterProximity(e):
	global myPanel
	myPanel.reset()
	myPanel.visible(viz.ON)
	model=e.sensor.getSourceObject()
	posicion=str(model.getPosition())
	posicion=viz.addText('Posición: '+posicion)
	#I would like the text will be variable
	#The text panel is cleaned before it appears
	e.sensor.text.visible(viz.ON)
	myPanel.addItem(posicion,align=vizdlg.ALIGN_CENTER)
##############I WOULD LIKE THAT TEXT1 WILL BE VARIABLE#######

#CAMBIANDO LA ACCIÓN CUANDO EL USUARIO SE ALEJA
def ExitProximity(e):
	global myPanel
	myPanel.visible(viz.OFF)
	e.sensor.text.visible(viz.OFF)

class house():
	def __init__(self, object, text, position):
		self.obj = viz.add(object, pos = position)
		self.obj.collideBox()
		sensor = vizproximity.addBoundingSphereSensor(self.obj,scale= 5)
		sensor.text = viz.addText(text,parent = self.obj)
		sensor.text.visible(viz.OFF)
		manager.addSensor(sensor)

house1 = house('box.wrl', 'house1', [-10,0,-20])
house2 = house('ball.wrl', 'house2', [0,0,0])
house3 = house('duck.wrl', 'house3', [10,0,20])

manager.onEnter(None,EnterProximity)
manager.onExit(None,ExitProximity)
Reply With Quote
  #5  
Old 08-01-2014, 07:40 AM
roobert roobert is offline
Member
 
Join Date: May 2014
Location: Pachuca, Hidalgo, México
Posts: 34
Send a message via Skype™ to roobert
Frank.
Is exactly what you wanted, you're a genius.
Thanks
Reply With Quote
  #6  
Old 08-01-2014, 08:25 AM
roobert roobert is offline
Member
 
Join Date: May 2014
Location: Pachuca, Hidalgo, México
Posts: 34
Send a message via Skype™ to roobert
And if I want get the text that put in the node, how I do?

house1 = house('box.wrl', 'HOUSE_GET_TEXT', [-10,0,-20])

sensor.text = viz.addText(text,parent = self.obj)


e.sensor.text.visible(viz.ON)
X=e.sensor.text.getText()
print X => "HOUSE_GET_TEXT"
Reply With Quote
  #7  
Old 08-01-2014, 08:45 AM
roobert roobert is offline
Member
 
Join Date: May 2014
Location: Pachuca, Hidalgo, México
Posts: 34
Send a message via Skype™ to roobert
I do that, thanks

X=e.sensor.text.getMessage()
print X => "HOUSE_GET_TEXT"
Reply With Quote
  #8  
Old 08-01-2014, 09:34 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Quote:
Originally Posted by roobert View Post
Frank.
Is exactly what you wanted, you're a genius.
Thanks
You're welcome! And well done on finding the answer to your last question on your own!
Reply With Quote
Reply

Tags
sensor proximity, viz.info

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
Access the vertices of a model pankaj bansal Vizard 1 03-29-2013 07:02 PM
Accesing different parts of model pankaj bansal Vizard 1 12-30-2012 10:10 PM
3ds Exported .IVE Model mirrors movement of Mainview Felix Vizard 9 05-18-2012 09:17 AM
Change model alpha and memory leak hosier Vizard 2 06-25-2009 10:55 AM
Model sizes Pastscapian Vizard 15 10-07-2006 02:48 PM


All times are GMT -7. The time now is 11:19 PM.


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