I need to receive the coordinates of a mouse click on a 3d surface. Mostly I’ve been following code from https://www.panda3d.org/manual/index.php/Clicking_on_3D_Objects but after calling traverse(render) on my traverser object, my collisionhandlerqueue object is still empty.
I’m thinking I need to set a collision mask on the visible geometry somehow, but the line
scene.setCollideMask(BitMask32.bit(0))
which I thought would be the brute force solution doesn’t seem to have done anything.
This will show visual debugging information about what collisions are happening.
This shows that the collisions are happening (in fact, since the “from” mask was already set to the default mask for visible geometry, setCollideMask wasn’t necessary); they are just not showing up in the queue.
Also, if you store a CollisionTraverser in base.cTrav, it will be automatically traversed every frame. This is probably not what you want in this case; you probably want to create your own traverser (and not store it in self.cTrav, but under a different name).
Finally, you probably want to call disableMouse() to disable ShowBase’s control over the camera. I’m not quite sure why this is important in this specific case, but it seems to solve the problem with the collisions not showing up in the queue.