how to set texture while runtime

Hello everyone!

I’ve got a problem in BGE with textures. I have to add a circle from a layer to my scene and change the positions of the vertices. This is not a problem. The problem is that the position of the vertices is different everytime I add the circle. So I have to add an texture to the circle after I change the positions of the vertices. When I do it first the texture looks wrong.

In Blender Render I solved this problem but I dont know how to do it in BGE using python. Can anyone tell me how to add the texture with python while runtime?

Thanks to everyone how’s trying to help me!

you cant… however you can move verticies of a mesh ?

Would you post some pictures. I really have no idea what you want to do and what fails.

So this is my circle:


Now I add this from a layer to my sceen and change the vertices to the positions I have to:



floor= scene.addObject("floor",owner)
mesh = floor.meshes[0]  
i = 0
        for v in range(0,16):
                
            x2 = floorX[i]
            y2 = floorY[i]
            z2 = floorZ[i]
            vert = mesh.getVertex(0,v)
            vert.XYZ = [x2,y2,z2]
            i = i + 1 

And this is my result:

As you can see the texture is distorted because it was on the circle bevor I changed the positions of the vertices. I have to add the texture after I’m finish with doing that to get a good result but I don’t know how to do that.

So you turn a circle into a square?

Anyway. The problem you get is that you move the position in 3D space, but you keep the location in UV-space untouched. I think you need to move the UV coordinates too.

Yes in this example its a square but it can be anything and I don’t know it before.

Can you tell me how to do that? I know how to do thet when im not in runtime but is this possible with python?

Woudn’t it be the easiest way to UV unwrap it again? Is this possible with pythone while runtime?

you can change the uv (the first and second set) at KX_VertexProxy

Thanks a lot!