Moving vertex of a plane in Game Engine

Hi guys,

I have a little problem in the Game Engine: I need to modify the vertex of a plane at each computed frame.

So I added a sensor “always” link to a Python script, and I have this inside:

import Blender
from Blender import NMesh

m1 = NMesh.GetRaw(“plane1”)
m1.verts[0].co[1] = 2.0

m1.update()

This code does change the y coordinate of the first vertex of the plane named “plane1”, but it does it only after I stop the game engine, not while running.

So I’m thinking maybe what I am using is not the good solution. Can you modifiy vertex in real time in the game engine?

Use an armature to move the vertex.

You need to move the vertex of plane at each frame? That’s exactly what my Flagshader does, certainly with far better performance than via Python. Play with it until you get what you want.

Well I googled this term and it doesn’t give me a serious lead. If you have more information, I take it.

You need to move the vertex of plane at each frame? That’s exactly what my Flagshader does, certainly with far better performance than via Python. Play with it until you get what you want.

I you provide me an URL with doc/download then I’ll play with it for sure :stuck_out_tongue:

obj = GameLogic.getCurrentController().getOwner()
msh = obj.getMesh()
vrt = msh.getVertex(0,0)
co = vrt.getXYZ()
co[1] = 2.0
vrt.setXYZ(co)

ashsid, you’re the man! Thank you!

Awww I’ve just found out this allows to change the vertex on the local coordinates of the object. Is there any way to use world coordinates with setXYZ?

EDIT: I placed the center of the object at the center of the world. It’s an ugly solution, but it does the job.

You cannot set vertex to global coordinates directly. But you can get orientation matrix of object, invert it and use it to multiply desired global coordinates of vertex. Result will be local coordinates that you will set to vertex. If you need example of matrix math, look at my Dynamic parent tutorial.

I you provide me an URL with doc/download then I’ll play with it for sure :stuck_out_tongue:

http://blenderartists.org/forum/showthread.php?t=87294&highlight=flag+waving