PDA

View Full Version : Getting the surrounding vertices of a selected vertex


guosen84
02-28-2010, 11:16 AM
Hi!
I'm new to MEL scripting and Maya.
What i want to accomplish in my MEL script is to be able to get the surrounding vertices of a selected vertex of a NURBS surface.
I am able to select any vertex on the surface by the following code
select -r t.cv[5][3]; //e.g.

I notice that when I select the vertex, the vertices surrounding the vertex is also highlighted, creating a grid. The size of the grid also depends on the position of the selected vertex, so for vertices that are at the edge of the NURBS surface, the highlighted grid is actually smaller.

What i need to do is get the vertices in the grid indicated by Maya in order to perform some other operations. I have looked at the API but found no way to do it. The closest method is pickWalk however it is still dependent on the grid size which is variable.

Does anyone have ideas on how i could be able to the vertices in the grid?
Any help would be greatly appreciated.
Thanks and cheers!

:D

fgs

NaughtyNathan
03-01-2010, 09:36 AM
I'm not sure I fully understand what you want to do, but if you have CV[5][3] selected, then the surrounding CVs are always going to be:

.cv[5][4]
.cv[4][3] .cv[6][3]
.cv[5][2]

this is how Nurbs CVs work. (AFAIK :D )
You just need to increase and decrease each CV U and V index by 1. You probably don't even need to worry about the maximum CV limit, as Maya should clamp the CV index automatically.

:nathaN

guosen84
03-01-2010, 10:46 AM
I'm not sure I fully understand what you want to do, but if you have CV[5][3] selected, then the surrounding CVs are always going to be:

.cv[5][4]
.cv[4][3] .cv[6][3]
.cv[5][2]

this is how Nurbs CVs work. (AFAIK :D )
You just need to increase and decrease each CV U and V index by 1. You probably don't even need to worry about the maximum CV limit, as Maya should clamp the CV index automatically.

:nathaN

Hi nathaN!

Thanks for the reply.

What i intend to do is actually get the vertices according to how Maya shows the selection as illustrated in the picture.

http://imgur.com/taW3R.jpg (http://imgur.com/taW3R.jpg)

In Maya, when i select a vertex, a white grid is shown. The size of this grid is dependent on the location of the vertex if I'm not wrong.
What I want to do is actually get the vertices that forms the grid.

I'm not exactly sure if it could be done in MEL or is it just some thing that Maya shows to help modelers figure out which vertices are influenced by the selected vertex.

Hahaha, hope this clears up my question. :thumbsup:

Cheers,
fgs

NaughtyNathan
03-01-2010, 12:32 PM
it should be still basically as I described. The "size", or extent of the white "grid" you see is simply a visual representation of how far the cv influence extends due to the surface degree. For example, your surface is cubic (3 degree) so Maya highlights 2 extra "cv extents" from your selection in every direction. If you change the degree to Quintic the CV influence would extend to 3 "grid" spaces.

So you can still create an array of CV indices from the starting single point, you just need to query the surface degree first to know how big to make the array.

:nathaN

NaughtyNathan
03-01-2010, 01:00 PM
I've just realised something else that may affect your idea... the highlighted grid doesn't always correlate to CVs, what is being highlighted is "surface patches".

For example, select an entire row of CVs then move them close to a neigbouring row. Then select a CV that is 2 cvs away from the row you moved. You'll see that the highlighted grid doesn't fall on a CV. how does this affect your surrounding CVs idea?


:nathaN

CGTalk Moderation
03-01-2010, 01: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.