Challenge: Object under cursor

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

REPLY TO THREAD
 
Thread Tools Search this Thread Display Modes
Old 04 April 2014   #1
Challenge: Object under cursor

I have not found any efficient ways to reliably return good results performing this very basic task in Maxscript.


Am I missing something here, or do we still not have access to one of the most fundamental functions imaginable in scripting?
 
Old 04 April 2014   #2
mousetrack ?
 
Old 04 April 2014   #3
There was at last count at least two hit-testing API's in maxscript that can do that. Plus the mousetrack functions mentioned above.
 
Old 04 April 2014   #4
Originally Posted by AlpineMan: There was at last count at least two hit-testing API's in maxscript that can do that. Plus the mousetrack functions mentioned above.


Mousetrack doesn't play well with epoly. I can't comment on the two others as you don't mention them by name.
__________________
http://www.per128.com - freelance 3d artist
 
Old 04 April 2014   #5
These are old, and despite my logging a few bugs against them years ago (As an internal employee) no one was interested in fixing them:

http://docs.autodesk.com/3DSMAX/14/...EF28C5-1732.htm

http://docs.autodesk.com/3DSMAX/14/...DE1B34-1733.htm

So as I remember, years ago, I had limited success with them. So go ahead and give them a try.
 
Old 04 April 2014   #6
Was'nt there some new method implemented and exposed in Max 2015 for the new placement tool? Maybe i should' nt mention it because it's not released yet...
__________________

PowerPreview: High Quality Nitrous Previews for 3ds Max 2012|2013|2014

[ Free Download (ScriptSpot) ]

Home of The Frogs | Online Portfolio
 
Old 04 April 2014   #7
Originally Posted by spacefrog: Was'nt there some new method implemented and exposed in Max 2015 for the new placement tool? Maybe i should' nt mention it because it's not released yet...


I'll followup later on that point. I'm presently not at home.
 
Old 04 April 2014   #8
Originally Posted by AlpineMan: These are old, and despite my logging a few bugs against them years ago (As an internal employee) no one was interested in fixing them:

http://docs.autodesk.com/3DSMAX/14/...EF28C5-1732.htm

http://docs.autodesk.com/3DSMAX/14/...DE1B34-1733.htm

So as I remember, years ago, I had limited success with them. So go ahead and give them a try.



Thanks, AlpineMan. I have been staying away from anything with an acceleration structure, for performance concerns. The script is triggered by external input and may be called up to 10 times/second, with no guarantee that the meshes haven't changed between each time.

The scary aspect of IntersectRay, IntersectRayScene is that they will work as advertised in most cases, but occasionally will give bogus results. I'm noticing those bad results a lot now since the functions are called so frequently.

Originally Posted by spacefrog: Was'nt there some new method implemented and exposed in Max 2015 for the new placement tool? Maybe i should' nt mention it because it's not released yet...

Has to be backwards compatible though :/
__________________
http://www.per128.com - freelance 3d artist
 
Old 04 April 2014   #9
Any hit testing will require iterating through the scene graph, updating all dependencies in the INode's and their meshes. So it will always be expensive anyway you look at it. Even just hovering your mouse around in the viewport will do what I just described, just so you can get a silly little popup window with the name of the object...
 
Old 04 April 2014   #10
Originally Posted by AlpineMan: Any hit testing will require iterating through the scene graph, updating all dependencies in the INode's and their meshes. So it will always be expensive anyway you look at it. Even just hovering your mouse around in the viewport will do what I just described, just so you can get a silly little popup window with the name of the object...


Well, I was playing with an idea of using a scene change event to update everything, though at that point it's starting to get ugly...
__________________
http://www.per128.com - freelance 3d artist
 
Old 04 April 2014   #11
Did you tried Picking Scene Nodes By Region?
 
Old 04 April 2014   #12
Originally Posted by Per128: I have not found any efficient ways to reliably return good results performing this very basic task in Maxscript.


Am I missing something here, or do we still not have access to one of the most fundamental functions imaginable in scripting?

there are two types of 'hit test'
# hit to select
# hit to mesh intersect

what do you really want?
 
Old 04 April 2014   #13
Originally Posted by miauu: Did you tried Picking Scene Nodes By Region?


Miauu, I came across that, but couldn't find that anyone had actually used it. Have you had success with it?


Originally Posted by denisT: there are two types of 'hit test'
# hit to select
# hit to mesh intersect

what do you really want?


Hi DenisT, ultimately mesh intersect, to get the face under the cursor of any object in the scene in real-time as the user moves the mouse pointer. In the past I've been using a plugin that exposes PolyObject::IntersectRay to Maxscript (resulting in an epoly version of IntersectRayEx). It's only now that I'm calling it a lot that I find it quite frequently gives wrong, and seemingly random, results.
__________________
http://www.per128.com - freelance 3d artist
 
Old 04 April 2014   #14
Originally Posted by Per128: Miauu, I came across that, but couldn't find that anyone had actually used it. Have you had success with it?


I use it in one of my scripts to select splines under the cursor and it works pretty well. For mesh objects I use IntersectRay which works with editable poly objects with no problems.

Try this:

  (
  	objsUnderCursorArr = (boxPickNode (box2 (mouse.pos - [2,2]) (mouse.pos + [2,2])) crossing:true )
  )

The result will be an array with all objects under the cursor.
 
Old 04 April 2014   #15
that's exactly the ways i usually use. the only difference is i prefer RayMeshGridIntersect
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:10 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.