Hi, could somebody please explain to me how to use the DirectSelection module from direct.directtools ? I’ve set up some sample code but it just doesn’t work:
import direct.directtools.DirectSelection as DirectSelection
from direct.showbase.ShowBase import ShowBase
class PandaApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.accept("mouse1", self.onLeftClick)
model = loader.loadModel("Apartment02")
model.find("**/+CollisionNode").show()
model.reparentTo(render)
model.ls()
self.selection = DirectSelection.SelectionRay()
def onLeftClick(self):
res = self.selection.pickGeom3D()
print res
app = PandaApp()
app.run()
The model is a simple house. I created an bounding box and tagged it with { barrier } in the .egg file. This is the output of model.ls():
ModelRoot Apartment02.egg
PandaNode Apartment02
CollisionNode Collision (6 solids)
GeomNode (1 geoms: S:(MaterialAttrib TextureAttrib TransparencyAttrib))
The return value of pickGeom3D() is None and I just don’t know why. I guess something is wrong with my scene setup but I couldn’t find any documentation for DirectSelection. Could someone please explain to me what I’m doing wrong? I’m using Panda 1.7.2 built for Python 2.7.2 on Windows 7 SP1.
Thanks !