Realtime modify-able terrain - Questions

Hello. I’m new to JME and I have few questions.

I know Java well, I guess and I have very little experiance with 3D programming (know basics).

My first goal in 3D, that I pointed to myself is real-time modify-able mesh (terrain, rock or other objects). For example a bomb that makes a big hole in ground after explosion. I was searching for this on many forums but couldn’t find any helpful tips.

I have read this but it isn’t satisfying me, because it only modifies terrain up and down. I need to be able to able to create caves too.

This is exacly what I want to create.

Is it possible to create this in JME, or I have to start from OpenGL learning?
Do you have a code or samples to effect like this?
Also if you could tell me what should I look for on web (any tags?) I would be grateful.


TerraMonkey doesn’t support caves yet. But it might in the medium-term, there is some interest in it.

To implement them you do not need to learn openGL, just jme3 :slight_smile:

Right now terrain is basically a heightfield: a grid of points each representing height at that position. This allows for very fast intersection/collision. To allow for caves, a particular section of terrain would have to become a non-heightfield mesh, but a regular mesh instead. Which is possible, but there are significant performance hits.

Texturing would also have to change, you would have to use the procedural material for TerrainGrid called HeightBasedTerrain.j3md. But that is easy and already done.

One option I am thinking about implementing is a way to transform the selected TerrainPatch into a mesh (a TerrainPatch is the smallest subset of terrain that builds up the entire terrain). Then allow editing that mesh as you would in that video. There are many details to that implementation, but it should be feasible.

Thanks, your answer pushed me forward.

Do I need to study any algorithms like marching cubes, because for now it’s kind of black magic for me?

How physics would work after terrain modify? I mean, if I have a ball that lies inside a hole, and I would make that hole deeper. The ball would detect it and fall down?


It shouldn’t be black magic for you, you are supposed to develop the game, copy&pasting “black magic” into a project will definitely not give you any joy while developing and not a good game :wink: I suggest you consider this your hobby now if you really want to get somewhere properly, otherwise level editors for FPS games are probably a better bet for some fun. About your question, you would have to modify the physics collision shape in realtime as well since continuous automatic updating as a feature enabled by default would probably be too much of a cpu strain if you don’t need it.