New to JME, design feedback and discussion

Hi, so I am new to JME, and game development on a non voxel related basis.

Anyways, using JME’s terrain editor I plan on creating a very large map. I also planned on doing it by using 512x512 sections that are loaded and unloaded on demand as the player nears them.

Is this a sound logic for doing this? or does anyone have a better way?

Currently trying something similar, was going away from jme terrain editor tho because it can be tiresome sometimes.
Trying out to create the blocks in blender and trying to figure out a way to loaf them on demand then.
The biggest problem so far for me is fiting the edges and especialy the textures together so you don’t see the seams.

If you find a good way i would be happy to hear about it.
Also about loading the blocks when they are needed. Tried to rewrite the terraingrid for this but haveing my difficulties with it.

Concerning the size of your blocks it depends on how much details you want to add to the landscape. If you put a lot of fauna ir other object like buildings on it it might be better to use smaler chunks.

<cite>@ryukajiya said:</cite> Currently trying something similar, was going away from jme terrain editor tho because it can be tiresome sometimes. Trying out to create the blocks in blender and trying to figure out a way to loaf them on demand then. The biggest problem so far for me is fiting the edges and especialy the textures together so you don't see the seams.

If you find a good way i would be happy to hear about it.
Also about loading the blocks when they are needed. Tried to rewrite the terraingrid for this but haveing my difficulties with it.

Concerning the size of your blocks it depends on how much details you want to add to the landscape. If you put a lot of fauna ir other object like buildings on it it might be better to use smaler chunks.


I have been dabbling with the TerrainEditor but it seems to be a little buggy at times, but this is a work in progress feature so thats okay. Getting the eges to line up properly in different terrain chunks with that is a bit of a hassle. I have been thinking about using float arrays and making a little gui editor to easily view the data and edit it. but at the same time this would be hard for me to visually represent wihtout loading the float arrays in the game as I have little experience with JME at this point.

If any of the veterans have any tips I’d much appreciate it.

If you are using terraineditor anyways and save the scenes as jo3 files it is very easy to create a little test class that just implements SimpleApplication and loads those chunks for you to see in a scene together.
Something like this is enough to let you see two created jo3 terrains (just have to give right name to assetManager and move according to your chunk size):
[java]
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

public class TerrainSceneTest extends SimpleApplication {

public static void main(String[] args) {
    TerrainSceneTest App = new TerrainSceneTest();
    App.start();
}

@Override
public void simpleInitApp() {
    Node ter = (Node) assetManager.loadModel("Zones/Tile1.j3o");
    Node ter2 = (Node) assetManager.loadModel("Zones/Tile2.j3o");
    rootNode.attachChild(ter);
    ter2.move(256, 0, 0);
    rootNode.attachChild(ter2);

    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);
}

}
[/java]

This might be helpful (note that it’s a work in progress):
http://hub.jmonkeyengine.org/forum/topic/generic-paging-system-for-jme/

<cite>@ryukajiya said:</cite> If you are using terraineditor anyways and save the scenes as jo3 files it is very easy to create a little test class that just implements SimpleApplication and loads those chunks for you to see in a scene together. Something like this is enough to let you see two created jo3 terrains (just have to give right name to assetManager and move according to your chunk size): [java] import com.jme3.app.SimpleApplication; import com.jme3.light.DirectionalLight; import com.jme3.math.Vector3f; import com.jme3.scene.Node;

public class TerrainSceneTest extends SimpleApplication {

public static void main(String[] args) {
    TerrainSceneTest App = new TerrainSceneTest();
    App.start();
}

@Override
public void simpleInitApp() {
    Node ter = (Node) assetManager.loadModel("Zones/Tile1.j3o");
    Node ter2 = (Node) assetManager.loadModel("Zones/Tile2.j3o");
    rootNode.attachChild(ter);
    ter2.move(256, 0, 0);
    rootNode.attachChild(ter2);

    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);
}

}
[/java]


