Collision with terrain generated by GeoMipTerrain

How can I find the Z coordinate of intersection point between geometry, generated by GeoMipTerrain and vertical line at point {X,Y}? getElevation() method isn’t satisfying me, because it gets a value not from geometry.

This is a code, which generates geometry:

terrain = GeoMipTerrain("Terrain")
terrainNodePath = terrain.getRoot()
tex = loader.loadTexture("data/Terrain_c.bmp")

The same as you would do if you configure picking on any other model. Just setCollideMask(something) on the terrain root sets the collide mask, and set up a ray like you would do in any other case.
I really advise against it, use getElevation instead, which is 100x faster, if not more, especially on huge terrains you will run into lags. What are the problems you are having using this?

You are right - collision checking is not efficient in this case.
The problem was following:
GeoMipTerrain generates “stairs-like” terrain(513x513 heightfield). I solve this problem by the code “terrain.setMinLevel(3)”, but the getElevation() method still returns “stairs-like” values, so character changes the height too sharply. This problem I was solved only today:

power = 16
sum = 0
number = 0
step = 0.1
for i in range(-power,power):
    for j in range(-power,power):
         sum += terrain.getElevation(x+i*step, y+j*step)
         number +=1
average_z = sum/number

Thank you for your help :slight_smile: