Skip to main content
GameDev.net gamedev.net
🔒 Locked

How do you do this...

Started by CProgrammer Dec 30, 2003 at 12:29 AM 6 replies 650+ views
Original Post
CProgrammer
CProgrammer
When I make a terrain engine I specify for each tile a height and then weld the corner vertices together in the position of the lowest vertex. How do you do this? -CProgrammer
wasd
wasd
I think what you''d normally do is specify the height for each point on a grid, then use the points to generate triangles to render. That way, each triangle is automatically welded to it''s surrounding ones.

E.G

.-.-.-.-.-.
.\.\.\.\.\.
.\.\.\.\.\.
.\.\.\.\.\.
.-.-.-.-.-.

Well, that doens''t really look too good, but basically, each . has a height, and your triangles are constructed between all the .s

---------------------------------------

Let''s struggle for our dream of Game!

http://andrewporritt.4t.com
Ilici
Ilici
each pixel in the height map represents a vertex like:

pixel[x, y] = height; so the vertex is:

V(x * horizScale, height * verticalSCale, y * horizScale);

thus for a 2^n patch of triangles you need a 2^n + 1 heightmap
shurcool
shurcool
So to create a one tile terrain, you''d need a heightmap with 4 pixels, not just one. Interesting.

---
shurcooL`
Kaezin
Kaezin
Yep.

And to save you time, if you want a map x tiles across and y tiles high, you will need (x+1)*(y+1) vertices. To find the height of an object in the middle of the tile, I just find the average of the four heights.
Half the people you know are below average.Trogdor the Burninator
CProgrammer
CProgrammer
quote:
Original post by shurcool
So to create a one tile terrain, you''d need a heightmap with 4 pixels, not just one. Interesting.

---
shurcooL`


Being sarcastic huh? Well at the moment my engine needs only one pixel. But i''m beginning to believe the per vertex approach mentioned here makes more sense. Any comments?
-CProgrammer
Ilici
Ilici
quote:
Original post by CProgrammer
But i''m beginning to believe the per vertex approach mentioned here makes more sense. Any comments?
-CProgrammer



You are correct sir!

1 pixel -> 1 vertex.
shurcool
shurcool
quote:
Original post by CProgrammer
quote:
Original post by shurcool
So to create a one tile terrain, you''d need a heightmap with 4 pixels, not just one. Interesting.

---
shurcooL


Being sarcastic huh? Well at the moment my engine needs only one pixel. But i''m beginning to believe the per vertex approach mentioned here makes more sense. Any comments?
-CProgrammer


No, actually, I''m not. I just never thought about this before, and found it neat.

---
shurcooL

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.