Gets whether the mouse is placed on the model

Hello, I’d like to ask if there is any way to obtain the Boolean value of whether the current mouse is placed on the model. I don’t know if there is any way to obtain it. I want to realize the operation mode like ZBrush, which can realize that the mouse is carved on the model and the rotating view is placed in the blank

你好,我想问一下有没有什么方法可以获取到当前鼠标是否放在模型上的布尔值,不知道有没有方法可以获取到,我想实现像ZBrush那样的操作方式,可以实现鼠标放在模型上是雕刻,放在空白处是旋转视图

Hi, perhaps the Mouselook Navigation addon would suit you for this purpose? It has an option for ZBrush-style navigation. (Disclaimer: I’m the developer of that addon)

As for your programming question, the easiest way would probably be to do a raycast (see the corresponding methods for Object, Scene and BVHTree), although it only works for meshes.
In principle, detecting the presence of objects under the mouse can also be done via selection and via depth-buffer. They work for non-meshes as well, but are more complicated and have their tradeoffs too.
I’ve implemented all three of these methods, so feel free to take a peek if you’re curious (and brave enough to delve into badly documented code) :wink:

2 Likes

Thank you very much. This is the effect I want. Thank you for your help. I hope to use your method. I don’t know if I can

十分感谢,这正是我想要的效果,感谢您的帮助,我希望使用您这个方法,不知道可不可以

Combined with @dairin0d suggestions, look at this template as well.
3.0\scripts\templates_py\operator_modal_view3d_raycast.py