Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Fractal Matrix Function

Author
Message
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 28th Aug 2007 05:00 Edited at: 28th Aug 2007 05:01
Screen shots:





Instead of using DBPro's built in matrices, I've used Phaelax's faster memblock matrix functions, which you can find here: http://forum.thegamecreators.com/?m=forum_view&t=32935&b=6

Here's the function that you call to fractalize the memblock matrix:

fractal_matrix(number as integer, k as float, d as float,minh as float, maxh as float)

Paramters:
number as integer - memblock matrix number

k as float - controls the hilliness of the terrain
0 - flat
0.3 - small hills
0.7 - hilly
1 - mountainous
>1 - cliffs

d as float - controls the bumpiness of the terrain
0 - no bumps
0.5 - some bumps
0.9 - bumpy
1 - mountainous-like bumps
>1 spiky

minh as float - minimum any part of the matrix can have
maxh as float - maximum any part of the matrix can have


Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Aug 2007 17:20
That's bloody impressive.

I was thinking about this sort of thing a few months back, and I was hoping you could explain how you did this?

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 28th Aug 2007 22:54
That is cool

lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 29th Aug 2007 00:20
Ankillito
17
Years of Service
User Offline
Joined: 10th Dec 2006
Location: Litigious California
Posted: 29th Aug 2007 02:50
Wow!! LL used remarks! I'm so proud.

That is really cool...

http://forum.thegamecreators.com/xt/xt_apollo_pic.php?i=1234759
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 29th Aug 2007 03:36 Edited at: 29th Aug 2007 03:41
Quote: "Wow!! LL used remarks! I'm so proud."

Nope, those are Phaelax's . The only part of the code that is mine are the fractal functions.

I've implemented the exact diamond-square algorithm described on http://gameprogrammer.com/fractal.html
I think it works better. The only downside is the terrain must have the same number of x segments as z segments, both of which must be a power of 2. The example has 2^7 segments a side.

Here's the full source:


Here are the three main functions that drive the diamond-square algorithm. You'll notice fractal_matrix() is no longer recursive and I added another parameter, island. If island is true, it will make a random island terrain, else it will make normal terrain:
Mr Tank
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: United Kingdom
Posted: 29th Aug 2007 03:45 Edited at: 29th Aug 2007 03:58
Wow! that looks very cool. All my ground is flat at the moment, but i could do with some speed. Going to check out those memblock matrix functions.
Just tried it. Appears to work faster than matrices do, even when updating! Thanks very much.

SUPER BADASS SPACESHIP X: WEBSITE
FORUM TOPIC
lower logic
18
Years of Service
User Offline
Joined: 15th Jun 2006
Location:
Posted: 30th Aug 2007 19:34 Edited at: 30th Aug 2007 19:34
Turned it into a sort of bubbling lava:

Login to post a reply

Server time is: 2024-11-22 18:25:43
Your offset time is: 2024-11-22 18:25:43