manipulating geometry in gameEngine ... HOW ?


(wizzleteet) #1

hi all,
I’d like interactively manipulate geometry (on a per-vertex basis) I have found some threads on this but they all speculate on undocumented python features.

Could somebody please give me pointers, or better yet an example on how to move a single vertex of a mesh interactively ?

kind regards,
wzzl


(Ben) #2

-This script attached to an object subtracts 1 to the z coord. of the vertex indexed as 1.

import GameLogic
cont = GameLogic.getCurrentController()
me = cont.getOwner()

mesh = me.getMesh()
vlen=mesh.getVertexArrayLength(0)

vert=mesh.getVertex(0,1).getXYZ()

vert[2]=vert[2]-1
	
mesh.getVertex(0,1).setXYZ(vert)

Ben


(Pooba) #3

Just out of curiosity, does the new deformed mesh detect collisons (for example, say i had a cube. A dynamic guy falls onto it and it’ll stop it. If i use the scipt to stretch out the cube, will the dynamic guy be able to fall on any part of it?

Thanx

Pooba


(Ben) #4

-No!It will collide at the original shape.

Ben


(wizzleteet) #5

hey that worked ,
thanks !

if one could only point me to the documentation of the used functions I’d be very happy…

This I think would be the spearhead of blender.org’s activities: documentation, documentation and documentation.
getVertex ???
where was that ?


(Ben) #6

-There’s not too much documentation about this methods.But if you do some “print dir()” can find intresting things.For example in the script above:

import GameLogic 
cont = GameLogic.getCurrentController() 
me = cont.getOwner() 

mesh = me.getMesh() 
print dir(mesh)

and look in the shell window.And so on…

Ben