Problem with CollisionRay

I post my code:

cs = new CollisionSphere(0,0,0,0.5);
cs2 = new CollisionSphere(0,0,0,5);
cs3 = new CollisionSphere(0,0,0,0.5);
//creo un nodo collisione dove mettere la sfera
sferaDiCollisione= new CollisionNode(“Sphere”);
sferaDiCollisione->add_solid(cs);
sferaDiCollisione2= new CollisionNode(“Sphere”);
sferaDiCollisione2->add_solid(cs2);

//creo un nodo scena che è attaccato al nodo Attore e lo visualizzo
 collAttore = Attore.attach_new_node(sferaDiCollisione);
 
 //NodePath collCamera = camera.attach_new_node(sferaDiCollisione3);
NodePath collAmbiente = environ.attach_new_node(sferaDiCollisione2);

collAttore.show(); 
collAmbiente.show();
queue = new CollisionHandlerQueue();

traverser.add_collider(collAttore,queue);

// Per cliccare su un oggetto 3d
Attore.set_tag(“myObjectTag”, “1”);
environ.set_tag(“myObjectTag”, “2”);
myTraverser = new CollisionTraverser(“ctraverser”);
pickerNode = new CollisionNode(“mouseRay”);
pickerNP = camera.attach_new_node (pickerNode);

pickerNode->set_into_collide_mask(GeomNode::get_default_collide_mask());

mouseWatcher = (MouseWatcher*)window->get_mouse().node();

//mpWorldManager->GameWindow()->get_mouse().node();
pickerRay = new CollisionRay(camera.get_x(), camera.get_y(), camera.get_z(),0,1,0);
pickerNode->add_solid(pickerRay);
myHandler = new CollisionHandlerQueue();
myTraverser->add_collider(pickerNP, myHandler);

framework.define_key(“mouse1”, “click”, MouseEvent, (void*) NULL);

with mouse event:
void MouseEvent(const Event *pTheEvent, void *pData) {

/*if(myHandler->get_num_entries()==1)
{
	cout<<"prova di collisione"<<endl;
}*/
if (!mouseWatcher->has_mouse()){
  // The mouse is probably outside the screen.
  return;

}
// This gives up the screen coordinates of the mouse.
LPoint2f mpos = mouseWatcher->get_mouse();

// This makes the ray’s origin the camera and makes the ray point
// to the screen coordinates of the mouse.
cout<set_from_lens(window->get_camera(0), mpos.get_x(), mpos.get_y())<<endl;

}

I where click click I get always 1.
Unlike the manual I replaced
pickerNode->set_from_collide_mask(GeomNode::get_default_collide_mask());
with
pickerNode->set_into_collide_mask(GeomNode::get_default_collide_mask());
why I suggested it at run time

I’m not sure what you’re trying to ask, but I’ll try to give some thoughts about your code.

set_from_lens will usually always return “true” when the coordinates are on screen. It returns true if the collision ray has been positioned successfully - it does not test for collisions; you will need to traverse the collision traverser and check the number of collisions there; but it seems you have commented out that code.

Furthermore, I should point out that collision rays cannot be used an “into” solids, and neither can GeomNodes be used as “from” objects. You should probably change it back to set_from_collide_mask if you want it to be able to pick visible geometry.

I would like to make Clicking on 3D Objects. I click with the mouse pointer to the successful and I determine the instructions

Sorry, I have no idea what you’re trying to say. Perhaps you could try stating your question in your native language, there might be other people on the forums speaking your language who can understand your question.

Io vorrei cliccare sull’oggetto della scena con il mouse.
I would click on the object of the scene with the mouse

Right, I understand what you’re trying to do, but what kind of problem are you running into specifically? What is the question that you’re trying to ask us?

io avvio queste istruzioni
I run these instructions:
panda3d.org/manual/index.php … 3D_Objects

Poi non capisco come ottenere almeno un valore che mi indichi che il mouse ha cliccato sull’oggetto
Then I do not understand how to get at least a value that indicates to me that the mouse has clicked on the object

grazie ancora, il vostro supporto, interesse o aiuto, mi ha portato a risolvere il mio problema, dovevo aggiungere
ok, thanks again, your support, interest or help, took me to solve my problem, I had to add
myTraverser->traverse(window->get_render());
if(myHandler->get_num_entries()==1)
{
cout<<“prova di collisione”<<endl;
}
come tu mi avevi indicato
as you told me you had indicated