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 / Matrix heightmapping using images

Author
Message
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 23rd Nov 2002 23:04
This might be useful to anyone who can't figure out matrix terrains, or as a simple way to make levels. Basically, you load an image, make a matrix and run the function to set all the matrix heights. It's in it's early stages, so if anyone has any comments/suggestions please say so.



Matnumber is the matrix number, imgnumber is the image number, x and y are the width and depth of the matrix and scale is the amount the height is to be scaled by. I haven't managed to scale the built in terrain commands, so I find this more useful. Remember the image has to be one bigger than the matrix grid size in each direction, for example if you had a 50x50 matrix, the image would have to be 51x51 pixels.

As yet there's no tilemapping function, I might make that soon, and then an editor to integrate the functions and produce images.
Bighead
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location:
Posted: 24th Nov 2002 10:08
I tried it but "memblock word(1,12+(k*2)))*scale)" was always 0.

Do you have a complete example (with all the media included)?
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 24th Nov 2002 20:34
Yes, here's one that turns the image into a bunch of canyons. By the way the images I'm using are 256 colours.



This is the image I'm using:



called map.bmp
Bighead
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location:
Posted: 24th Nov 2002 23:17
Well, I have a 1024x1024 (100k) jpg file that it is well represented by the terrain commands. However, when I use matrix_heightmap function the output has nothing to do with it.

If you want I could email the jpg image so that you can check what I mean.
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 30th Nov 2002 23:39
Ok, I'll see what I get. TheDarthster@hotmail.com
Bighead
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location:
Posted: 1st Dec 2002 21:09
Ok, I've emailed the file to you ...
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 2nd Dec 2002 00:36
The image I received translated into a matrix fairly well except for spikes in the middle of the canyon which I wasn't expecting. The image was nowhere near 1024x1024 however.
G Man X
21
Years of Service
User Offline
Joined: 11th Dec 2002
Location:
Posted: 15th Dec 2002 15:46
When I tried to use a rectangular pic I soon realised that it should be "set matrix height matnumber,(x-i),j,(memblock word(1,12+(k*2)))*0.001*scale" in the function definition. Still having trouble getting it to work though... I get a matrix but the bumps on it bear little resemblance to the picture

Good The Boyz Have Done It Is!
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 15th Dec 2002 23:43
Oops, I nearly always get my x and z mixed up with arrays. Oddly enough, every picture I've tried comes out exactly the way I expect, yet no-one else's does. Oh well, back to the drawing board...
Pheagey
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Mid-Fl., USA
Posted: 28th Jan 2003 07:44
Um, this worked or me, quite well infact. Thanks I was really looking for somethinglike this.

haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 28th Jan 2003 18:07
Here is my take on moulding a matrix from a heightmap, To make the matrix look smooth increase the variable blur factor.



Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Epidemicz
22
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 28th Jan 2003 23:56
TheDarthster:

Are all the pictures that you are using small? Are set dimensions I should make may heightmap in? Because, I'm getting the same "matrix coordinates illegal" error...

I am the very disease you pretend to be.
Pheagey
21
Years of Service
User Offline
Joined: 26th Jan 2003
Location: Mid-Fl., USA
Posted: 29th Jan 2003 00:50
The height map must be square. I.E 10*10,100*100
Also they need to be 1 pixel larger than the size of the matrix you are making. So if the matrix will be 10*10 your image should eb 11*11. If the matrix is 100*100 your image should be 101*101.

The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 29th Jan 2003 19:09
I'm using 50x50 matrices, and 51x51 pixel images. Make sure the matrix width and length x and y actually exist, don't try to set x and y higher than the matrix size. Also, if you are not using square images, see G Man X's comment for a correction.
ducati916
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 2nd Jul 2003 03:07
ok i used this code works good btw

but there is a slight problem if ur using the "set display mode"
set to 32 bit color then all u will get is a ugly matrix made up of spikes

so just set the color to 16 and it should work fine

btw can anyone explain 16 bit and 32 bit color difrences coz i cant see no difrence in vision of performance??

thanx

Login to post a reply

Server time is: 2024-11-24 02:47:57
Your offset time is: 2024-11-24 02:47:57