PDA

View Full Version : getting the mouse click (3D) position on item in world


gohkgohk
08-11-2009, 06:58 PM
When mouse clicked on a surface, how to get this 3D coordinate?
I want to do this, because i want to create curves on the surface, rather than on XY plane.
Do anyone hv idea on it?
thx

bendingiscool
08-12-2009, 09:33 AM
Sounds like you could just make the surface live.

Chris

cbamber85
08-13-2009, 08:44 PM
Someone has posted a similar a question before. To build it from scratch, it generally involves creating a pick ray using the current camera settings (factoring in offset for orthographic, and FOV proportion for perspective), and then testing it for intersection with all the polygons in the rough region of the ray - using fustrum clipping for example.

gohkgohk
08-15-2009, 05:17 AM
Someone has posted a similar a question before. To build it from scratch, it generally involves creating a pick ray using the current camera settings (factoring in offset for orthographic, and FOV proportion for perspective), and then testing it for intersection with all the polygons in the rough region of the ray - using fustrum clipping for example.
If i just want to get a clicked point on surface internally, but not make any curce, make live can not help.
is this mean Maya Api do not provide this function? And I need to do it buy ray picking?

cbamber85
08-15-2009, 07:52 AM
Off the top of my head I can't think of an API command that does exactly what you want, but there are commands that get a clicked XY coordinate of a window, find objects intersecting a ray, etc. It would just be a case of chaining these together in deriving your own custom context command (probably from a MPxSurfaceShapeUI). If this isn't for learning and time is crucial, I would do some internet searching as it is a common function.

meuH
08-15-2009, 04:09 PM
viewToWorld() is what you are looking for, if I understand what you are trying to do.
It will give you the position and the direction for your click through the viewport you clicked into (compute all camera data internally from what I can tell).

look it up in the API M3dView class reference documentation.

you'll have to compute the intersection between the ray from the above method and whichever object in your scene yourself after that, the API provide all the necessary methods for that.

CGTalk Moderation
08-15-2009, 04:09 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.