Using a model mesh as a 3d function

I’m programming my first 3D stuff with Panda, and to make things easier I decided to have all movement done in 2D(so, no jumping, floating, burrowing or anything alike) and the units would go up and down with the terrain. The terrain itself is a big modeled mesh, so what I want to know is: is there a way to use a loaded mesh as a 3D function? Like, given (X,Y) coordinates, to get the corresponding Z value automatically?

Using the usual collision detection ought to work ok for that - extend a collision ray down from the player or other moving things, which will give you an intersection point on the terrain mesh.