0
\$\begingroup\$

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.

Thanks

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Depending on where you want to go with this, you could rely on a physics engine to do those calculations. The physics engine controls the world in a realistic way, and your own graphics engine displays it. \$\endgroup\$ Commented Jul 1, 2022 at 13:43
  • \$\begingroup\$ I must use just vulkan, for a university project. I was thinking to use height maps, but they doesn't seem too precise \$\endgroup\$ Commented Jul 3, 2022 at 8:38
  • \$\begingroup\$ I suggest you edit the question and tell us a bit more about what you have so far (including if it's 2d or 3d), that would help us help you. \$\endgroup\$ Commented Jul 3, 2022 at 12:53
  • \$\begingroup\$ Ok, I have update the quastion with how I am proceeding, if you can help it would be great \$\endgroup\$ Commented Jul 3, 2022 at 16:01
  • \$\begingroup\$ Do you have a mesh for your terrain? How do you currently move your car? \$\endgroup\$ Commented Jul 3, 2022 at 16:38

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.