Well I still got that error when I set
bla.setIntoCollideMask(BitMask32(1))
for the buttons and
self.pickerNode.setFromCollideMask(BitMask32(0))
. I now know that this comes from the star ships flying “underneath” the star map. If I dont give the ships a collision solid, the Ray->Sphere not allowed error does not come up. The ships are also into objects.
Can this be prevented by setting a BitMask? Can you please give me the Mask values for these constellations, I will read up later on the subject?
from -> into (my guess):
Projectiles (01) -> Ships (00)
Ray (11) -> Buttons (10)
other constellations get ignored, especially Ray -> Ships.
Is it healthy to have two CollisionTraversers? Like, one in the map, one in the world? Or should the map use the one from the world?
EDIT:
With self.pickerNode.setIntoCollideMask(BitMask32.allOff()) at least the error goes away. But still, print self.rayHandler.getNumEntries() prints 0.
EDIT2:
Well I need this solved, its a very basic mechanism of my game. I will paste some code, propably someone can come up with observations.
def buildStarmap()
self.mouseTrav = CollisionTraverser()
self.rayHandler = CollisionHandlerQueue()
self.pickerNode = CollisionNode("mouseRay")
pickerNP = camera.attachNewNode(self.pickerNode)
self.pickerNode.setIntoCollideMask(BitMask32.allOff())
self.pickerNode.setFromCollideMask(BitMask32(0))
self.pickerRay = CollisionRay()
self.pickerNode.addSolid(self.pickerRay)
self.mouseTrav.addCollider(pickerNP,self.rayHandler)
def buildStobArt(self, stobname, buttonposx, buttonposy, indexno):
stobartcm = CardMaker("stobart")
stobartcm.setFrame(-1,1,-1,1)
stobart = stobartcm.generate()
stobart.setIntoCollideMask(BitMask32(1))
stobart.setTag("stobname", stobname)
stobartnode = self.StarmapArtNode.attachNewNode(stobart)
stobartnode.setPos(buttonposx*0.8*self.scalefactor/480,0,buttonposy*0.5*self.scalefactor/300)
stobartnode.setColor(0.1,0.1,0.1,1.0)
stobartnode.setScale(0.075,1.0,0.02)
stobartnode.setTag("stobname", stobname)
stobartnode.setShaderOff()
return stobartnode
def buildStobText(self, stobname, buttonposx, buttonposy):
stobtext = OnscreenText(text=stobname, fg=self.findStobPointColor(StarmapData[stobname][6]),
pos=(buttonposx*0.8*self.scalefactor/480,buttonposy*0.5*self.scalefactor/300-0.01),
scale=(0.03), align=TextNode.ACenter, sort=1, font=loader.loadFont("cmss12"),
mayChange=True)
stobtext.node().setIntoCollideMask(BitMask32(1))
stobtext.setTag("stobname", stobname)
stobtext.reparentTo(self.StarmapTextNode)
return stobtext
def processClick(self):
if base.mouseWatcherNode.hasMouse():
mousepos = base.mouseWatcherNode.getMouse()
self.pickerRay.setFromLens(base.camNode, mousepos.getX(), mousepos.getX())
self.mouseTrav.traverse(aspect2d)
print self.rayHandler.getNumEntries()
print self.rayHandler.getEntries()
if self.rayHandler.getNumEntries() > 0:
bla ...
Right now the prints at the end just print 0 and [].