Hi,
In this case you will need to create a Vizard node for each object that you want to be viewable by the user. If you have one model file with individually viewable objects, then you need to call
getchild on each sub-object to ensure that a Vizard node is created for it.
You might want to create your own class that handles which objects are viewable and detects them for you. I've made a simple version here:
Code:
import viz
viz.go()
class NodeDetector:
def __init__(self):
self.__nodes = []
def addNode(self,node,name):
node.name = name
self.__nodes.append(node)
def detectNode(self,pos):
line = viz.screentoworld(pos)
info = viz.intersect(line[:3],line[3:])
if info.intersected:
if info.object in self.__nodes:
return info.object
return None
Cube1 = viz.add('theCube.ac')
Cube2 = viz.add('theCube.ac')
Cube3 = viz.add('theCube.ac')
Cube1.translate(-3,0,15)
Cube2.translate(0,0,15)
Cube3.translate(3,0,15)
nd = NodeDetector()
nd.addNode(Cube1,'Cube1')
nd.addNode(Cube2,'Cube2')
nd.addNode(Cube3,'Cube3')
def mijntimer(num):
node = nd.detectNode(viz.mousepos())
if node:
print 'you are over object : ', node.name
viz.callback(viz.TIMER_EVENT,mijntimer)
viz.starttimer(0,0.5,viz.FOREVER)