Solved

# Fast Height Adjustment in OpenGL

Posted on 2003-02-26
Medium Priority
343 Views
I am loading a height map into a 64x64 array and stretching it out to 1024x1024 when I draw it in OpenGL.  As I walk around the terrain, I want the height of the camera (my first person view) to stay a steady amount from the height of the terrain.  Cant just check the verticies because it will be jerky and you will end up walking THROUGH the terrain until you are actually over the higher vertex.  So how can I check the height of an imaginary point in between two points without having to use sqrt.

I dont want to do 2 sqrts every time I take a step.  I know theres a way to do this with angles...
0
Question by:lyleworthington
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 2

Accepted Solution

TGGC earned 300 total points
ID: 8034489
There is no fast way to do this by angles, instead of that you have to use linear interpolation. Your mesh consists of a lot triangles, first find the triangle the at the desired position and its three vertexes.

May look like that:

A--------------B
I............/
I..P....../
I......../
I....../
I..../
I../
I/
C

Height of P is (assuming y-axis is height):

Py= Ay + (By-Ay)*((Px - Ax)/(Bx - Ax)) + (Cy-Ay)*((Pz - Az)/(Cz - Az))
0

Author Comment

ID: 8044539
Thats exactly what i was looking for, thanks.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
###### Suggested Courses
Course of the Month8 days, left to enroll