This question might have been posted before but a long time ago so I don’t know if at this moment there’s some progress in regards to this feature.
I want to dynamically edit an object (a plane that is supposed to become a terrain). I must subdivide it and change its vertex positions then, when the game is closed leave everything as it was at the beginning.
So, I have a simple plane (called Terrain) already created and what I am trying is this:
terrain_object = bpy.data.objects['Terrain'] terrain_object.dimensions = (10, 10, 0.0) # !!! # add some vertices terrain_object.data.vertices.add(4) terrain_object.data.vertices[-4].co = (1, -1, 1) terrain_object.data.vertices[-3].co = (-1, -1, 1) terrain_object.data.vertices[-2].co = (-1, 1, 1) terrain_object.data.vertices[-1].co = (1, 1, 1) # add one face terrain_object.data.tessfaces.add(1) terrain_object.data.faces[-1].vertices_raw = [7,4,5,6] terrain_object.data.update(calc_edges=True)
In first place, when I run the game I get this error:
Error: cannot add tessfaces to a mesh that already has polygons
Secondly, I see that when I change the dimensions of the plane (at # !!!) it is changed into the 3D view and remains changed after the game stops. Looks like working with bpy.data.objects is only for plugins, not for games, so I don’t know what will happen in the run-time executable when doing this.
Is there anything else I could take use of in order to make this work. To be able to do this would really push Blender game engine to the top and open limitless possibilities for editing objects in the game.