Yes this is basically what I am trying to do, I can do this no problem, its an easy task. The thing that I am having trouble with at this point is using the terrain editor to get morph the terrain to how I want it AND have the terrain heights flow evenly between the chunk of terrain next to it.

This is why I was thinking of making a simple aplication that would be a gui for editing float values for say a 512x512 chunk of terrain, this would be saved to a file then loaded by the game into a float array to generate a heightmap. Pair this with an alphablend png and custom Materials to load textures onto them and it should be much easier to have the terrain flow evenly in between chunks of terrain.

The Pro’s of this:

  • evenly flowing terrain heights between chunks
  • very easy to customize the terrain heights
  • simplicity

The Con’s of this:

  • Tri-planar (I believe that is the word I want) texturing may be more difficult, though I haven’t looked into this at all yet (by Tri-Planar I mean texturing steep hills so that the texture isn’t stretched out)
  • The only way to test how this would look in reality would to load them into the game, though simple and can be done its not as awesome as it could be.
  • editing all those float values may be time consuming, though I could make tools to increase/decrease multiple fields simulaneously with a desired increment.

Any thoughts on this?

EDIT: on second thought something similar could be achieved by making a “game” that was just for map editing then the heightmap was stored to a file for loading later, unfortunately I don’t know about editing textures and storing with an alpha blend png. I’ve never done anything of that sort before, though I am sure it is doable.

If you want to use heightmaps anyways it would be even easier to use something like blender to design you whole level.
There are several modifiers (like subsurface) that give you real nice landscape with relatively low poly count so it is still editable in blender on a large scale.
Once you are satisfied with your landscape create a large heightmap from it (lets say 4096x4096) wich offers a lot of detail (might even create a high detail landscape and bake a displacement/UV map from it). Then divide that heightmap into smaller chunks (maybe 256x256) and load those with terrainquads created from these heightmap chunks.

You just have to make sure the edges are fine then, so make the cut so that the last pixel of the first chunk is also the first image of the next chunk. (actualy i think you need a different size for your complete heightmap then depending on how many chunks you create to compensate the conversion, because you “loose” one pixel per edge that has a neighbour).

If the edges of a heightmap are at the same height there will be no seams and the chunks will fit together nicely.

There are a ton of tutorials that show you how to create good landscapes in blender relatively fast, also plenty tutorials on how to make heightmaps (i posted two links in another thread yesterday i think) and displacement/uv/normal maps from that if needed. Texturing those is another thing, from my experiances so far this should be done in jm3 then because the textures you paint on it in blender look different then those loaded in the scene then.

Wel if you go for a own system i did this with quite some success

and how it looks ingame
http://hub.jmonkeyengine.org/forum/topic/new-horizons/page/4/#post-115009

Terrain size with this approach is graficcard limited mostly, as the full heightmap must be available in the graficcard at all times.

If you do get visible seems in terrain (due to rounding errors you can get one pixel gaps even though they are supposedly identical) a small vertical “skirt” around the edge of each chunk is supposed to be quite effective at getting rid of them.

<cite>@Empire Phoenix said:</cite> Wel if you go for a own system i did this with quite some success

and how it looks ingame
http://hub.jmonkeyengine.org/forum/topic/new-horizons/page/4/#post-115009

Terrain size with this approach is graficcard limited mostly, as the full heightmap must be available in the graficcard at all times.

Have you released the code for that somewhere or was it just a little private project ?
Also i wonder if the GPU is doing most of the work and basicaly the terrain just exists in GPU memory how would you check collisions or implement physics ?
As fas as i understand bullet would need an actual body as a reference and this technique creates the terrain by displacig the pixcels of plane triangles shaped planes? (or maybe i didn’t understand it fully :wink: )

Well i create a normal meshcollisionshape for bullet (actually several 256x256 ones)
As only the rendering is the problem with really large terrains this works surprisingly well.

25kmx25km with 1 meter resolution and 16bit height are possible without problems on current computers.

I was planning on sometime releasing that code, but it needs quite some work prior (As it only accepts .r16 from l3dt for the moment)