I am trying to generate a bunch of plant models at random spots on the surface of the terrain but terrainQuad.getHeight(); isn’t returning the correct value; at least it’s not returning the value that my character’s local translation is returning.
This is what it looks like: https://puu.sh/BFfQP/d7df917089.png
What’s especially vexing to me is that the difference between the models local translation.y and the terrainquad.getHeight isn’t constant.
Ok so, you are definitely correct that I should be using getHeightmapHeight(). I just created another Scene and Terrain within it using one of the JME random hill terrain generators and now everything is working properly…unfortunately I don’t want to just give up the Scene i’ve been working on for a while. Any idea what properties of a Terrain would cause it to behave like that?
I altered the mesh of the “Original” Terrain that was having heightmap problems using the JME3 Terrain Editor.
Hmm I’m not entirely certain, but did you alter the mesh by using the terrainQuad.setHeight(Vector2f coord, float height); method, or by altering the mesh’s vertex buffer. I think altering the vertex buffer could cause the problem, since that would not alter the height map data being stored in the TerrainQuad class, only the mesh.
Edit: my bad, I just saw you did mention that you altered the terrain using the terrain editor. I’m not quite sure what could have been the cause then, I use the terrain editor a lot as well but haven’t noticed that problem. Did you possibly scale the terrain when it was having issues? I think one of the javadocs mentioned that the getHeight() methods don’t take scaling into account.
Another potential factor could be if your’e attaching more than one LOD control - the terrain editor will create an LOD control for you by default when you make a new Terrain, and then I’ve also had times where I accidentaly added a second LOD Control at run-time and I got some weird results.
Also, as a final note to anyone looking at this in the future, if you use TerrainQuad.getHeight(), it properly takes into account both Scene scaling as well as Terrain scaling! TerrainQuad.getHeightmapHeight() does not.