Implementing TerrainGrid

Greetings and Salutations

I have just run through most of the basic tutorials for jME and have been playing around with the Terrain Editor. Please assume that I have limited knowledge of actual programming.

I’ve been looking for a way to make procedurally generated terrain for a java-based game for a while now. Obviously Minecraft is a prime example of this, but I want more realistic terrain. TerrainGrid looks just about perfect for my needs but I ma having some trouble getting it to work. I can’t find the library/package it is contained in and I can’t get any of the examples to run either.

Help?

Thanks in advance.

TerrainGrid still working for me despite its age, odd that you’re having issues.
Although the SDK is in flux at the current time as the Devs concentrate on the impending stable release and we are behind on updates as a result. Be patient and try this:
Use the SDK to create the jME test suite, although there are errors within due to the above statement there are many modules that will work fine on their own, so navigate through the examples to the Terrain section and find the .java files within and the ones relating to terrainGrid such as TerrainGridTest.java, Then Select the file and right-click-"Run File"or open it and Shift-F6 to run just that file, it should get you started.
Give that a go and see if it works or relay the errors back here if you cannot get it working.
Cheers.

PS: Almost forgot, the http zip locator class is also broken at the moment so you’ll need to download the TerrainGridTestData.zip file manually using the link in the code and place it in the base project directory for the jME test projects.

Okay I have found the TerrainGrid files and I can run most of them, but when I run TerrainGridTest.java I just get a blank blue screen which I assume is the skybox and this comes up in the output box at the bottom.

INFO: Loading heightmap from file: Scenes/TerrainMountains/terrain_-1_-1.png
Aug 05, 2013 3:58:01 PM com.jme3.renderer.lwjgl.LwjglRenderer updateUniformLocation
INFO: Uniform m_VertexColor is not declared in shader [ShaderSource[name=Common/MatDefs/Misc/Unshaded.vert, defines, type=Vertex, language=GLSL100], ShaderSource[name=Common/MatDefs/Misc/Unshaded.frag, defines, type=Fragment, language=GLSL100]].
com.jme3.asset.AssetLoadException: The given image cannot be loaded Scenes/TerrainMountains/terrain_-1_-1.png (Flipped)

Oookay… my test code here does no use any Unshaded material… not sure where you’re getting that from, but then it’s only an info warning.
As for the missing tile it sounds like the TerrainGridTestData.zip file is not in the correct location. It should be in the ./JmeTests directory.

I can’t find a link to download the missing .zip, is there still a working download?

You are quite helpful :slight_smile:

Use the link in the java file, works for me: http://jmonkeyengine.googlecode.com/files/TerrainGridTestData.zip

Ah, I it works now. It doesn’t seem to be generating infinitely though.

Glad it worked.
That particular terrainGrid test isn’t infinite no, just the image tiles inside the zip file.
For true infinite worlds look at the TerrainFractalGridTest.java test.

Basically for infinite terrains you’ll need the fractal generation code of some kind to generate the heightmaps. This isn’t something I’ve gone into yet as I’ve been concentrating on fixed tile-based terrains for my projects. So have a play of the fractal tests and experiment with that.

Cheers

Here we go again, same topic different problem.

I’ve been working on implementing collision, which works fine for 3D objects and heightmapped terrain, but I can’t get it to work with TerrainGrid Fractals.
Every time I try to run my code I get this error.

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at mygame.Main.simpleInitApp(Main.java:82)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:724)

Thanks in advance.

On your line of code: mygame.Main.simpleInitApp(Main.java:82)
…something is null.

Since you are the only one who can see the code then you are probably best equipped to look into it.

Okay, I found the NullPointerException, fixed it and it runs properly now but the terrain doesn’t detect collision. I’ll play with it some more and see what I can come up with.

Any help is welcome.