A real Newbe Question about Height maps

Started by
13 comments, last by Sixten 21 years, 4 months ago
hi,

using an 8-bit grayscale .raw file is much efficient. you just load this as unsigned char. so you''re height map array now contains values between 0 to 255, then you just use this values for your terrain''s y vertices, and you won''t have to go thru all those texture loading/locking etc., stuffs,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
Advertisement
Well how do i create .raw files then.. and i am making a terrain Egnine and i want to be abel to load more the one sort of file so im gonna use height maps to.... so can anyone help me with the code???
Try DevIL for image loading. It loads many image file formats into memory (a nicely accessible array of chars depending on the image format).

ILuint img;
ilGenImages(1, &img);
ilBindImage(img);
ilLoadImage("myHeightMap.png");
char *imagedata = ilGetData();

Depending on ilGetInteger(IL_FORMAT) or something along the lines -- check out the manual, my code probably doesn''t work -- you can access each pixel using imagedata[blah].

You could of course make a seperate app to load an image and save it to a more convenient format. This has the advantage that you can do some expensive preprocessing such as lighting and such...

Well im designing a game Engine.. and i want to be abel to load more the one typ of Maps... so i have a choise... and maybe someone elles wants to us emy game egine then i want him/her to be abel to choose thier map files... so i want to know how i can get the code i got right now working then i will start on Raw, map and other files...
hi sixten,

you could use paintshop pro to generate .raw files and you don't need any helper or library to load an 8bit grayscale .raw file because, well it's already in 'raw' so loading it can be accomplished by this,

FILE *pFile = NULL;

pFile = fopen( rawfile, "rb" );
fread( HeightMapArray[999], 1, 999, pFile );
fclose(pFile);

and later, you can now use your heightmaparray to assign the heights to your y's vertices,

find out more at gametutorial's, they have a heightmap tutorial there,



[edited by - mickey on December 14, 2002 10:13:13 AM]
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,

This topic is closed to new replies.

Advertisement