I'm extending the terrain quad with resources from various tutorials and have the following code:

public class WorldTerrain extends TerrainQuad {

    public static final String NAME = "terrain";
    public static final int PATCH_SIZE = 9;
    public static final int TOTAL_SIZE = 33;
    private static Vector3f spawnLocation = new Vector3f(13, 3, 16);
    private Material mat_terrain;

    private void loadText(AssetManager assetManager) {
         * 1. Create terrain material and load four textures into it.
        mat_terrain = new Material(assetManager,

         * 1.1) Add ALPHA map (for red-blue-green coded splat textures)
        mat_terrain.setTexture("Alpha", assetManager.loadTexture(

         * 1.2) Add GRASS texture into the red layer (Tex1).
        Texture grass = assetManager.loadTexture(
        mat_terrain.setTexture("Tex1", grass);
        mat_terrain.setFloat("Tex1Scale", 64f);

         * 1.3) Add DIRT texture into the green layer (Tex2)
        Texture dirt = assetManager.loadTexture(
        mat_terrain.setTexture("Tex2", dirt);
        mat_terrain.setFloat("Tex2Scale", 32f);

         * 1.4) Add ROAD texture into the blue layer (Tex3)
        Texture rock = assetManager.loadTexture(
        mat_terrain.setTexture("Tex3", rock);
        mat_terrain.setFloat("Tex3Scale", 128f);

    private static float[] generateHeightMap(AssetManager assetManager) {
        AbstractHeightMap heightmap = null;
        try {
            heightmap = new HillHeightMap(1024, 100, 2, 10, 1);
        } catch (Exception ex) {
            Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
        return heightmap.getHeightMap();

    public static Vector3f getSpawnLocation() {
        return spawnLocation;

    public WorldTerrain(Interface app) {
        super(NAME, PATCH_SIZE, TOTAL_SIZE, generateHeightMap(app.getAssetManager()));

        setModelBound(new BoundingBox());
        setLocalTranslation(32f, 0f, 32f);

        List<Camera> cameras = new ArrayList<Camera>();

        RigidBodyControl landscape = new RigidBodyControl(0.0f);

and the interface:

public class Interface extends SimpleApplication {

  private TerrainQuad terrain;
  Material mat_terrain;

  public static void main(String[] args) {
    Interface app = new Interface();

  public void simpleInitApp() {

    terrain = new WorldTerrain(this);

This gives the following result: holes in terrain as you can see large parts of the terrain are not rendering (ignore the weird mountains those are only tests). If I move the camera around these holes move around suggesting it's a rendering problem in the terrain. Anybody who knows how to fix?

  • \$\begingroup\$ "these holes move around" ... Perhaps you can make a better indication of what are you referring to. Right now it is like totally unclear. \$\endgroup\$
    – Kromster
    Jul 31 '14 at 4:28
  • \$\begingroup\$ If I move the camera these black squares move (look at the side closest to the camera in the picture) around as well. (note that the terrain should obviously be a square greenish square). \$\endgroup\$
    – Thijser
    Jul 31 '14 at 6:04

Trying changing

setModelBound(new BoundingBox());


BoundingSphere bs = new BoundingSphere();
bs.setCenter(new Vector3f(32,0,32));

Edit Larethian (short Version) (confirmed working on example code):

setModelBound( new BoundingSphere(1000000, new Vector3f(32f, 0f, 32f)) );

As pointed out in the comments below a bounding volume with this large of a radius shouldn't really be used...although the fact that it is working gives you an idea of what the original problem was. If you wish to use bounding spheres realistically what you can do is try setting the radius to be "PATCH_SIZE".

  • 2
    \$\begingroup\$ If the problem is incorrect or optimistic bounding volumes, consider mentioning this and outlining a correct approach to estimating reasonable pessimistic bounding volumes. Making a bounding sphere with radius 1000000 seems like a filthy hack that effectively disables culling all together, due to the huge size. \$\endgroup\$ Aug 3 '14 at 0:25

Maybe they are being culled for being partly outside the view area? Might be worth looking at the code selecting what you render instead of the terrain code.

(Or setting near and far plane differently and/or moving the camera further away since it seems the engine is not a custom solution)

  • \$\begingroup\$ This is actually all the code I have right now, the rest is inside the jmonkey engine \$\endgroup\$
    – Thijser
    Jul 31 '14 at 10:53
  • \$\begingroup\$ Would definitely try experimenting with the camera then. Normals do not change randomly and you say the polys not rendered vary, so probably they are culled falsely. \$\endgroup\$
    – Tecuani
    Jul 31 '14 at 10:57
  • \$\begingroup\$ Is this a bug in the engine then? I use the default camera and a direct extension of the terrain object (again all code is in the question) \$\endgroup\$
    – Thijser
    Jul 31 '14 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.