Skip to main content
gamedev.net
🔒 Locked

Random heightmaps?

Started by CutterSlade 3 replies 800+ views
Original Post
CutterSlade
CutterSlade
Hello. I''m making a game similar to Worms, only in 3D, and for that I''ve been looking for ways to create random heightmaps on-the-fly to be used by the terrain engine (TrueVision 3D). Do any of you know where I could find a piece of code (preferrably in Visual Basic or C/C++) or small standalone utility that would generate a random heightmap and then store it in grayscale image file? Thanks in advance
--------------------------------------------------------- There are 10 kinds of people: those who know binary and those who don't
TerranFury
TerranFury
Perlin noise could do the trick: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

So could something simpler to program like the fault algorithm. The fault algorithm works like this: Generate two random points. These define a line. Randomly decide whether to make one side "high" or the other "low." Then add a small constant to all points on the "high" side and subtract it from all points on the "low" side. Repeat a thousand or so times. Done.
scaught
scaught
And remember, rand() is horribly repetitive in its lower bits, so don''t do rand()%11-5, use the more significant bits instead.

Though on second thought, maybe that''s actually ok for terrain.

-scott

Topic Locked

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

Sign in to reply to this topic.