|
-
Nov 17th, 2000, 03:49 PM
#1
Thread Starter
New Member
Using OpenGL, I've made a function to construct a terrain from a grayscale picture. Does anyone have a nice small efficient formula to calculate the height of the terrain in any given point-even between vertexes of the terrain
Here's a very crude diagram:
I hope it formats correctly...
+----+----+----+----+----+
| | | | | |
+----+----+----+----+----+
| | | | | |
+----+----+----+----+----+
| | | A | | |
+----+----+----+----+----+
| | | | | |
+----+----+----+----+----+
Each + is a vertex of the terrain with a different height.
Suppose someone is standing at point A - how do you calculate how high the character is?
Thanks,
pollier
-
Nov 17th, 2000, 04:11 PM
#2
Hyperactive Member
can't you just store the character's y co-ord?
buzzwords are the language of fools
-
Nov 17th, 2000, 06:40 PM
#3
PowerPoster
If you know the position you could check the color of your map to calculate the y-pos...
-
Nov 17th, 2000, 07:14 PM
#4
Monday Morning Lunatic
How about averaging the four outer points?
Code:
A-------D
| |
| P |
| |
B-------C
P = (A + B + C + D) / 4
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 19th, 2000, 02:39 PM
#5
Thread Starter
New Member
Not what I meant...
Thanks for the ideas. You were close, but not enough...
+--------+
|..a......|
|..........|
|.....b...|
+--------+
(Each + is a vertex point, or a pixel of my bitmap of the terrain)
All the + have different heights. Therefore, point a is going to be at a different height than point b. How can I calculate this?
Also, can someone tell me how to put formatted text on this forum?
-
Nov 19th, 2000, 04:58 PM
#6
transcendental analytic
It would be a lot easier with hexagonal tiles, since then you have flat tiles and not any complicated formula you use. Of course you could divide the tile into two and use three vertexes.
Anyway you could calculate the average using the distance as the mass parameter as you do when you calculate central mass point.
Code:
_
\
/_ h * (Dx^2+Dy^2)^.5
_______________________
_
\
/_ (Dx^2+Dy^2)^.5
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|