Help determing what the user clicked

I only recently installed Panda3D and have found that looking at other peoples code seems to be far more educational for me than reading through the manual.

The one thing i can’t seem to find is how to determine the whether or not the player has clicked on a certain target. I would also like to be able to paint a texture to where the player clicked, and depending on the what was hit (I am assuming this would be done by checking what time of texture was applied to it) play a sound.

Any input would be greatly appreciated.

there is an example in the manual regarding “picking a 3d object” … 3D_Objects

hope that helps,

Yeah that was exactly what i was looking for, thanks.

What would i have to do though if i wanted to paint a texture on a surface if i didnt click a pickable object?

Do you mean, put a little splat or something wherever the user clicks? That’s actually kind of tricky, but it’s possible. The easiest thing to do is just to put a little card in front of wherever the user clicked, using the CardMaker class. There’s a longish discussion on a related topic in this thread.

But it’s not really that much harder to project a texture splat onto wherever the user clicks. See Projected Textures in the manual.

In either case, you’ll have to be comfortable working with the scene graph: you’ll have to be able to extract the point of intersection in world coordinates from the CollisionEntry that the picker gives you, and create a new object (either a card or a LensNode) that’s positioned above the point of intersection and rotated in the right direction. Panda makes operations like this really quite easy, but it does take some practice to get it right and some experience to make it easy.