I have made a terrain using the terrain editor and it shows up in my project assets as a .j3o file. When I try to use it, it will not appear in my simple game and the triangle count in the stats show that it is not loading. In the tutorials, I am told that I must use a heightmap and code all the textures and lights, but in the documentation I am told I can add lights and textures in the scene editor. Because of this, I am not sure why there is a terrain editor, since it creates an object and not a height map and the tutorials state that I should be using a heightmap image and doing everything by writing lines of code. Can anyone help me understand what is going on? I can post my test program if you like.
Thanks,
Matt
The terrain editor is doing everything that the code in the examples do. It saves a complete terrain, incl. heightmap and texture info. Then you can load it like any model into your game, without having to set up anything in-code.
Normen is correct, the editor makes you a model that you load into your game. The terrain is part of the whole scene. You don’t have to do anything else regarding heightmaps or alpha maps.
Thanks, that helps! Now I just have to figure out why it isn’t showing up.
As far as I can tell my code is fine, would it be ok if I posted it here to see if someone can spot what I am doing wrong?
Thanks again!
No light?
sure you can post it here
I added a light to the root node, in the scene editor, do I need to add another? Also, the stats only show about 400 triangles, so I don’t think that is it. Here is my code:
package mygame;
//basic stuff
import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
private Spatial scene_model;
@Override
public void simpleInitApp() {
scene_model = assetManager.loadModel("Scenes/TerrainTest.j3o");
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
You don’t attach the model to the rootNode…
You haven’t attached your scene to the root node yet.
damn, normen is beating me by mere seconds!
Doh! I thought:
scene_model = assetManager.loadModel(“Scenes/TerrainTest.j3o”);
did that for me, my bad.
Thanks again for all the help!
Oops, one more question: if I add a rigid body controller in the scene editor I don’t have to add another one via code, right?
No, but you have to add it to the physics space, you can do physicsSpace.addAll((Node)loadedModel);
Excellent! Thanks again.