I am writing a small "game" in vulkan, in which a car can move in an environment that is not flat, like a desert with valleys.
I am able to translate my car and follow it with the camera on a flat horizontal plane, however I can't figure out how can I understand if there is a downhill or an uphill and rotate my car consequently.
I was thinking to create a sort of matrix in which for each point I have the eight in thet point and so I can add an offset to the car, and rotate it approximating a plan with the neares points, but I have an obj file, and I don't know how I can proceed.
EDIT: I am developing a 3d app, in which the car moves in a terrain like the one I link here: https://3dmdb.com/en/3d-model/cycles-mountain-shader-vol-1/1031398/?free=True&q=mountains+displacement
I have created a displacement map with blender of the terrain, in this way I can understand how height I am with respect to the zero, while moving on the map.
I read the corresponding pixel of the height map, which changes from 0 to 255, and I retrieve if I am "high" or "low".
I would like to know if my idea is correct and, moreover, how can I increase the precision; in fact even with the height map I can't be precise, since let's say the value 125 doesn't mean that I'm exacly at half of the total height, for may experiance trying this option, at least.