Search code examples
python3dwxpythonpyopenglmouse-position

Getting a 3d mouse position in python


I would like to develop a python application to import an obj file and then allow the user to interact with it, moving the loaded objects (including the roll and span movements). Furthermore, when the user clicks on an area of the model, the application will be able to take the 3D mouse coordinates. Any suggestion about how to obtain mouse coordinates (x,y,z)?

UPDATE this is the example code : pastebin.com/FxGczBEt I would like to print the x,y,z mouse coordinates instead of x,y only ("OnMouseDown" function)... I haven't found anything useful in the wx-python library...


Solution

  • Have you looked at Panda3d? I am working on a wx app that controls a scene rendered in Panda3d (in another word it's a panda3d app with wx for GUI).

    You can call the wxpython event loop from Panda3d side as mentioned here. https://www.panda3d.org/manual/index.php/Main_Loop

    In Panda3d, picking a model by mouse clicking seems like an easy task (collision with ray casting). https://www.panda3d.org/manual/index.php/Clicking_on_3D_Objects

    I know it's not a direct answer to your question but I just wanted to point out that mixing wxPython and Panda3d works so well.