View Full Version : scripted snaps ?
06-23-2003, 07:23 PM
hello, I was wondering if it would be possible to create scripted snaps. Can you get to the existing snap functionality?
the one i have in mind would be best described as 'distance from endpoint'. so you would enter a distance, and then it would snap to that distance on the selected edge from it's endpoint. great for cutting a given distance from an edge, for instance when creating a 'smoothed bevel'
06-25-2003, 07:39 PM
i've found that through the viewport you can get a 3D location of a screen point and what not, but nothing to directly acces and modify the edge and vertex ID's / location of that on which you snap.
06-25-2003, 09:53 PM
Are you saying you would there to be maxscript functionality in which subobject parts like edges and vertices could be snapped to or indicated as being scrolled over like during a mouse tool use? Like they way it automatically does when you are in a subobject mode for each subobject respectively? Or if you have the snap tool on?
06-26-2003, 08:35 AM
like when you have the snap tool on. The easiest way would be to modify the enpoint snap, but if i can code the snap and user feedback manually that would be ok too.
06-26-2003, 09:51 AM
Edge detection is a very tricky subject by itself. I sorted it out (somewhat) for my CleanCut script, but I see a bit of a hurdle in getting from there to where you want to go. Here's what I did, roughly, for the edge detection routine (for what it's worth):
1. Create a mesh snapshot of the EPoly object (assuming that's what you're operating on), since the next step won't work on EPoly.
2. Use mapScreenToWorldRay() and intersectRayEx() to find out what face (triangle) on the mesh is under the mouse.
3. By comparing vertices, find out which polygon on the EPoly contains the mesh triangle.
4. Loop through the poly's edges and use the intersection point from intersectRayEx(), the edge's vert positions, the dot product and some other math wizardry to find out which edge is closest to the mouse.
Step 4 is obviously the tricky part. Somewhere in my function for doing this I also derived a distance along the edge as a percentage (0.0 to 1.0). There may be a way to use that to find a corresponding world-unit distance. I don't really know at this point:shrug:
If I haven't thoroughly confused you, then there's hope!
01-15-2006, 12:00 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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.