I am using openGL ES. I have loaded a ball, skybox, and a small patch of terrain into the program.
The terrain changes heights at certain points.
The ball rolls around the terrain.
My question is: is there any way I can tell what the height of the terrain is at the position of the ball? (The position of the ball is stored in a variable that can be used). Is there any sort of OpenGL ES command, or even an OpenGL command I can base some research of this into?
OpenGL is a rendering API, it just draws things onto the screen, nothing more. So you won’t get around doing such things like terrain collision detection and the like yourself.
If you got a heightmap for the texture (e.g. you draw a x-z regular grid with the y taken from a heightmap). You can just search for the cell your ball is in (or better the triangle the ball is in of the two triangles) and interpolate the corresponding height values to get the height of the terrain at the ball’s position.