CollideMask question??

I load small floor to test collision

        environ  = loader.loadModel("floor.egg")
        environ.setScale(20)
        environ.setH(180)
        environ.setPos(0,0,-100)
        environ.reparentTo(render)
        environ.node().setIntoCollideMask(BitMask32.bit(1))

I set intoCollideMask using bit 1 then load another object that attached with the ray downward

  #load object
        self.obj  = loader.loadModel("smiley.egg")
        self.obj.setScale(20)
        self.obj.setPos(0,0,0)
        self.obj.reparentTo(render)        

        #set collision ray to be solid
        rayNode = self.obj.attachNewNode(CollisionNode('rayDown'))
        ray = CollisionRay(0, 0, 0, 0, 0, -1)
        rayNode.node().addSolid(ray)
        rayNode.node().setFromCollideMask( BitMask32.bit(1))
        rayNode.show()

the ray use the mask as same as above
Why i cannot check the collision between them (ray and floor not collid)
thank you for any answer

You are setting the into collide mask on the wrong node. environ.node() is not the CollisionNode that corresponds to your collision geometry; it’s just the top node returned by loadModel().

One solution would be to find the actual CollisionNode and call setIntoCollideMask() on that. But it would be better just to use the NodePath-level setCollideMask() method (not the PandaNode-level setIntoCollideMask() method), like this:

        environ  = loader.loadModel("floor.egg")
        environ.setScale(20)
        environ.setH(180)
        environ.setPos(0,0,-100)
        environ.reparentTo(render)
        environ.setCollideMask(BitMask32.bit(1))

The NodePath-level method is, in general, more powerful and easier to understand than the lower-level PandaNode method.

David

Is setCollideMask() functiion set bitMask to the collision node as Into node?

and what is different between setCollideMask() function and set[From/Into]CollideMask()

Thank you for your answer, I got it…

NodePath.setCollideMask() adjusts the into collide mask of nodes at that node level and below. It is the method you should call most of the time for ordinary nodes in the world.

PandaNode.set[Into/From]CollideMask() adjusts the into or from collide mask of that particular node only. It does not traverse below to children nodes. It is the only way to set a from collide mask on a node that you are adding to the collision traverser; but there’s not usually any other time to use either of these methods.

David