Manipulating a mesh in a game

Hi,
I want to be able to manipulate an object in the game, and I’m not sure to what extent it would be possible. E.g I want to cut an object with a knife.

Any ideas on how to accomplish this?

Thanks

Blenders game engine is very limited in editing meshes in real time. So i dont think it would be posible if you want to create an exe it wount work, but if you runn it inside blender , you got a chance…

use the blender module in python to make it. I have not aidea how to do it. i just know that the blender module is not included in a runtime

It is possible to control position and shape of every single face of mesh using Python methods, but it has large impact on performance if it is widely used. I have created interactive 3d graph using this method, but manupulating ~1000 vertices every frame resulted in unacceptable performance.

Another option is to prepare “cutted” mesh and replace original mesh in moment of cut.

Ashsid said:

It is possible to control position and shape of every single face of mesh using Python methods, but it has large impact on performance if it is widely used. I have created interactive 3d graph using this method, but manupulating ~1000 vertices every frame resulted in unacceptable performance.

Sounds interesting, any chance to get hands on an example blend ?
As i am presently tinkering with the Irrlicht engine…Maybe in C++…

Sounds interesting, any chance to get hands on an example blend ?
As i am presently tinkering with the Irrlicht engine…Maybe in C++…

Sorry, I don’t have right to publish .blend files from that project, but I can give an example how to place first vertex of the first face and the first material on local coordinates [1,2,3]:

obj = GameLogic.getCurrentController().getOwner()
mesh = obj.getMesh()
vert = mesh.getVertex(0, 0)
vert.setXYZ(1, 2, 3)

On Irrlicht engine: I haven’t worked with it but I think examples from Blender aren’t usable in it without total rewriting.

mmm, I’m aware of replacing the mesh with a “cutted” mesh, but I’m trying to simulate a cut so I need more accuracy. The python script sounds like the answer to me. Is there maybe a link that handles this particular application of python for the GE? My python isn’t up to scratch yet, so I’ll appreciate any help.

Thanks again

Download file Cut.blend, it contains example of cutting sphere using mouse cursor. Just load cut.blend into Blender, strat game and use mouse (with LMB pressed) to cut sphere into pieces.

This example is limited and has some restrictions:

  1. Cutted object can contain only triangles.
  2. Cutted object can’t have shared vertices among faces (no SetSmooth).
  3. Cutting is very simplified, resulting in object breakdown.

You can use it as an inspiration and base for improvements.

Thanks, I appreciate the help :wink: