TerrainPage.getHeight() not working, at least the way I want it to :-P

Alright, well I'll start out with what I'm TRYING to do ;-P…

I am trying to load trees into my game. I have a TerrainPage all set up and lovely using a MidPointHeightMap.

MidPointHeightMap height_map = new MidPointHeightMap(64 * numPlayers, 1f);
        TerrainPage tp = new TerrainPage("terrain", 33, height_map.getSize() + 1, new Vector3f(8f, .5f, 8f), height_map.getHeightMap());

It is showing up and looks nice, so I don't expect it's a TerrainPage issue.

I am loading trees into the game in clusters of 10. There is a "main" tree that all the others are placed around. Most of the trees are placed perfectly in line with whatever the height of the terrain is, but some are partially, mostly, or almost completely underground.

This is the code for placing my trees:

//terrSize is tp.getSize() * 4, that way I can get the trees to cover the whole terrain
//loc is a Vector3f
//adj is another Vector3f
for(int i = 0; i < T_CLUSTERS; i++) {
            xPos = numGen.nextInt(terrSize) - tp.getSize() * 2;
            zPos = numGen.nextInt(terrSize) - tp.getSize() * 2;
            loc.set(xPos, 0, zPos);
            models[currTree].setLocalTranslation(xPos, tp.getHeight(loc), zPos);
            System.out.println("DEBUG: Tree Pos " + models[currTree].getLocalTranslation());

            for(int j = 0; j < T_CLUSTER_SIZE; j++) {
                while(true) {
                    adj.set((numGen.nextInt(50) - 25f), 0,(numGen.nextInt(50) - 25f));
                    if(Math.abs(xPos + adj.getX()) < terrSize / 2 && Math.abs(zPos + adj.getZ()) <
                            terrSize / 2)
                models[currTree].setLocalTranslation(xPos + adj.getX(), tp.getHeight(adj),
                        zPos + adj.getZ());

Ironically, the trees don't actually cover the whole terrain, which is another problem, but let's focus on one thing at a time.

Can anyone see anything blaringly obvious that I missed?

Thank you,

I'm new here and don't have much experience with TerrainPage, but I thought I'd mention that the javadoc says

getHeight returns the height of an arbitrary point on the terrain.


getHeightFromWorld returns the height of an arbitrary point on the terrain when given world coordinates.

something to try…