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" |
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.
|
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) |
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 |
Frank.
Is exactly what you wanted, you're a genius. Thanks |
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" |
I do that, thanks
X=e.sensor.text.getMessage() print X => "HOUSE_GET_TEXT" |
Quote:
|
All times are GMT -7. The time now is 03:11 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC