I’ve been searching for a way to subdivide a plane at runtime in BGE. I’ve found some posts where it is discussed (even one from 2003(!)) but none offer the solution (except saying they found a working example… without posting the example).
I’m curious as well if you can make this work. The thing is that an object is converted to a compatible mesh for the game engine when you press P. So if the conversion does work with a subdivision modifier it will be applied during conversion. You’ll end up with the same mesh as when you applied the sudivision yourself. But this is just theory guessing and a little knowledge of the blender source.
You could edit the vertices yourself in game. You could let a GLSL shader do some magic (which would be the fastest)
What are you trying to accomplish exactly. If you need a texture on a plane and you want to modify the corners you could just modify the UV coords. As long as there are 4 vertices I guess you will not have the effect you described in your other post.
Hmm I don’t know what I should do with the uv coords to make it work. Do you mean I should match the uv’s with the modified vertex coordinates?
What I’m trying to accomplish: I have 5 planes with render2texture. The planes can be modified so that they fit 5 physical screens. Basically it’s a simple projectionmapping setup. The problem is that if a plane has only 4 vertices and you move them, the texture deforms a bit weird (it distributes the texture over two triangles instead of a quad). So I thought I may be able to callibrate a plane using 4 vertices, then subdivide it so the texture will be distributed more evenly.
But I think this workaround is also a dead end (looks like subdivide doesnt work in runtime)
You cannot create vertex’s in game, but you can edit those that are there
Modifiers are applied before the engine starts.
And the problem with your textures is likely that you have a ‘twist’ in your polygon. Remember that the order of vertices is not the same each time you play the game.
Ol jsut read the articles you mentioned and i think this might do the trick. But how do i implement this? I’m no expert when it comes down to opengl and don,t know how to use it in blender either…
object = logic.getCurrentController().owner
for mesh in object.meshes:
print(mesh.numPolygons)
for material in mesh.materials:
shader = material.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(vertex_shader, fragment_shader, True)
# get the first texture channel of the material
shader.setSampler('color_0', 0)
Perhaps someone with more GLSL experience can shred a light?