What's wrong with my code?

I’ve tirelessly recreated this piece of code several times without any improvement. The node that the runner ultimately calls for and attaches is nowhere to be seen. Hopefully someone here can point out what I did wrong. I greatly appreciate your help!

[java]package mygame;

import com.jme3.asset.AssetManager;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.BufferUtils;
import java.util.ArrayList;

public class Landmass {

AssetManager assetManager;

double[][] points;
double[] linearPoints;

Mesh landMesh;
Material landMaterial;
Geometry landGeometry;
Node landNode;

Vector3f[] vertices;
int[] indexes;

ArrayList<Integer> indexesList;

public Landmass(AssetManager manager, double[][] array) {
    assetManager = manager;
    
    points = array;
    linearPoints = getLinearArray(array);
    
    landMesh = new Mesh();
    
    /** ** ** **/
    makeVertices();
    makeIndexes();
    
    landMesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
    landMesh.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(indexes));
    landMesh.updateBound();
    
    landMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    landMaterial.setColor("Color", ColorRGBA.Green);
    landMaterial.getAdditionalRenderState().setWireframe(true);
    
    landGeometry = new Geometry("wireframeGeometry", landMesh);
    landGeometry.setMaterial(landMaterial);
    
    landNode = new Node("landNode");
    landNode.attachChild(landGeometry);
}

private void makeVertices() {
    vertices = new Vector3f[points.length * points[0].length];
    
    for (int i = 0; i < points.length; i++) { // i = row = y
        for (int j = 0; j < points[0].length; j++) { // j = col = x
            vertices[points[0].length * i + j] = 
                    new Vector3f((float) j, (float) points[i][j], (float) i);
        }
    }
}

private void makeIndexes() {
    indexesList = new ArrayList<Integer>();
    
    for (int i = 0; i < points.length - 1; i++) { // i = row = y
        for (int j = 0; j < points[0].length - 1; j++) { // j = col = x
            indexesList.add((points.length * i) + j); // top left (0)
            indexesList.add((points.length * (i + 1)) + j); // bottom left
            indexesList.add((points.length * (i + 1)) + (j + 1)); // bottom right
            
            indexesList.add((points.length * i) + j); // top left
            indexesList.add((points.length * (i + 1)) + (j + 1)); // bottom right
            indexesList.add((points.length * i) + (j + 1)); // top right
        }
    }
    
    indexes = new int[indexesList.size()];
    for (int i = 0; i < indexes.length; i++) {
        indexes[i] = indexesList.get(i);
    }
}

public static double[] getLinearArray(double[][] array) {
    double[] newArray = new double[array.length * array[0].length];
    
    for (int i = 0; i < array.length; i++) {  // i = row = y
        for (int j = 0; j < array[0].length; j++) {  // j = col = x
            newArray[array[0].length * i + j] = array[i][j];
        }
    }
    
    return newArray;
}

public Node getNode() {
    return landNode;
}

}[/java]

Could be line 44. Look at how Quad sets up its index:
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/scene/shape/Quad.java#119

Also, for what it’s worth, your code always assumes that the width and height of the source data is the same. So if they aren’t the same then you will get strange results.

One way to narrow down the problem would be to replace your mesh with something like Box which is known to work. So if using a Box in line 51’s Geometry instead of your landMesh makes something appear then you know it’s your mesh. Otherwise you can look into your scene setup.

Thanks a ton! I fixed it.