destructable environments in the bge

You can add faces to a mesh with shape keys.Could that be used to make a marching cubes type game?Is that illegal to do?

How can you add faces with shape keys?

Like this.
http://www.pasteall.org/blend/32948
You see i keyed the relative value to add the face.And then used a always sensor connected to a and controller.which is connected to a action actuator.I used that to play the shape key animation.

This is not really an added face. This is an existing face. It was just hidden as it had no size. You can get the same effect with armature animation or by manipulating the mesh via Python.

The problem is the face needs to exist already, you can’t dynamically add new faces with this method. If so you would need to define the UV and materials too.

It is a nice method anyway. You could “predefine” some basic elements that can be “unfolded” while running the game. To get more faces, you add more objects.
As more objects will slow down the game, you could replace existing meshes with meshes that have an higher number of “un-foldable” faces. Unfortunately it needs much effort.

Back to topic. I do not know what marching cubes is … checking wikipedia … ok now I know.

You should be able to implement the visualization of volume models with cut cubes. To me it looks like as there is a max of 4 faces per cube. A mesh with 4 faces should be fine.

According to wikipedia the patent on the algorithm expired 2005.

How would you tranfer the marching cubes algorithm to python?

It is an algorithm. This means there is a way to implement it in any programming language. I can’t tell you how to do that. I’m not into this topic. I assumed you already knew about the algorithm, but you did not know how to create the resulting faces in the BGE.

As far as I see it, the algorithm results in 0 to 4 triangles per volume cube. So you can use your idea to form these faces.

When i make it a static object you cannot stand on certain areas.

You can also use Blender to create the new mesh data and load it at runtime using libload, which is the technique that I used for mesh slicing.

I am not going to be able to use marching cubes algorithm right now.I have to get back to learning how to program in the bge.The demos were great though.