3dsmax mouse click event

3dsmax mouse click event

3233895328
Contributor Contributor
897 Views
3 Replies
Message 1 of 4

3dsmax mouse click event

3233895328
Contributor
Contributor

I want to implement a mouse click event in 3dsmax, where you click on any position on the model and then return to the coordinates of the clicked position on the model

0 Likes
Accepted solutions (2)
898 Views
3 Replies
Replies (3)
Message 2 of 4

wernienst
Collaborator
Collaborator
Accepted solution

There is the pickPoint() function.

The How to ... Draw a Freehand Spline tutorial may also help.

 

Message 3 of 4

MartinBeh
Advisor
Advisor
Accepted solution

You could use "pickPoint" in combination with regular 3D snaps, or you can use the "on mousePoint" event in combination with "mapScreenToWorldRay" and some ray casting. The first should be fine if all you need is a 3D world coordinate; the latter is probably better if you need to know which object was clicked. 

 

PS: Looking at the documentation, I realize that maybe the first variant could use the "boxPickNode" function to also find out what object was clicked on...?

 

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
0 Likes
Message 4 of 4

3233895328
Contributor
Contributor
global modelA = ${}  -- 获取场景中名为 "ModelA" 的对象

-- 定义鼠标点击时的回调函数
fn mouseClickCallback msg ir obj faceNum shift ctrl alt =
(
-- 处理鼠标点击事件

if msg == #mouseAbort then
(
return #abort
)
elif if msg == #mousePoint then
(
-- 如果光标下有模型A,输出其名称
if isValidNode modelA and modelA == obj then
(
local rayStart = ir.pos
local rayStartStr = "[" + (rayStart.x as string) + ", " + (rayStart.y as string) + ", " + (rayStart.z as string) + ", "+(ctrl as string) +" ]"
handle_mouse_point(rayStartStr)
-- python.Execute("handle_mouse_point("+(rayStart as string)+")")
)
)
else
(
#continue
)
return #continue -- 继续跟踪
)

-- 开始鼠标跟踪,指定模型A和回调函数
mouseTrack trackCallback:mouseClickCallback on:modelA
0 Likes