CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-23-2003, 12:54 AM   #1
ktpr
Frequenter
 
Join Date: May 2003
Posts: 183
select vertices from x,y,z coords?

sorry to be posting so much but I'm beginning to realize that your only as good as you knowledge of the mel library and I just started.

Does anyone know of a way to select a vertex by supplying coords?

cheers
ktpr
 
Old 05-23-2003, 01:08 AM   #2
Hugh
Compositor
 
Hugh's Avatar
Hugh Macdonald
2D Supervisor
Nvizible
United Kingdom
 
Join Date: Nov 2002
Posts: 1,465
Would this be on the currently selected poly object?

You'd have to select all of the vertices on the object and cycle through them, and return the closest one to the point you give....
__________________
Hugh Macdonald
nvizible

Last edited by Hugh : 05-23-2003 at 01:20 AM.
 
Old 05-23-2003, 01:17 AM   #3
ktpr
Frequenter
 
Join Date: May 2003
Posts: 183
Post

hheeh i just relpied to your thread.

yeah I would have two objects, but aren't exactly the same: What I want to do is iterate through the set of points of one object and for each point find the closest point on the other object. It would really easy if I could just say select all points w/in this x,y,z box....

Another alternative, I'm thinking is to do a binary search on the points of the other object but i don't really want to do that ...

cheers
ktpr
 
Old 05-23-2003, 01:20 AM   #4
Hugh
Compositor
 
Hugh's Avatar
Hugh Macdonald
2D Supervisor
Nvizible
United Kingdom
 
Join Date: Nov 2002
Posts: 1,465
Pseudocode:

Code:
global proc int getClosestVertex(float $searchPos[3], string $searchObject) { int $numVertices = getNumVerts($searchObject); int $vertex; float $dist = 9999.9; int $currentClosest = -1; for($vertex = 0; $vertex < $numVertices; $vertex++) { float $vertPos[3]; $vertPos = `xform -q -ws -t ($searchObject+".cv["+$vertex+"]")`; $thisDist = getDistance($vertPos, $searchPos); if($thisDist < $dist) { $currentClosest = $vertex; $dist = $thisDist; } } return $currentClosest; } global proc float getDistance(float $point1[], float $point2[]) { float $distance[3]; float $tot_dist = 0; int $i; for($i=0; $i<3; $i++) { $distance[$i] = $point1[$i] - $point2[$i]; $tot_dist += $distance[$i] * $distance[$i]; } return sqrt($tot_dist); }


you'll have to work out the getNumVerts proc yourself - and I did say this was pseudocode - I make no guarentees that it will work straight off, but it should point you in the right direction...

I've got into a bad habit of using float[3] instead of vector, so you might want to conver that....

Should all work, though...
__________________
Hugh Macdonald
nvizible
 
Old 05-23-2003, 01:22 AM   #5
Hugh
Compositor
 
Hugh's Avatar
Hugh Macdonald
2D Supervisor
Nvizible
United Kingdom
 
Join Date: Nov 2002
Posts: 1,465
Ah - all points within a box is probably easier....

Instead of checking the distance in the function above, check whether the X is in a certain range, and the same for Y and Z. If they are all in the desired range, then it is in the box...

And rather than just returning a vertex number at the end, as you find them, select them.
__________________
Hugh Macdonald
nvizible
 
Old 05-23-2003, 01:42 AM   #6
ktpr
Frequenter
 
Join Date: May 2003
Posts: 183
thanks for the puesdo code. I'll see what I can do with it; I can't have any user interaction and I don't want to search through the entire object.

cheers
ktpr
 
Old 05-23-2003, 08:46 AM   #7
wrend
existitial phage
Campbell Strong
Upper Sturt, Australia
 
Join Date: Feb 2002
Posts: 548
yeah, a developed volume select tool set would be tre-grande!
... but there are some rudiments already, the selectionConstraints ..... for poly components only = (
.. but you can build dummy, point matching, polys.

a cple of steps to do a box, but you can do spherical off the bat.

if you cactch more than one point, you can just pull your space down till its just one.

i've just started to use this, can be a fug load quicker than other approaches.

campbell.
 
Old 05-23-2003, 01:52 PM   #8
ktpr
Frequenter
 
Join Date: May 2003
Posts: 183
Hmm I wonder why it doesn't work with anything but polys. Doesn't even mention that limitation in the documentation. damn

Is there a way to get the points affected by a sculpt deformer? If so I could select all the points of one object, create a sculpt at a vertex location of the other, move the sculpt like a centimeter, and read what points were affected and pick the closest one. Perhaps some kind of event callback?

ktpr

Last edited by ktpr : 05-23-2003 at 02:26 PM.
 
Old 01-15-2006, 06:00 AM   #9
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed 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 03:20 AM.


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