# navigating vertex lists?

(Piraniac) #1

Hi everyone,

Im fairly new to python so i apologise now if this turns out to be a dud question

If you take an object with any number of vertices and with the vertex indices in any order, is it possible to ‘tell’ a vertex which ones are its immediate neighbours?
So far i have made a cloth patch using python as this allows me to control the ordering of the vertices, then any vertex can be told which other vertices in the list are its neighbours using simple maths junk.
Now i really need to be able to give python an arbitrary object and let it work out which vetices are connected, ie which are ‘next’ to each other.

I’m just experimenting with cloth simulation, using a mass-spring system, and i’ve got a cool ‘flag in the wind effect’ but now i want to move onto more advanced stuff and this is proving very tough.

I have a few ideas how to do this logically, but they don’t appear tio work in code so i put it to you great people

darn, i have a lesson, have to go hope this makes sense!

cheers
Piran

(theeth) #2

logically, you could go through the face list and assume that if a vertex is in the same face as another one, they are connected with a surface. For the edges, I don’t know how you could do that though, I haven’t work a lot with the 2.25 API…

Martin

(Piraniac) #3

Hey, thanks, i’m glad my garbled question made sense to someone!

Yeah, i’ve been exploring using the face list to return the connected verts but it’s proving difficult (or at least with my python skills it is :-? ).
So far i’ve managed to make a plane act like jelly, which is interesting but not quite cloth!
I’m assuming then that the index returned from the vertex when using object.faces is the same as the index used in object.verts and hey, if theeth reckons thats the way to go then it can’t be far wrong, eh?

thanks, and if i get anything good i’ll let y’all know

cheers
Piran