Drawing polygons in realtime

Hi,

Is it possible, in realtime, to draw polygons between points, e.g. a triangle between three points?

If not, could a function be written in blender’s game engine module to do that, and if so, how? Many thanks, 1/1 credit(s)

It is possible, but not particularly easily. Here’s how to do so:

  1. Create a triangle, for example.
  2. Spawn the triangle at whatever position in space.
  3. Pass a small list of objects that you want the triangle to point towards (you could do this when the triangle is added).
  4. Move the vertices of the triangle to focus on the X, Y, and Z position values of each object - use this:
cont = logic.getCurrentController()
obj = cont.owner
mesh = obj.meshes[0]

for v in mesh.getVertexArrayLength()
    vert = mesh.getVertex(0, v)
    vert.setXYZ(list[v].position[0], list[v].position[1], list[v].position[2])

in the triangle to lock the individual vertices of the triangle to the positions of the objects passed in the list you created earlier. I haven’t tested it yet, though…