?
Solved

Fast Height Adjustment in OpenGL

Posted on 2003-02-26
2
Medium Priority
?
343 Views
Last Modified: 2013-12-26
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
Comment
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
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
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

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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question