Im trying to write a simple script which will allow for easy manipulation of vertexes. As anyone whos tried this out knows its not as simple as in the modelling engine where theres just one vertex at the end of each edge. From what i understand by asking loads of questions here, when a mesh is imported into the GE it is divided into seperate triangles, so for an ico sphere for example there are five vertices in one point in space due to five triangles vertices converging in the same point in space. So to move that apparently singular point you need to move five vertexes at once- otherwise things get messy…
So heres the script which i need some help with:
import GameLogic cont = GameLogic.getCurrentController() own = cont.getOwner() scene = GameLogic.getCurrentScene() grid = scene.getObjectList()["OBSphere"] mesh = grid.getMesh(0) if own.snap==0: n =0 for v_index in range(mesh.getVertexArrayLength(0)): vertex = mesh.getVertex(0, v_index) v_xyz = vertex.getXYZ() if v_xyz in GameLogic.globallist == 0: ## coords not in global list GameLogic.globallist.append(v_xyz) ## puts those coords in global list GameLogic.list,n =  ## creates a new list GameLogic.list,n.append(v_index) ## adds vertex index to new list n =+ 1 print GameLogic.list1 print GameLogic.globallist if v_xyz in GameLogic.globallist == 1: ## if coords are in the global list m = GameLogic.globallist.index(v_xyz) ## find how far along the global list those coords are GameLogic.list,m.append(v_index) ## appends the index to the list of indexes for that coord own.snap=1
You’ll have to copy and paste that, its a bit messy with notes too self
The idea is that is runs through the vertex index’s XYZ cooords, if it is the first instance of those coords the coords are added to a global list and a seperate list is created in which the index number is stored.
If it is not the first instance of these coords the vertex index value is added to the list with other vertexes from the same coords.
Im not too good at explaining things at the best of times but that wasnt too good. I want to end up with a global list of coords and seperate lists of all the indexes at those coords. The lists kinda reference each other because all indexes in list0 have the same coords,[ which happen to be the 0 value of the global list]
One problem with the code is the list creation thing, i dont know how to substitue variables into declaring new lists.
I dont know what the others are yet.
If someone could take a look id appreciate i think it could be a useful script for many people as it will make lists for any shape