How do I transform a Spatial in a Terrain?

Hello guys, i’m with a problem here that i think it’s a noob question, but nevermind. I created a landscape with the j3o format. That means, it needs to be loaded into s Spatial. Ok, no problem. The real problem is that i want to use TerrainLodControl to maximise performance. The problem is that it only accepts a Terrain in the construtor. I tried to cast Terrain on the Spatial, and use the method setSpatial() of the control. Nothing. It always returns an exception. So, can somebody help me please? Thanks!

When posting about an exception… and the exception is not included with the stack trace… might as well not even mention it because it’s only as useful as having not mentioned it at all. :wink:

oh, sorry. Here there is:

I made a mistake. When i use the setSpatial() method the app doesn’t crashes, but it doesn’t seem to work.

When i cast Terrain to Spatial, it just says that i can’t:

Set 15, 2014 9:17:13 PM handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.ClassCastException: com.jme3.scene.Node cannot be cast to com.jme3.terrain.Terrain
at mygame.Main.simpleInitApp(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(

Here you have.

PS: Mythruna is becoming a fantastic game! Keep the good job!


The scene is not a Terrain. The Terrain must be children of that node but I think it should already have LOD controls. I’m not sure as I’ve never used it.

Well, i can see that the LOD controls ins’t implemented and/or working. I already used LOD in a example and when i get further away i can see the loss of detail. I really need it because my landscape is big, and with more than 1000000 vertices being rendered, the computer becomes slow. But thanks for your help pspeed!

What software did you create the terrain in? You need to be able to export it into a heightmap as opposed to a model file.

How large is your terrain? and what view distance do you need?

Cause if you plan for stuff like 20km view distance, the normal terrain system cannot be used directly, as it is not really designed for that.

Hey guys, i figured out what has going on! The TerrainLodControl needed the camera of the SimpleApplication. I discovered that the terrain (that i created using the SDK) had already the TerrainLodControl.class. Then i tried to give the camera to the control, and it worked! Finally! But thanks for everbody thet helped me!

PS: Im not english, so it may have errors in the text.