CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
reply share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 04-11-2014, 11:03 AM   #1
Per128
monky
 
Per128's Avatar
portfolio
Per Abrahamsen
Spain
 
Join Date: Aug 2002
Posts: 76
Send a message via ICQ to Per128
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-11-2014, 11:22 AM   #2
Klvnk
Lord of the posts
 
Klvnk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Feb 2014
Posts: 699
 
Old 04-11-2014, 11:43 AM   #3
AlpineMan
Frequenter
 
AlpineMan's Avatar
Chris Johnson
USA
 
Join Date: Aug 2003
Posts: 283
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-11-2014, 01:51 PM   #4
Per128
monky
 
Per128's Avatar
portfolio
Per Abrahamsen
Spain
 
Join Date: Aug 2002
Posts: 76
Send a message via ICQ to Per128
Quote:
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-11-2014, 02:27 PM   #5
AlpineMan
Frequenter
 
AlpineMan's Avatar
Chris Johnson
USA
 
Join Date: Aug 2003
Posts: 283
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-11-2014, 02:40 PM   #6
spacefrog
Frog of the posts
 
spacefrog's Avatar
Josef Wienerroither
Freelance
Vienna, Austria
 
Join Date: Sep 2002
Posts: 2,422
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-11-2014, 02:53 PM   #7
AlpineMan
Frequenter
 
AlpineMan's Avatar
Chris Johnson
USA
 
Join Date: Aug 2003
Posts: 283
Quote:
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-11-2014, 03:02 PM   #8
Per128
monky
 
Per128's Avatar
portfolio
Per Abrahamsen
Spain
 
Join Date: Aug 2002
Posts: 76
Send a message via ICQ to Per128
Quote:
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.

Quote:
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-11-2014, 03:37 PM   #9
AlpineMan
Frequenter
 
AlpineMan's Avatar
Chris Johnson
USA
 
Join Date: Aug 2003
Posts: 283
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-11-2014, 03:47 PM   #10
Per128
monky
 
Per128's Avatar
portfolio
Per Abrahamsen
Spain
 
Join Date: Aug 2002
Posts: 76
Send a message via ICQ to Per128
Quote:
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-12-2014, 07:42 AM   #11
miauu
Expert
 
miauu's Avatar
portfolio
Kostadin Kotev
Blagoevgrad, Bulgaria
 
Join Date: Sep 2009
Posts: 769
 
Old 04-12-2014, 05:09 PM   #12
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,420
Send a message via ICQ to denisT
Quote:
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-12-2014, 06:00 PM   #13
Per128
monky
 
Per128's Avatar
portfolio
Per Abrahamsen
Spain
 
Join Date: Aug 2002
Posts: 76
Send a message via ICQ to Per128
Quote:
Originally Posted by miauu


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


Quote:
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-13-2014, 09:39 AM   #14
miauu
Expert
 
miauu's Avatar
portfolio
Kostadin Kotev
Blagoevgrad, Bulgaria
 
Join Date: Sep 2009
Posts: 769
Quote:
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:
Code:
( 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-13-2014, 11:56 AM   #15
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,420
Send a message via ICQ to denisT
that's exactly the ways i usually use. the only difference is i prefer RayMeshGridIntersect
 
reply share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:52 AM.


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