# Edit object in BGE

Can I edit an object mesh in BGE using python? it seems its possible using GLSL shaders; but i've no idea about that.

Please guide me or give me a example using GLSL.

thanks.

• It seems, the bmesh module is not accessible in BGE.

If you're certain you want to use GLSL, know that it doesn't read like other programming languages.

It's more like the programming language R, in that you can give it data, and it just does specified transformations for you; without what you would normally expect to be in a loop.

If I were to attempt it, I'd start with something easier, like Love2D
https://love2d.org/forums/viewtopic.php?f=4&t=32605

Then, once you have an understanding of how to write a GLSL shader,
export an InterQuakeModel from Blender, and use it with Love3D
https://github.com/excessive/love3d
https://github.com/excessive/love3d-demos

That just seems like an easy playground to 'tink around with 'em.
After you know what you're doing, then put those GLSL scripts in BGE.
https://en.wikibooks.org/wiki/GLSL_Programming/Blender

• thanks for your complete answer. i just want to cut a sphere in BGE. and after some research realized that using geometry shaders will work; but that creates some kind of artifact and dont affects to physic engine. – Fadavi Dec 26 '17 at 17:13

GLSL isn't easy, especially if you have no idea about it.
It would be far easier to use Python to edit a mesh in Blender.

• thanks again. bmesh module is usable/accessible is BGE? – Fadavi Dec 26 '17 at 17:15
• BGE allows python scripts. You just have to import bmesh at the beginning of your script, like any other module you use. – Doyousketch2 Dec 26 '17 at 17:47
• I know, but bmesh cannot handle BGE objects, and only support bpy objects (not sure, is it true?); If its possible, please give me code sample about using bmesh and bge together. thanks a lot. :) – Fadavi Dec 26 '17 at 18:26
• Oh that could be. I may have read that half-a-doz years ago when bmesh was new. I assumed they could by now. I know bmesh makes a copy of the data, then you have to push back any changes to the original model. If they don't allow that in the BGE, then I'd pre-make a few variations of your model, then flip between 'em as needed. – Doyousketch2 Dec 26 '17 at 19:42